flutter_payu 0.0.3
flutter_payu: ^0.0.3 copied to clipboard

payu sdk.

Flutter payu SDK #

Currently only Android is supported

author #

zhaolong Email:zhaoyuen123@126.com

Integration Steps #

Step 1: Add Dependency #

  flutter_payu: ^0.0.2

<br/>

Step 2: Add permissions (Android) #

The Cashfree PG SDK requires that you add the INTERNET permission in your Android Manifest file.

<manifest ...>
    <uses-permission android:name="android.permission.INTERNET" />
<application ...>

Step 3: Add plist value (iOS) #

Opt-in to the embedded views preview by adding a boolean property to the app's Info.plist file with the key io.flutter.embedded_views_preview and the value YES. This is required by the flutter_webview plugin.

    <key>io.flutter.embedded_views_preview</key>
    <true/>

Step 4: Register merchantKey,merchantSalt #

here.

Step 5: Initiate Payment #

  • App passes the order info and the token to the SDK
  • Customer is shown the payment screen where he completes the payment
  • Once the payment is complete SDK verifies the payment
  • App receives the response from SDK and handles it appropriately

How to integrate #

For both the modes (normal and seamless) you need to invoke the doPayment() method. However, there are a few extra parameters you need to pass incase of seamless mode.

doPayment #

    String merchantKey = "gtKFFx";
    String email = "john@yopmail.com";
    String userCredential = merchantKey + ":" + email;
    Payu payu = new Payu(
      // test https://payumobile.gitbook.io/sdk-integration/test-merchant-list
      merchantKey: merchantKey,
      merchantSalt: "eCwWELxi",
      isProduction: false,
      amount: "1.0",
      email: email,
      firstName: "test",
      phone: "9876543210",
      surl: "https://payuresponse.firebaseapp.com/success",
      furl: "https://payuresponse.firebaseapp.com/failure",
      productInfo: "test",
      transactionId: "test-" + DateTime.now().millisecondsSinceEpoch.toString(),
      userCredential: userCredential,
    );
    _flutterPayu.doPayment(payu);

example #

    final FlutterPayu _flutterPayu = FlutterPayu();
    _flutterPayu.on(FlutterPayu.EVENT_PAYMENT_SUCCESS, _handlePayuPaymentSuccess);
    _flutterPayu.on(FlutterPayu.EVENT_PAYMENT_ERROR, _handlePayuPaymentError);
    _flutterPayu.on(FlutterPayu.EVENT_PAYMENT_FAILURE, _handlePayuPaymentFailure);
    _flutterPayu.on(FlutterPayu.EVENT_PAYMENT_CANCEL, _handlePayuPaymentCancel);
    
    void _handlePayuPaymentSuccess(PayuSuccess response) async {
        print("Payu payment success payuResponse:" +response.payuResponse.toString());
        print("Payu payment success merchantResponse:" +response.merchantResponse.toString());
    }

    void _handlePayuPaymentFailure(PayuFailure response) async {
        print("Payu payment failure payuResponse:" +response.payuResponse.toString());
        print("Payu payment failure merchantResponse:" +response.merchantResponse.toString());
    }

    void _handlePayuPaymentError(PayuError payuError) async {
        print("Payu error:${payuError.message}");
    }

    void _handlePayuPaymentCancel(PayuError payuError) {
        print("Payu cancel:${payuError.message}");
    }

Payu Parameters #

here.

ParameterRequiredDescription
merchantSaltNoMerchant salt received from PayU Can be filled in, if not null will calculate the hash locally

NOTE #

There can be scenarios where the SDK is not able to verify the payment within a short period of time. The status of such orders will be PENDING