OlaMoney

This page describes how to integrate with OlaMoney SDK.

Gradle Dependency

Add below dependency in application's build.gradle.

implementation 'com.payu.olamoney:olamoney:1.1.0'

Callbacks

List of the callback function provided by PayU OlaMoney:

  1. onPaymentInitialisationSuccess() - Callback invoked if the customer is eligible for OlaMoney(Postpaid/Wallet).

  2. onPaymentInitialisationFailure(int errorCode, String description) - Callback invoked when there is some error in Customer eligibility.

Following are the errors which are received in onPaymentInitialisationFailure.

   - ErrorCode        : Description

   - 100              : Mandatory params are missing. Please check again! //Mandatory params for checking eligibility is missing.
       
   - 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 below method.

    /**
     * Method to check the eligibility of Customer for OlaMoney
     * @param activity Activity Context
     * @param callback {@link com.payu.olamoney.callbacks.OlaMoneyCallback}
     * @param olaMoneyParams {@link com.payu.olamoney.utils.PayUOlaMoneyParams}
     */
     new OlaMoney().checkForPaymentAvailability(Activity activity, OlaMoneyCallback callback, PayUOlaMoneyParams olaMoneyParams)

where object of PayUOlaMoneyParams can be created like below.

Kindly note that values that are set in PayUOlaMoneyParams must be the same that needs to be sent to PayU's backend in payment post-data.

Creating 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 below

OlaMoney Eligibility Hash Generation

To generate OlaMoney eligibility hash use below method

sha512(key|command|var1|salt) 
where
Key - Merchant Key
Command - get_eligible_payment_options
var1 - {\"amount\":\"<Transaction Amount>",\"txnid\":\"<Transaction Id>\",\"mobile_number\":\"<Customer Phone Number>",\"first_name\":\"<Customer first name>\",\"bankCode\":\"OLAM\",\"email\":\"<Customer's email>\",\"last_name\":\"<Customer's last name>\"}
Order of the fields should be the same written here.
Salt - Merchant's Salt

Ordering of the fields of var1 should be the same written above. 
amount: Amount that buyer needs to pay. 
txnid: Merchant generated Transaction id for the order. 
mobile_number: The buyer mobile number for OlaMoney Payment. 
first_name:  Buyer first name. 
bankCode: It must be OLAM. 
email: Buyer Email ID. Not mandatory If don’t have, send blank "". 
last_name: Buyer Last name. Not mandatory If don’t have, send blank "". 

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();
  }

To generate payment hash visit here.

After generating the postdata above either post it to CustomBrowser or any webview.

Set up for Test/Sandbox Merchant

If you are using the SDK with a test merchant, please provide this metadata value to the manifest file else removed these lines below.

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

</application>

Last updated