BIAPAY PAYMENT GATEWAY SDK
BIAPAY Payment Gateway SDK is a high-level wrapper around the BIAPAY Payment Gateway API that provides strongly typed responses and exceptions.
Features
- BIAPAY Payment Gateway SDK for Flutter.
- Easy to use.
- Support for Android and iOS.
- No need to setup any additional configuration.
- Safe & Secure
- Instant Cashout
- End-to-end encryption
- Transparent Pricing
Getting Started
Installation
Install the latest version from pub.dev.
Add this biapay_gateway to your package's pubspec.yaml file:
dependencies:
biapay_gateway: [version]
or Run this command with your terminal:
$ flutter pub add biapay_gateway
Start to Code
Import package
Import the package into your dart file. If you are using Android Studio or VS Code, you can do this easily by pressing Alt+Enter
and selecting the import package option. Otherwise, you can manually import the package by adding the following line to your dart file:
// Import package
import 'package:biapay_gateway/biapay_gateway.dart';
Example
Create a new instance of BiaPayGateway
class. and pass required parameters. clientId
, clientSecret
, email
, mobileNumber
, orderId
, amount
, currencyCode
, transactionId
and transactionType
are required parameters.
// Import package
import 'package:biapay_gateway/biapay_gateway.dart';
// Create a new instance of BiaPayGateway class.
final biapay = BiaPayGateway(
clientId: 'clientId',
clientSecret: 'clientSecret',
email: 'email',
mobileNumber: 'mobileNumber',
orderId: 'orderId',
amount: 'amount',
currencyCode: 'currencyCode',
transactionId: 'transactionId',
transactionType: 'transactionType',
);
- After creating a new instance of
BiaPayGateway
class. calllaunch
method to start payment process.launch
method will return aFuture
object. You can useonSuccess
andonFailed
callback functions to handle success and error response. - Inside
onSuccess
andonFailed
callback functions you can access the data by using add parameter in callback function. You can use any name foronSuccess
andonFailed
callback function parameters.
// Call launch method to start payment process.
biapay.launch(
onSuccess: (response) {
// Handle success response.
},
onFailed: (error) {
// Handle failed response.
},
);
- Access the
onSuccess
andonFailed
callback response data. BothonSuccess
andonFailed
are return list of data withstatus
andmessage
keys as aMap
object. It's like a JSON response. You can access the data by using key names. Key name represents the name of the data. - For example,
status
is a key name ofstatus
data. You can access thestatus
data by usingstatus
key name.
// Call launch method to start payment process.
await biapay.launch(
onSuccess: (response) {
// Handle success response.
final orderId = response['orderId'];
final status = response['status'];
final currency = response['currency'];
final amount = response['amount'];
final biapayTransactionId = response['biapayTransactionId'];
final transactionId = response['transactionId'];
final biapaySignature = response['biapaySignature'];
final message = response['message'];
// Do something with response data.
},
onFailed: (error) {
// Handle failed response.
final status = error['status'];
final message = error['message'];
// Do something with error data.
},
);
onSuccess
is a callback function that will be called when payment process is completed successfully.
onFailed
is a callback function that will be called when payment process is failed.
Both onSuccess
and onFailed
are return JSON response with status
and message
keys.
- You can check your payment signature by using
verifySignature
method.verifySignature
method will return aFuture
object. verifySignature
method requiredorderId
,biapayTransactionId
,transactionId
,clientSecret
, andbiapaySignature
parameters.verifySignature
method will return list of data withmessage
of the signature verification process.verifySignature
method will returnorderId
biapayTransactionId
transactionId
biapaySignature
generatedSignature
message
keys as aMap
object. It's like a JSON response. You can access the data by using key names. Key name represents the name of the data.
// Call verifySignature method to verify payment signature.
final value = await biapay.verifySignature(
orderIdVerify,
biapayTransactionIdVerify,
transactionIdVerify,
clientSecret,
biapaySignatureVerify
);
// Access the data by using key names.
final orderId = value['orderId'];
final biapayTransactionId = value['biapayTransactionId'];
final transactionId = value['transactionId'];
final biapaySignature = value['biapaySignature'];
final generatedSignature = value['generatedSignature'];
final message = value['message'];
Response
Success Response
onSuccess
callback function will return a list of data withstatus
andmessage
keys.status
key is a String value that will return status of payment process.message
key is a String value that will return message of payment process.
{
"orderId": "xxx",
"status": "COMPLETED",
"currency": "USD",
"amount": 240,
"biapayTransactionId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"transactionId": "xxxxx",
"biapaySignature": "/*************",
"message": "Your payment has been successfully completed."
}
Error Response
onFailed
callback function will return a list of data withstatus
andmessage
keys.status
key is a String value that will return status of payment process.message
key is a String value that will return message of payment process.
{
"status": "FAILED",
"message": "Your payment has been failed."
}
Verified Signature Response
{
"orderId": "xxx",
"biapayTransactionId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"transactionId": "xxxxx",
"biapaySignature": "xxxxxxxxxxxxxxxxxxxxxxx",
"generatedSignature": "xxxxxxxxxxxxxxxxxxxxxxx",
"message": "Signature verified successfully."
}
Additional information
For more information, see BIAPAY.