Skip to content

Latest commit

 

History

History
101 lines (92 loc) · 3.57 KB

README.md

File metadata and controls

101 lines (92 loc) · 3.57 KB

payu

PayU Biz SDK & UI integration (beta)

A simple & Easiest way to integrate PayU Biz Payment Gateway with your Android Application

PayU Money

Step by step guide to integrate PayU Biz SDK with your Android Application
  1. Add Maven repository and compile dependency in build.gradle file.
    dependencies {
        compile 'com.sasidhar.smaps.payu:payu:0.0.5'
    }
    
  2. Add Internt Permissions in your Android Application Manifest file
        <uses-permission android:name="android.permission.INTERNET" />
    
  3. Create an object for PayuConfig Class and Configure your environement (test/dev)
    PayuConfig payuConfig = new PayuConfig();
    

    // for testing payuConfig.setEnvironment(PayuConstants.MOBILE_DEV_ENV);

    // for production payuConfig.setEnvironment(PayuConstants.PRODUCTION_ENV);

  4. Create an object for PaymentParams and obtain all the required parameters
  5. PaymentParams paymentParams = new PaymentParams();
    paymentParams.setKey("merchant_key"); // Get Merchant Key from PayU Biz Merchant Account
    paymentParams.setFirstName("name"); // User Name
    paymentParams.setEmail("email"); // User Email Address
    paymentParams.setPhone("phone"); // User Mobile Number
    paymentParams.setProductInfo("productinfo"); // Product info
    paymentParams.setAmount("amount"); // Amout 
    paymentParams.setTxnId(""); // Transaction ID
    paymentParams.setSurl("SURL"); // Success URL
    paymentParams.setFurl("FURL"); // Failure URL
    

    // User defined fields are optional (pass empty string)

    paymentParams.setUdf1(""); paymentParams.setUdf2(""); paymentParams.setUdf3(""); paymentParams.setUdf4(""); paymentParams.setUdf5("");

  6. Generate HASH by with PaymentParams object & SALT and add it to PaymentParams object.
    PayuHashes payuHashes = Utils.generateHashFromSDK(paymentParams, "SALT"); // Get SALT from PayU Biz Merchant Account
    paymentParams.setHash(payuHashes.getPaymentHash());
    

    Note: It is recommanded to generate HASH from your own server instea of here.

  7. Create an Intent to a PaymentActivity and pass PayuConfig, PaymentParams and PayuHashes objects that we are create in the above steps as intent extras.
    Intent intent = new Intent(this, PaymentActivity.class);
    intent.putExtra(PayuConstants.PAYU_CONFIG, payuConfig);
    intent.putExtra(PayuConstants.PAYMENT_PARAMS, paymentParams);
    intent.putExtra(PayuConstants.PAYU_HASHES, payuHashes);
    
  8. Start Activity for Result
    startActivityForResult(intent, PayuConstants.PAYU_REQUEST_CODE);
    
  9. Handle response at onActivityResult
    if (requestCode == PayuConstants.PAYU_REQUEST_CODE) {
        switch (resultCode) {
            case RESULT_OK:
                Toast.makeText(MainActivity.this, "Payment Success.", Toast.LENGTH_SHORT).show();
                break;
    
        case RESULT_CANCELED:
            Toast.makeText(MainActivity.this, "Payment Cancelled | Failed.", Toast.LENGTH_SHORT).show();
            break;
    }
    

    }

  10. Optionally you can alos configure Payment Methods to enable or disable by setting boolean value (true/false) before calling startActivityForResult
    PaymentOptions.DebitCardEnabled = true;
    PaymentOptions.CreditCardEnabled = true;
    PaymentOptions.isNetBankingEnabled = true;
    PaymentOptions.isEMIEnabled = false;
    PaymentOptions.isPayUMoneyWalletEnabled = true;
    PaymentOptions.isCashCardEnabled = false;