PayU biz is a payment gateway aggregator who offer electronic payment services to merchant website through its partnerships with various banks and payment instrument companies. With PayU,customers can pay through various options like Credit cards, Debit cards, Net banking, EMI,Cash Cards,Email Invoicing, IVR, Cash on Delivery(COD).
Integration of PayU biz in android application is quiet easy as they provide there own SDK with UI, its on you you can use their UI (Non-Seamless method) or create your own(Seamless method). Here we will integrate the PayU with Non-Seamless method in our Android Application.
Make sure you are registered with PayU biz and have your Merchant key and Salt if not, please get one for your website.
You can get the SDK from here and the Custom Browser from here which is required for the integration. Now when you have these put them as modules in your application and have a dependency to them from your application’s build.gradle as
Now whenever you want to make a payment you have to send all the values the SDK need to process your request. You can either get them from server or you can generate them in app by yourself. The earlier one is better as you should never put the Merchant key and Salt in your app for obvious security reasons. but here I am directly giving the values also the mode is STAGING_ENVIRONMENT, while going for release do change itd to PRODUCTION_ENVIRONMENT.
String key = "gtKFFx",salt = "eCwWELxi", amount = "10",product_info = "MY PRODUCT INFO",firstname = "John",
lastname = "Doe",pg = "CC", email = "[email protected]", txnID = "XXX5678",zip = "NNNNN", phone_num = "9754XXXXXX",
success_url = "http://mysuccess" ,failure_url = "http://failure";
String UDF =""; // User Defined Fields, you can put any data here.
Intent intent = new Intent(MainActivity.this, PayUBaseActivity.class);
mPaymentParams = new PaymentParams();
payuConfig = new PayuConfig();
//generate hashes or get them from server
PayuHashes hashes = getHashesFromServer();
In case needed, the php code for generating hashes is as follows.
$paymentHash = strtolower(hash('sha512', $code));
$arr['payment_hash'] = $paymentHash;
$cmnNameMerchantCodes = 'get_merchant_ibibo_codes';
$merchantCodesHash_str = key.'|' . $cmnNameMerchantCodes . '|default|'.SALT ;
$merchantCodesHash = strtolower(hash('sha512', $merchantCodesHash_str));
$arr['get_merchant_ibibo_codes_hash'] = $merchantCodesHash;
$cmnMobileSdk = 'vas_for_mobile_sdk';
$mobileSdk_str = key.'|' . $cmnMobileSdk . '|default|'.SALT;
$mobileSdk = strtolower(hash('sha512', $mobileSdk_str));
$arr['vas_for_mobile_sdk_hash'] = $mobileSdk;
$cmnPaymentRelatedDetailsForMobileSdk1 = 'payment_related_details_for_mobile_sdk';
$detailsForMobileSdk_str1 = key.'|' . $cmnPaymentRelatedDetailsForMobileSdk1 . '|default|'.SALT;
$detailsForMobileSdk1 = strtolower(hash('sha512', $detailsForMobileSdk_str1));
$arr['payment_related_details_for_mobile_sdk_hash'] = $detailsForMobileSdk1;
And you are ready for your test Payment. Be sure the hashes are same on both the ends server and mobile as they are matched at every point.
Source: https://developer.payubiz.in .