Integration Steps
The Android Customer Browser integration involves the following steps:
SDK Integration
Before you start with the integration, enable the payment methods that you want to offer to your customers from Dashboard > Settings > Payment methods. PayU enable Cards, UPI, and other payment methods by default, and we recommend that you enable other payment methods that are relevant to you. For more information, refer to Configure Checkout Payment Methods.
Step 1: Create a PayU account
First, create a PayU account. For more information, refer to Register for a Merchant Account.
Step 2: Set Up build.gradle
Add the following dependency in your application’s build.gradle:
implementation 'in.payu:payu-custom-browser:7.15.6'
Watch Out: If you are getting the following error:
Default interface methods are only supported starting with Android N (--min-api 24): Landroidx/lifecycle/DefaultLifecycleObserver;onCreate(Landroidx/lifecycle/LifecycleOwner;)V
Add the following compileOptions on your app's build.gradle:
android { compileOptions { sourceCompatibility 1.8 targetCompatibility 1.8 } }
From version 7.4.0 onwards, it is mandatory to import UPI SDK dependency if you want to make payments through any of the following UPI options along with the changes mentioned in the Third-Party Payments Support section.
- UPI Intent
- Collect
- Google Pay
- PhonePe
<uses-permission android:name="android.permission.RECEIVE_SMS" />
Tip: Merchants are advised to add this permission in the application’s
AndroidManifest.xml
to support OTP assist. In case your application supports a minimum SDK of less than 20, do these changes in your surl/furl.
Step 3: Check for Payment Availability
The CheckForPaymentAvailability
function in CustomBrowser class. Checks for payment option type availability:
Activity : activity instance
PaymentOption : Payment Option type e.g.PaymentOption.SAMSUNGPAY,PaymentOption.PHONEPE
PayUCustomBrowserCallback : this class provide callbacks
paymentOptionHash : Payment Related Details Hash
merchantKey : PayU Merchant Key
user_credentials : User credentials or use "default"
Generate PaymentOption HashTo generate PaymentOption Hash refer to Hash Generation.
Formula :-sha512(key|command|var1|salt)
where
key= Provide your merchant key here command= "payment_related_details_for_mobile_sdk" // Api Commands salt= Provide your merchant salt here var1= Provide user credentials or use "default"
For more information, refer to Generate Static Hash.
Sample
new CustomBrowser().checkForPaymentAvailability(Activity activity, PaymentOption paymentOption, PayUCustomBrowserCallback payUCustomBrowserCallback, String paymentOptionHash, String merchantKey, String user_credentials)
Step 2: Invoke CustomBrowser
To invoke CustomBrowser:
Create a basic object of CustomBrowserConfig similar to the following code snippet. For more information on configurations supported, refer to Android CustomBrowser Configurations.
Post URL can be any of the following:
Production - https://secure.payu.in/_payment Staging - https://test.payu.in/_payment
CustomBrowserConfig customBrowserConfig = new CustomBrowserConfig(merchantKey,txnId);
customBrowserConfig.setPayuPostData(<Post Data>);
customBrowserConfig.setPostUrl(<Post Url>);
- Create an object of
PayUCustomBrowserCallback
. - Call method
addCustomBrowser()
similar to the following code snippet:
Input:
Activity
: activity instance.CustomBrowserConfig
: configuration object of the custom browser.PayUCustomBrowserCallback
: this class provides callbacks.
Input:
Activity : activity instance
CustomBrowserConfig : configuration object of the custom browser
PayUCustomBrowserCallback : this class provide callbacks
Sample
new CustomBrowser().addCustomBrowser( Activity activity, CustomBrowserConfig customBrowserConfig, PayUCustomBrowserCallback cbPayUCustomBrowserCallback)
Sample Post Request
Card
firstname=John&ccnum=5123456789012346&device_type=1&ccvv=123&ccexpyr=2025&key=gt****&[email protected]
&bankcode=CC&txnid=1705055037779&amount=1.0&udf5=udf5&ccexpmon=05&surl=https://cbjs.payu.in/sdk/success
&udf3=udf3&udf4=udf4&udf1=udf1&udf2=udf2&sdk_platform=[{"name":"PayUCheckoutPro","platform":"android","version":"2.0.27"},{"platform":"android","name":"coresdk","version":"7.0.1"},
{"platform":"android","name":"pgsdk","version":"2.0.5"},{"platform":"android","name":"custombrowser","version":"7.11.14"}]
&phone=99999*****&pg=CC&furl=https://cbjs.payu.in/sdk/failure&productinfo=Macbook+Pro&ccname=PayuUser
&hash=a13d39d161c4377b4e81a97bc8b8bf06835628d208b379f3a15a4e352b88d1dc6fde878ff89e5c7d0eeb36f214d996313f4672432a92244c4950224a472c669b
Net Banking
amount=1.0&firstname=John&udf5=udf5&device_type=1&surl=https://cbjs.payu.in/sdk/success&udf3=udf3&
udf4=udf4&udf1=udf1&udf2=udf2&sdk_platform=[{"name":"PayUCheckoutPro","platform":"android","version":"2.0.27"},
{"platform":"android","name":"coresdk","version":"7.0.1"},{"platform":"android","name":"pgsdk","version":"2.0.5"},{"platform":"android","name":"custombrowser","version":"7.11.14"}]
&phone=99999*****&pg=NB&furl=https://cbjs.payu.in/sdk/failure&productinfo=Macbook+Pro&key=gt****&[email protected]
&hash=84d0fe7da879adb22429f2f4c33334c31ed164d819356b5f8842d4c207560cc4251c76b4211a476ca029ffd5581b6f760afe97c35c635d2eaa75d379619e6145
&bankcode=SBIB&txnid=1705055218155
Parameter | Description | Example |
---|---|---|
|
| TESTPG |
|
. Reference: For the test Net Banking credentials, refer to Test Cards, UPI ID, and Wallets . | TESTPGNB |
For the supported payment method, refer to Supported Payment Methods.
Test the Integration
After the integration is complete, you must test the integration before you go live and start collecting payment. You can start accepting actual payments from your customers once the test is successful.
You can make test payments using one of the payment methods configured at the Checkout.
Testing checklistThings to remember while testing an integration:
- To test the integration make sure that you are making a transaction call to the test endpoint.
- Use your test key and salt for the transaction requests. For more information, refer to Access Test Key and Salt.
- Set the value of the
environment
parameters to1
.
Test cards only for Test environmentThese test cards, UPI, and Wallet credentials must only be used in the sandbox environment. Using these test cards in production environment may cause validation error.
Test credentials for supported payment methods
Following are the payment methods supported in PayU Test mode.
Test credentials for Net Banking
Use the following credentials to test the Net Banking integration:
- user name: payu
- password: payu
- OTP: 123456
Test VPA for UPI
CalloutThe UPI in-app and UPI intent flow is not available in the Test mode.
You can use either of the following VPAs to test your UPI-related integration:
For Testing the UPI Collect flow, Please follow the below steps:-
- Once you enter the VPA click on the verify button and proceed to pay.
- In NPCI page timer will start, Don't "CLICK" on click text. Please wait on the NPCI page.
- The below link opens in the browser Paste the transaction ID at the end of the URL then click on the success/failure simulator page. After that, your app will redirect to your app with the transaction response.
https://pgsim01.payu.in/UPI-test-transaction/confirm/<Txn_id>
*For Android
You can add the below metadata under the application tag in the manifest file to test the UPI Collect flow on test env:-
Ensure to remove the code from the manifest file before going live.
<application>
<meta-data android:name="payu_debug_mode_enabled" android:value="true" /> // set the value to false for production environment
<meta-data android:name="payu_web_service_url" android:value="https://test.payu.in" /> //Comment in case of Production-->
<meta-data android:name="payu_post_url" android:value="https://test.payu.in"/> //Comment in case of Production-->
</appliction>
Test cards for EMI
You can use the following Debit and Credit cards to test Emi integration.
Kotak DC EMI |
|
AXIS DC EMI |
|
HDFC CC EMI |
|
ICICI CC EMI |
|
Test Wallets
You can use the following wallets and their corresponding credentials to test wallet integration.
Wallet | Mobile Number | OTP |
---|---|---|
PayTM | 7777777777 | 888888 |
PhonePe | Use the Phonepe Pre-Prod app for testing purposes as described in the following PhonePe doc. location: https://developer.phonepe.com/v1/docs/setting-up-test-account Download the app and register your mobile number and follow the instructions as described in the above PhonePe docs. | NA |
AmazonPay | You can test using your original Amazon account details. |
Go-live Checklist
Ensure these steps before you deploy the integration in a live environment.
Collect Live payments
After testing the integration end-to-end, once you are confident that the integration is working as expected, you can switch to live mode to start accepting payments from your customers.
Watch Out!Ensure that you are using the production merchant key and salt generated in the live mode.
Checklist 1: Update Production Key and Salt
To generate the live merchant key and salt:
- Log in to the PayU Dashboard and switch to Live Mode on the menu.
- Navigate to Developers → API Keys tab.
- Copy the key and salt using the copy button.
- Replace the Test key and salt with the Production key and salt in the payment integration code and start accepting actual payments.
Checklist 2: Configure setIsProduction()
Set the value of the setIsProduction()
to true
in the payment integration code. This enables the integration to accept live payments.
Checklist 3: Configure verify payment method
Configure the Verify payment method to fetch the payment status. We strongly recommend that you use this as a back up method to handle scenarios where the payment callback is failed due to technical error.
Checklist 4: Configure Webhook
We recommend that you configure Webhook to receive payment responses on your server. For more information, refer to Webhooks.
During the integration, refer the Generate Static Hash for hash generation details.
Updated 1 day ago