Android Ola Money SDK

A lightweight SDK which supports payments via OlaMoney (Postpaid + Wallet)

Set up build.gradle

Add the below dependency in the application’s build.gradle:

implementation 'in.payu:olamoney:1.3.1'

SDK Callbacks

PayU OlaMoney provides the following callback functions:

  • onPaymentInitialisationSuccess(): Callback invoked if the customer is eligible for OlaMoney(Postpaid/Wallet).
  • onPaymentInitialisationFailure(int errorCode, String description): Callback invoked when there is some error in Customer eligibility.
  • The following error messages are displayed when using onPaymentInitialisationFailure.

❗️

Error

Following errors can occur if the onPaymentInitialisationFailurecallback is failed:

100: Mandatory params are missing. Please check again!

101 Something Went Wrong!

Checking OlaMoney Eligibility

Before proceeding with payment via OlaMoney payment mode merchant must check whether the customer is eligible for OlaMoney or not by using the following code block:

new OlaMoney().checkForPaymentAvailability(Activity activity, OlaMoneyCallback callback, PayUOlaMoneyParams olaMoneyParams);

Where PayUOlaMoneyParams object can be created as mentioned in the next section.

πŸ“˜

Remember

Values set in the PayUOlaMoneyParams must be the same that needs to be sent to PayU’s backend in payment post-data.

Create PayUOlaMoneyParams

PayUOlaMoneyParams payUOlaMoneyParams = new PayUOlaMoneyParams(); 
payUOlaMoneyParams.setMobile(<Customer Mobile number>)); 
payUOlaMoneyParams.setFirstName(<Customer Firstname>); 
payUOlaMoneyParams.setTxnId(<TransactionId>); 
payUOlaMoneyParams.setMerchantKey(<PayU Merchant key>); 
payUOlaMoneyParams.setHash(<Hash generated for OlaMoney Eligibility check>); 
payUOlaMoneyParams.setAmount(<Amount that customer needs to pay>); 

Where OlaMoney eligibility hash can be created as described in the following section.

OlaMoney Eligibility Hash Generation

To generate the OlaMoney eligibility hash, use the method similar to the following:

sha512(key|command|var1|salt)

Where:

  • Key – Merchant Key
  • Command – get_eligible_payment_options
    var1 – {\”amount\”:\””,\”txnid\”:\”\”,\”mobile_number\”:\””,\”first_name\”:\”\”,\”bankCode\”:\”OLAM\”,\”email\”:\”\”,\”last_name\”:\”\”}
  • Salt – Merchant’s Salt

🚧

Remember

The fields in the hashing string and the parameters in the var1 field should be in the exact same order as shown above.

ErrorCodeError MessageDescription
100Mandatory parameters are missing. Please check again!Mandatory parameters for checking eligibility are missing.
101Something Went Wrong!

Payment Post Data

Payment post data can be created as follows:

PaymentParams paymentParams = new PaymentParams(); 
paymentParams.setKey(<Merchant Key>); 
paymentParams.setAmount(<Transaction Amount); 
paymentParams.setProductInfo(<Product_info>); 
paymentParams.setFirstName(<First Name of Customer>); 
paymentParams.setEmail(<Customer's email); 
paymentParams.setTxnId(<Transaction Id>); 
paymentParams.setSurl(<Success Url>); 
paymentParams.setFurl(<Failure Url>); 
paymentParams.setUdf1(β€œudf1”); 
paymentParams.setUdf2(β€œudf2”); 
paymentParams.setUdf3(β€œudf3”); 
paymentParams.setUdf4(β€œudf4”); 
paymentParams.setUdf5(β€œudf5”); 
paymentParams.setPhone(<Customer's Phone Number>); 
paymentParams.setHash(<Payment Hash>); 
PostData postData = new PayUOlaMoneyPaymentParams().getPaymentPostData(paymentParams);
if(postData.getCode() == PayuErrors.NO_ERROR){
String postDataValue = postData.getResult();
}else{
String errorValue = postData.getResult();
}

Set up for Test/Sandbox Merchant

If you use the SDK with a test merchant, please provide this metadata value to the manifest file.

<application
    <meta-data
        android:name="payu_web_service_url"
        android:value="https://test.payu.in" />

</application>