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
onPaymentInitialisationFailure
callback 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.
ErrorCode | Error Message | Description |
---|---|---|
100 | Mandatory parameters are missing. Please check again! | Mandatory parameters for checking eligibility are missing. |
101 | Something 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>
Updated 2 months ago