-
Notifications
You must be signed in to change notification settings - Fork 10
PayU PhonePe InApp SDK Integration
himgupta229 edited this page Nov 11, 2019
·
5 revisions
Gradle: implementation 'com.payu.phonepe:phonepe-intent:1.4'
Add below url in root project build.gradle like below:
allprojects {
repositories {
maven {
url "https://phonepe.bintray.com/PhonePeIntentSDK"
}
}
}
1. Import gradle in your project or download the phonepe-intent-release.aar file from github.
2. In case integration with importing aar as a module please import below dependency also in your app build.gradle.
compile 'phonepe.intentsdk.android.release:IntentSDK:0.1.5.2'
3. Call method checkForPaymentAvailability available in PhonePe to check if PhonePe payment is available or not on device.This method is called before showing PhonePe as a checkout option.
Sample
PhonePe.getInstance().checkForPaymentAvailability(Activity activity, PayUPhonePeCallback callback, String paymentOptionHash, String merchantKey, String user_credentials)
Input :
PayUPhonePeCallback : the class to provide callbacks
Activity : Activity
paymentOptionHash : Payment Related Details hash
merchantKey : PayU Merchant Key
user_credentials : Provide user credentials or use "default"
Notes:
To generate paymentoptionHash use below method
sha512(key|command|var1|salt)
where key = Provide your merchant key here
command = "payment_related_details_for_mobile_sdk"
var1 = Provide user credentials or use "default"
salt = Provide your merchant salt here
After successful initialisation of PhonePe by calling checkForPaymentAvailability method call makePayment method to make payment.
Sample
PhonePe.getInstance().makePayment(PayUPhonePeCallback callback, Activity activity, String postData,boolean isUserCacheEnabled, View customDialogView);
Input:
PayUPhonePeCallback : the class to provide callbacks
Activity : activity instance
postData : PayU postdata
isUserCacheEnabled : To Enable/Disable User Cache
customDialogView : Provide your Custom Progress Dialog View(Optional)
Sample post data:
txnid=1524122818080&productinfo=product_info&user_credentials=default&key=*****&surl=**SUCCESS_URL**&furl=**FAILURE_URL&firstname=firstname&[email protected]&amount=10&udf1=udf1&udf2=udf2&udf3=udf3&udf4=udf4&udf5=udf5&pg=CASH&bankcode=PPINTENT&hash=***PAYMENT_HASH***
Notes:
To generate paymentHash use below method
sha512(key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||salt)
where key = Provide merchant key
txnid = Provide transaction id
amount = Provide transaction amount
productinfo = Provide product info
firstname = Provide customer firstname
email = Provide customer email
udf1-udf5 = Used Defined values
salt = Provide merchant Salt
List of the callback function provided by PayU PhonePe:
-
onPaymentOptionFailure (String payuResponse, String merchantResponse) - Calls when payment fails
-
onPaymentOptionSuccess (String payuResponse, String merchantResponse) - Calls when payment succeeds
-
onPaymentOptionInitialisationFailure (int errorCode,String description) - Called for PhonePe initialisation failure where,
- errorCode : Error Code
- description : Error Description
Following are error messages w.r.t. PhonePe initialisation failure
- ErrorCode : Description
- 1 : MERCHANT_KEY_NOT_REGISTER_FOR_PHONEPE // Merchant is not registered for
PhonePe with PayU
- onPaymentOptionInitialisationSuccess (boolean result) - Callback when PhonePe is successfully initialised.
// Callback for PhonePe
PayUPhonePeCallback payUPhonePeCallback = new PayUPhonePeCallback() {
@Override
public void onPaymentOptionFailure(String payuResponse, String merchantResponse) {
super.onPaymentOptionFailure(payuResponse, merchantResponse);
Intent intent = new Intent();
intent.putExtra("payu_response", payuResponse);
intent.putExtra("result", merchantResponse);
setResult(Activity.RESULT_CANCELED, intent);
finish();
}
@Override
public void onPaymentOptionInitialisationSuccess(boolean result) {
super.onPaymentOptionInitialisationSuccess(result);
// Merchants are advised to show PhonePe option on their UI after this callback is called.
}
@Override
public void onPaymentOptionSuccess(String payuResponse, String merchantResponse) {
super.onPaymentOptionSuccess(payuResponse, merchantResponse);
Intent intent = new Intent();
intent.putExtra("payu_response", payuResponse);
intent.putExtra("result", merchantResponse);
setResult(Activity.RESULT_OK, intent);
finish();
}
@Override
public void onPaymentOptionInitialisationFailure (int errorCode, String description) {
//Callback thrown in case PhonePe initialisation fails.
}
};
- SDKs Overview
- Server Side
- Client Side
- Android SDK Integration
- Android Custom Browser
- Android Samsung Pay SDK integration
- Android PhonePe Intent SDK integration
- Android Google Pay™ SDK Integration
- Android PayU CheckoutPro SDK Integration
- IOS PayU CheckoutPro SDK Integration
- iOS integration with PayU Checkout UI
- iOS SDK integration
- iOS Custom Browser
- Mobile Releases
- FAQs
- Common Issues