nano_payment_gateway 0.2.2 nano_payment_gateway: ^0.2.2 copied to clipboard
A Flutter package allows you to easily implement the payment gateway integration.
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:nano_payment_gateway/nano_payment_gateway.dart';
void main() => runApp(const MySample());
class MySample extends StatefulWidget {
const MySample({super.key});
@override
State<StatefulWidget> createState() => MySampleState();
}
class MySampleState extends State<MySample> {
void onTapConfirmAfterOTP(ResponseModel response) {
Navigator.of(context).pushReplacementNamed('/shopping', arguments: {
'description': response.data!['responseMessage'],
'statusCode': response.status
});
}
RequestBodyModel getRequestBody() {
Map<String, dynamic> billingAddress = {
"billingName": "",
"billingZip": "",
"billingState": "",
"billingCountry": "",
"billingTel": "",
"billingEmail": "",
"billingCity": "",
"billingAddress": ""
};
Map<String, dynamic> shippingAddress = {
"deliveryName": "",
"deliveryState": "",
"deliveryCountry": "",
"deliveryTel": "",
"deliveryZip": "",
"deliveryCity": "",
"deliveryAddress": ""
};
Map<String, dynamic> objectBody = {
"merchantId": "1",
"merchantName": "EzKart ECOM Provider",
"currencyCode": "AED",
"amount": "1000",
"merchantPublicKey":
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC5whV5aZ1mPiohGkE7GT2dYpr0iAW6STLbrE2yuT4DPAFRpXgeLJEPCGr2jakHlzEujzX+mr9ZHdY9ukp0ebyWBibWGPpqyVuSqGOx4BAukviltqPCmA+DGffxRcDh7cl+5HPwFCryiD7zKo1BOHCLLZFpck1ClgWETXIqbu8YEQIDAQAB",
"orderId": "Y665JG",
"cartId": "2",
"billingAddress": jsonEncode(billingAddress),
"shippingAddress": jsonEncode(shippingAddress),
"customerId": "0000000000001",
};
RequestBodyModel requestBody =
requestBodyModelFromJson(jsonEncode(objectBody));
return requestBody;
}
@override
Widget build(BuildContext context) {
return PaymentWidget(
requestBody: getRequestBody(),
onTapConfirmAfterOTP: onTapConfirmAfterOTP,
showAddress: true,
);
}
}