gatee_payment 1.1.2 gatee_payment: ^1.1.2 copied to clipboard
A streamlined package for seamless integration of Gate-E functionality into Flutter applications. Expedite the integration process, empower customization, and simplify the incorporation of Gate-E features.
gatee_payment #
A streamlined package for seamless integration of Gate-E functionality into Flutter applications. Expedite the integration process, empower customization, and simplify the incorporation of Gate-E features.
Screenshots #
Features #
- Effortless Integration: Seamlessly integrate Gate-E capabilities into your Flutter apps with minimal effort.
- Flexible Customization: Tailor the design and settings of the Gate-E integration to match your project's unique requirements.
- Time-Saving Solution: Save development time by utilizing pre-built components and streamlined integration processes.
Getting Started #
Before you start using the package:
1- Contact our business team (Gate-E): support@gate-e.com
2- Sign the agreement
3- pay for the service
4- Received the documents and agreements
5- Register in Gate-e portal
6- wait approval from provider
7- Recived approvel and Activate Payment Gateways - PG team
Usage #
To use this plugin, add gatee_payment as a dependency in your pubspec.yaml file.
Here's a quick example of how you can use the gatee_payment package:
1- The payment process starts by sending an initiating payment request through the “Initiate Payment” API.
- Test environment: https://www.test.gate-e.com/api/process.php
- Live environment: https://www.gate-e.com/api/process.php
- Required parameters:
Initiate Payment - parameters #
Name | Parameter | Type | Description |
---|---|---|---|
Merchant ID | unique_id | String | Unique ID of the company, you can get it from API Settings |
API Type | api_type | String | Value: 1 (with registration), Value: 2 (without registration) |
Original amount | amount | String | Set the required amount of the payment |
Action | action | String | value: background (return response in JSON format) |
Callback URL | callback_url | String | value: https://www.gate-e.com/api/callback.php, Hint: for test environment add test.gate-e |
Calculated Hash | calculated_hash | String | The calculated hash will be calculated according to posted data of the above list. |
Example #
//process
Future<Map<String, dynamic>> process() async {
final payload = {
'unique_id': unique_id,
'amount': amount,
'api_type': api_type,
'action': action,
'callback_url': call_back,
};
String calHash = await calculateHash(hash, payload);
final payload2 = {
'unique_id': unique_id,
'amount': amount,
'api_type': api_type.toString(),
'action': action,
'callback_url': call_back,
'calculated_hash': calHash,
};
final response = await http.post(Uri.parse(pro_url), body: payload2);
final jsonResponse = jsonDecode(response.body);
return {
'payment_id': jsonResponse["payment_id"],
'key': jsonResponse['key'],
};
}
//Calculated hash
String calculateHash(String hash, Map<String, String> data) {
data = SplayTreeMap<String, String>.from(data);
var data1 = '';
data.forEach((key, value) {
if (key != 'data' && key != 'note') {
data1 += '$key=$value;';
}
});
data1 += 'hash=$hash;';
var bytes = utf8.encode(data1);
var digest = md5.convert(bytes);
var calculatedHash = hex.encode(digest.bytes);
return calculatedHash;
}
Initiate Payment - sample response #
{
status: success,
payment_id: 57841211263245,
key: f452g5566ev544h55d58ss45,
payment_url: https://www.gate-e.com/api/payment.php?payment_id=57841211263245
}
2- Import package
import 'package:gatee_payment/payment_method.dart';
3- Call the provider in the main
ChangeNotifierProvider(
create: (BuildContext context) {
return CheckInternet();
},
),
4- After getting the payment_id and key from the process API, send them to the PaymentMethods() screen along with the screen you want to return back to (onFinishScreen).
ElevatedButton(
child: Text('SDK'),
onPressed: () async {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PaymentMethods(
paymentid: paymentId,
keyid: key,
onFinishScreen: HomeScreen(), //redirect to this screen
textBackButton: "Back to home", //not required - default is "Back"
onSuccessfulPayment: () {
// ex: display successfull payment
print("successfull payment");
},
onFailedPayment: () {
// ex: display unsuccessfull payment
print("unsuccessfull payment");
},
transaction: TransScreen(),
),
),
);
},
),