payment_gateway_demo 0.0.16 copy "payment_gateway_demo: ^0.0.16" to clipboard
payment_gateway_demo: ^0.0.16 copied to clipboard

unlistedoutdated

A payment gateway demo by Konze.

Payment Gateway Package for Flutter #

A payment gateway package for Flutter

Stripe Integration Steps #

Getting Started #


return StripePaymentPackagePage(
  jsonData,
  themeData: theme,
  onCallBack: (value) {
    if (value is PaymentIntent) {
      PaymentIntent paymentIntent = value;
      debugPrint('value ==>> ${paymentIntent.amount}');

      if (paymentIntent.status ==
          PaymentIntentsStatus.Succeeded) {
        ScaffoldMessenger.of(context).showSnackBar(
          const SnackBar(
            content: Text(
                'Success!: The payment was confirmed successfully, Thank You.'),
          ),
        );
      }
    } else {
      debugPrint('value ==>> $value');
      ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(content: Text('Error: $value')));
    }
  }
);

Installation #

flutter pub add payment_gateway_demo

Requirements #

Android

This plugin requires several changes to be able to work on Android devices. Please make sure you follow all these steps:

  1. Use Android 5.0 (API level 21) and above
  2. Use Kotlin version 1.5.0 and above: [example](https://github.com/flutter-stripe/flutter_stripe/blob/79b201a2e9b827196d6a97bb41e1d0e526632a5a/example/android/ .gradle#L2)
  3. Using a descendant of Theme.AppCompat for your activity: example, example night theme
  4. Using an up-to-date Android gradle build tools version: example and an up-to-date gradle version accordingly: example
  5. Using FlutterFragmentActivity instead of FlutterActivity in MainActivity.kt: example
  6. Rebuild the app, as the above changes don't update with hot reload

These changes are needed because the Android Stripe SDK requires the use of the AppCompat theme for their UI components and the Support Fragment Manager for the Payment Sheets

If you are having troubles to make this package to work on Android, join this discussion to get some support

iOS

Compatible with apps targeting iOS 12 or above.

To upgrade your iOS deployment target to 12.0, you can either do so in Xcode under your Build Settings, or by modifying IPHONEOS_DEPLOYMENT_TARGET in your project.pbxproj directly.

You will also need to update in your Podfile:

platform :ios, '12.0'

CashFree Integration Steps #

Getting Started #


CFPaymentPackagePage cfPaymentPackagePage = CFPaymentPackagePage();

String getRandomNo() {
   var rng = Random();
   return 'order ${rng.nextInt(1000000)}';
}

String envType = "TEST";
String requestId = getRandomNo();
String orderAmount = "1";
String? tokenData = "";
String customerName = "Arjun";
String orderNote = "Order Note";
String orderCurrency = "INR";
String appId = envType == "TEST"
        ? "1831dac3fd47d13be98b7fd11381"
        : "1848d0ce8441fb8ffa258bc98481";
String customerPhone = "9012341234";
String customerEmail = "sample@gmail.com";
String notifyUrl = "https://test.gocashfree.com/notify";

tokenData = "GET YOUR OWN TOKEN";

CFPaymentOrder cfPaymentOrder = cfPaymentPackagePage.initPaymentData(
   requestId,
   orderAmount,
   tokenData,
   customerName,
   orderNote,
   orderCurrency,
   customerPhone,
   customerEmail,
   notifyUrl,
   appId,
   envType,
);

cfPaymentPackagePage.doPayment(
    context,
    cfPaymentOrder.toMap(),
    callback: (value) {
      if (value is CFResponse) {
        CFResponse response = value;
        //Todo: CFResponse will provide you the result like payment status, message and payment details.
      }
    },
);

CashFree_PG Integration Steps #

Getting Started #


CFPGPaymentPackagePage cfPaymentPackagePage = CFPGPaymentPackagePage();

CFEnvironment envType = CFEnvironment.SANDBOX;
String requestId = "P20221028_205937530634e4e2a9d1db3163715c459";
String? tokenData = "TJS0QYArOhSt16eCkB4R";

CFPGPaymentOrder cfPaymentOrder = cfPaymentPackagePage.initPaymentData(
   '#FF0000',
   requestId,
   tokenData,
   envType,
);

await cfPaymentPackagePage.doPayment(
  context,
  (String message) {
    debugPrint("Verify Payment");
  },
  (CFErrorResponse responseCode, String message) {
    debugPrint("Error while making payment");
  },
);