payUParams static method

Future<Map> payUParams({
  1. required String amount,
  2. required bool isProduction,
  3. required String productInfo,
  4. required String merchantKey,
  5. required String userPhoneNumber,
  6. required String transactionId,
  7. required String firstName,
  8. required String merchantSalt,
  9. required String email,
  10. required String hashUrl,
  11. String merchantName = PayUParams.merchantName,
  12. bool showExitConfirmation = true,
  13. bool showLogs = false,
  14. String successURL = PayUParams.successURL,
  15. String failureURL = PayUParams.failureURL,
  16. required String userCredentials,
})

Implementation

static Future<Map<dynamic, dynamic>> payUParams({
  // amount is required
  required String amount,
  // Is Production or Test Environment
  required bool isProduction,
  // require product information
  required String productInfo,
  // merchant key
  required String merchantKey,
  // user's phone number is required by payumoney gateway
  required String userPhoneNumber,
  // a unique transactionId is required
  required String transactionId,
  // user's first name is required. make sure it doesn't have space
  required String firstName,
  // merchantSalt provided by the payumoney dashboard
  required String merchantSalt,
  // user's email for payment related notification. payumoney will handle emails
  required String email,
  // server url to generate hashes
  required String hashUrl,
  // optional Merchant Name will appear on payment page
  String merchantName = PayUParams.merchantName,
  // bool value will decide whether to show exit dialog or not
  bool showExitConfirmation = true,
  // Bool will decide whether to show debug logs or not
  bool showLogs = false,
  // payumoney success url
  String successURL = PayUParams.successURL,
  // payumoney failure url
  String failureURL = PayUParams.failureURL,
  // user credentials are used to store saved cards and payment details for repetive payments and fast checkouts.
  required String userCredentials,
}) async {
  try {
    // passing data to platform. expected to get <string,dynamic> Map in return
    final data = await _channel.invokeMethod('payUParams', {
      'amount': amount,
      'isProduction': isProduction,
      'productInfo': productInfo,
      'merchantKey': merchantKey,
      'userPhoneNumber': userPhoneNumber,
      'transactionId': transactionId,
      'firstName': firstName,
      'merchantSalt': merchantSalt,
      'email': email,
      'showLogs': showLogs,
      'merchantName': merchantName,
      'showExitConfirmation': showExitConfirmation,
      'successURL': successURL,
      'failureURL': failureURL,
      'hash': hashUrl,
      'userCredentials': userCredentials,
    });
    // returning response back to flutter app
    return data;
  } catch (error) {
    // debuging error in case of payment failure.
    debugPrint(error.toString());
    // creating map with failed status for better event handling
    final errorResponse = {"status": "failed", "message": "payment canceled"};
    // returning recently generated map as response
    return errorResponse;
  }
}