Additional Support for Payment Methods
Additional support features availabile for card, wallets and more.
Use the Razorpay Android Custom SDK to integrate supported payment methods on the Checkout form of your Android app as per your business requirements. Here are some additional methods provided by the SDK for the integration and usage of payment methods:
You can use these methods for card payment method integration.
The SDK provides a method to get the card network name of the provided card number.
- At least 6 digits of the card number are required to identify the network.
- Possible values returned by this method are,
visa
,mastercard
andunknown
. - If it is not able to identify the network it returns
unknown
.
razorpay.getCardNetwork(cardNumber);
The SDK provides a checksum-based method to determine if the entered card number is valid or not.
razorpay.isValidCardNumber(cardNumber);
The SDK provides a method to get the length of the card number for a specific card network.
razorpay.getCardNetworkLength(cardNetworkName);
The SDK provides a method to fetch the bank logo's URL, here bankCode
is the code of bank, you will be able to get it from the response received in onPaymentMethodsReceived
callback.
razorpay.getBankLogoUrl(bankCode);
The SDK provides a method to get the wallet logo's URL.
razorpay.getWalletLogoUrl(walletName);
The SDK provides a method to get the wallet's square-shaped logo's URL.
razorpay.getWalletSqLogoUrl(walletName);
The SDK provides basic validation for the payment data JSONObject
. In case of a validation error, the SDK returns an error map in the onValidationError
callback function.
The sample code shown below describes a validation error on the contact
field:
razorpay.validateFields(payload, new ValidationListener() {@Overridepublic void onValidationSuccess() {try {webview.setVisibility(View.VISIBLE);outerBox.setVisibility(View.GONE);razorpay.submit(payload, PaymentOptions.this);} catch (Exception e) {Log.e("com.example", "Exception: ", e);}}@Overridepublic void onValidationError(Map error) {Log.d("com.example", "Validation failed: " + error.get("field") + " " + error.get("description"));Toast.makeText(PaymentOptions.this, "Validation: " + error.get("field") + " " + error.get("description"), Toast.LENGTH_SHORT).show();}});
Our SDK sets an instance of RazorpayWebViewClient
and RazorpayWebChromeClient
to the WebView passed to facilitate bank page optimizations. If you want to set your own custom WebViewClient
you have to extend RazorpayWebViewClient
and pass it to our SDK.
Watch Out!
This step is optional and is only required when you want to set a custom WebViewClient
/WebChromeClient
The sample code given below shows how to customize the RazorpayWebViewClient
:
/*** Extend the RazorpayWebViewClient for your custom hooks*/razorpay.setWebviewClient(new RazorpayWebViewClient(razorpay){@Overridepublic void onPageStarted(WebView view, String url, Bitmap favicon) {// Make sure you don't forget to call the super methodsuper.onPageStarted(view, url, favicon);Log.d(TAG, "Custom client onPageStarted");}@Overridepublic void onPageFinished(WebView view, String url) {// Make sure you don't forget to call the super methodsuper.onPageFinished(view, url);Log.d(TAG, "Custom client onPageFinished");}});
Similarly, you can set your own WebChromeClient
:
/*** Extend the RazorpayWebChromeClient for your custom hooks*/razorpay.setWebChromeClient(new RazorpayWebChromeClient() {@Overridepublic void onProgressChanged(WebView view, int newProgress) {// Make sure you don't forget to call the super methodsuper.onProgressChanged(view, newProgress);customProgressBar.setProgress(newProgress);}});
Is this integration guide useful?