Native app
Native app integration gives you complete control over the Google Pay user experience within your mobile application or website. While Dintero handles the payment processing, you implement the Google Pay interface directly, providing a seamless experience for your customers.
Prerequisites
Google Pay Merchant Onboarding
Before implementing Google Pay in your app, you must complete Google's merchant onboarding process:
- Create a Google Pay API developer account
- Complete Google's merchant verification process
- Submit your integration for Google's review and approval
- Receive approval to process live transactions
Note: This process can take several weeks, so plan accordingly. You can begin development using Google's sandbox environment while awaiting approval.
Enable Google Pay on your Dintero account
During your onboarding, Google Pay will generally be enabled as a payment method by default. If it's not enabled, you can go to settings and payment methods. There you can enable Google Pay as a payment method for your account. If you use payment profiles ensure that Google Pay is added to the relevant profiles.
Integration with Dintero
Below we'll describe how you can implement the payment flow yourself. The flow is as follows:
- User initiates payment
- You request payment data from Google Pay
- Google Pay returns the payment data
- You post the payment data to Dintero
- If required, you ask user to perform 3-D Secure challenge
- You initiate the payment
Dintero API
To integrate directly with Dintero you can use the Checkout API, see the API reference.
To enable payments with Dintero you first need to create a session with Dintero. Also see how you can configure your session for payment in app.
Once you have a session you can get payment operations. For Google Pay, you want to
get the operation with a rel of submit-dintero-psp-googlepay
. This operation will contain the endpoint to use for submitting the
Google Pay payment data, as well as the fields you need to configure Google Pay:
supported_networks
: The supported networks for Google Paygateway_merchant_id
: This is your gateway merchant ID, which is your account ID. In production this should start with aP
, in test mode it should start with aT
gateway_id
: The gateway ID to use, this will always bedintero
googlepay_merchant_id
: For native implementation you should ignore this fieldhref
: This is the URL you should post the Google Pay payment data to
Setting up Google Pay
See the Google Pay Android overview for an overview of how it works, the payment flow, and various resources. You can follow the tutorial from Google Pay to configure Google Pay for Android.
Below we'll describe some of the steps for configuring Google Pay, specifically which values to use and where to find them.
Gateway ID and Gateway Merchant ID
Set the gateway and gateway merchant ID to ensure you use Dintero as the gateway.
The gateway should always be dintero
and will be returned in gateway_id
. The gateway merchant ID is returned in gateway_merchant_id
and should be your account ID.
private fun gatewayTokenizationSpecification(): JSONObject {
return JSONObject().apply {
put("type", "PAYMENT_GATEWAY")
put("parameters", JSONObject(mapOf(
"gateway" to "dintero",
"gatewayMerchantId" to "YOUR_DINTERO_ACCOUNT_ID")))
}
}
Replace YOUR_DINTERO_ACCOUNT_ID
with your actual Dintero account ID. The correct value is returned as gateway_merchant_id
in the payment operation. You can also find your account ID by logging in to Backoffice, where it will be displayed in the upper right corner. It is an 8-digit number with a preceding P or T (e.g., P12345678). Use PXXXXXXXX for production and TXXXXXXXX for testing (e.g., when in test mode).
Authorization Methods
Google Pay can provide both cards on file (PAN_ONLY
) or device tokens (CRYPTOGRAM_3DS
). Device tokens are tokens bound to an Android device that is authenticated with a 3-D Secure cryptogram. Dintero supports both methods.
Device tokens will generally not require 3-D Secure authentication as they are already authenticated, while PAN_ONLY
will generally require 3-D Secure authentication.
For native apps it is recommended to at least use CRYPTOGRAM_3DS
. To support both methods for maximum compatibility you can do the following:
private val allowedCardAuthMethods = JSONArray(listOf(
"PAN_ONLY",
"CRYPTOGRAM_3DS"))
Card Networks
You have to provide the card networks that you want to accept to Google Pay. While you can choose to not support all card networks, you should not provide any networks not supported by Dintero.
The card networks supported by Dintero are returned as supported_networks
in the payment operation.
private val allowedCardNetworks = JSONArray(listOf(
"MASTERCARD",
"VISA"))
Submitting Payment Token
Once everything is configured you can request a payment token from Google as described in their tutorial.
You should then receive the payment data that you should submit to Dintero. Use the href
returned in the payment operations for the submit-dintero-psp-googlepay
operation,
see the API reference
{
"reference": "<payment reference>",
"payment_data": "<Google Pay payment data>"
}
Ensure you send the payment_data
as a JSON string.
3-D Secure
You need to support performing 3-D Secure authentication even if you only support device tokens, as there can be instances where additional authentication is required.
Performing 3-D Secure
The response when you post payment data will let you know if you need to perform 3-D Secure or not. If auth_method.type
is NONE
there should be no need for 3-D Secure,
otherwise you need to find the operation with a rel
of 3d-secure-init-hosted
and open the provided URL in an iframe.
When the user has completed 3-D Secure you will receive a redirect back to the return URL used for the payment session.
The redirect will contain a query parameter status_3ds
with a value indicating the result of the 3-D Secure challenge: 3DS_SUCCESS
, 3DS_FAILURE
, or 3DS_CANCEL
.
Initiate Checkout Payment
After posting the Google Pay payment data to Dintero and performing 3-D Secure (if required), the next step is to initiate the checkout payment.
Make sure you set the payment_product_type
to dintero_psp.googlepay
. The psp_transaction_id
will be returned when you post the payment data to Dintero.
Testing
Sandbox Environment
You can use Google Pay's test environment during development to test your integration. Use pre-defined test cards to test different scenarios. Ensure you use the correct account ID when in test mode (it should start with a T).
The test payments will not charge any cards.
Make sure to verify that you handle 3-D Secure and handle the redirect correctly.
Production Testing
Once you are ready to test in production you can enable Google Pay for production and try payments. Note that this will actually charge your card, but you can cancel or refund the payment after testing.
If you want to avoid exposing Google Pay to customers while testing in production you can set up a payment profiles and add Google Pay to a profile that isn't used for customers.
Best Practices
Make sure you follow the following best practices.
- Never log or store Google Pay tokens
- Implement proper error handling to avoid exposing sensitive information
- Validate all payment responses on your server
Troubleshooting
Common Issues
- Ensure you have configured Google Pay with your own Google Pay merchant ID
- Verify gatewayMerchantId matches your Dintero account
- Check that Google Pay is enabled in your Dintero account
- Ensure proper authorization method configuration
- Ensure Google Pay is not configured with networks not supported by Dintero