nagad_payment_gateway 0.1.1
nagad_payment_gateway: ^0.1.1 copied to clipboard
A Flutter package for Nagad Online Payment API (Sandbox) Integration
Nagad Online Payment API Integration Flutter Package
This is a Flutter package for the merchants and service providers that want to incorporate a new online payment method provided by Nagad.
Note : Get your merchant credentials by contacting Nagad.
# Credentials to be provided by Nagad #
final merchantID = "Specific Merchant id"
final merchantPrivateKey = "Merchant Private Key"
final pgPublicKey = "Nagad Payment Gateway public Key"
Initialize the Nagad
instance: #
Create an instance of Credentials and provide it to the Nagad Instance:
Nagad nagad = Nagad(
credentials: const Credentials(
merchantID: merchantID,
merchantPrivateKey: merchantPrivateKey,
pgPublicKey: merchantPrivateKey,
isSandbox: true)); // switch to false for production
Note: Make sure to replace the provided credentials with your Nagad Sandbox or production credentials.
Set Additional Merchant Info #
Additional Merchant Info Fields | Length | Description |
---|---|---|
serviceName | 25 | Service Name Provided by Merchant |
serviceLogoURL | 1~1024 | Publicly accessible logo URL |
additionalFieldName EN | 20 | Additional Field Name to be shown in Payment Page for Locale EN |
additionalFieldName BN | 20 | Additional Field Name to be shown in Payment Page for Locale BN |
additionalFieldValue | 20 | Value of Additional Field in English |
Expample:
{
“serviceName” : “T Shirt”,
“serviceLogoURL” : “tinyurl.com/sampleLogoUrl”,
“additionalFieldNameEN” : “Color”,
“additionalFieldNameBN” : “রং”,
“additionalFieldValue” : “White”
}
N.B: Additional Merchant Info can be anything and will be saved for further usage. However only these fields will be shown in the payment page.
Regular Payment #
To make a regular merchant payment, use the pay
method:
Parameters #
amount:
The amount for payment
orderID:
This is unique identifier to place order for payment. You can use current millisecondsSinceEpoch for uniqueness.
Request
DateTime now = DateTime.now();
String orderId = 'order${now.millisecondsSinceEpoch}';
StatusAPIResponse statusAPIResponse =
await nagad.pay(context, amount: 10.0, orderId: orderId);
Response: StatusAPIResponse contains
- merchantId
- orderId
- paymentRefId
- amount
- clientMobileNo
- merchantMobileNo
- orderDateTime
- issuerPaymentDateTime
- issuerPaymentRefNo
- additionalMerchantInfo
- status
- statusCode
- cancelIssuerDateTime
- cancelIssuerRefNo
- serviceType
N.B: Save the required information to your database if needed
License #
nagad_payment_gateway package is licensed under the GNU General Public License (GPL) version 3.0.
©2024