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. call launch method to start payment process. launch method will return a Future object. You can use onSuccess and onFailed callback functions to handle success and error response.
  • Inside onSuccess and onFailed callback functions you can access the data by using add parameter in callback function. You can use any name for onSuccess and onFailed 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 and onFailed callback response data. Both onSuccess and onFailed are return list of data with status and message keys as a Map 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 of status data. You can access the status data by using status 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 a Future object.
  • verifySignature method required orderId, biapayTransactionId, transactionId, clientSecret, and biapaySignature parameters.
  • verifySignature method will return list of data with message of the signature verification process.
  • verifySignature method will return orderId biapayTransactionId transactionId biapaySignature generatedSignature message keys as a Map 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 with status and message 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 with status and message 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.