Google Wallet In-App Provisioning enables cardholders to add their payment cards to Google Wallet directly from within your app. With this feature, cardholders can quickly and securely add their payment information to their Google Wallet, without having to manually enter their card details.
The Adyen Google Wallet Provisioning SDK has a transitive dependency on the Google Push Provisioning API (version 18.3.3).
The Google Push Provisioning API is not available publicly but can be provided by Adyen (ask your Adyen account manager) or requested from Google.
Once you have the API, the dependency must be made available to your development environment. This can be done via Maven Local by adding the files under your ~/.m2
directory or they can be hosted in an internal Maven repository if you have one.
Note: The Google Push Provisioning API should not be published in such a manner where it is made available publicly.
Adyen Google Wallet Provisioning SDK is available on GitHub. Installation instructions can be found there.
Before you start implementing the Adyen SDK, make sure that your system satisfies the following requirements:
With Google Wallet in-app provisioning, your cardholder can add their card directly from your app. During the in-app flow, the cardholder taps Add to Google Wallet and the provisioning process starts and finishes within your app providing a seamless flow.
The following diagram walks you through the in-app provisioning flow:
Before you start card provisioning, you must get activation data for the specified payment instrument.
From your server, make a GET /paymentInstruments/{id}/networkTokenActivationData
request and specify the id
of the payment instrument in the path. To make this request, your API credential needs the following role:
curl https://balanceplatform-api-test.adyen.com/bcl/v2/paymentInstruments/{id}/networkTokenActivationData \
-H 'x-api-key: YOUR_BALANCE_PLATFORM_API_KEY' \
-H 'content-type: application/json' \
The response contains the sdkInput
object that you need to initialize the provisioning service in the next step.
Pass the sdkInput
to your app.
Initialize the CardProvisioning
class that is used to check if the cardholder can add a payment card to their Google Wallet.
The CardProvisioning
instance is initialized by calling the CardProvisioning.create()
static method. Pass in the sdkInput
value from step 1 and a function returning an Activity
.
fun create(
sdkInput: String,
activityProvider: () -> Activity,
): CardProvisioningCreateResult
Example:
val result = CardProvisioning.create(
sdkInput,
{ myProvisiioningActivity }
)
val cardProvisioning = when(result) {
is CardProvisioningCreateResult.Success -> result.cardProvsioning
is CardProvisioningCreateResult.Failed.GooglePayNotSupported -> throw Exception("Google Pay not supported")
is CardProvisioningCreateResult.Failed.InvalidSdkInput -> throw Exception("Invalid sdk input")
}
The returned CardProvisioningCreateResult
will provide an instance of CardProvisioning
if successful or details of the error on failure.
The CardProvisioning
class provides suspend
functions which return when the requested operation has either completed or failed and return objects which can be queried for the request state.
Call the canProvision()
method of the CardProvisioning
instance.
suspend fun canProvision(): CanProvisionResult
The value returned by the canProvision()
method can be used to determine whether the Add card to Google Wallet button should be displayed or hidden.
Example:
val result = client.canProvision()
when(result) {
is CanProvisionResult.CanBeProvisioned -> displayGoogleWalletButton()
is CanProvisionResult.CannotBeProvisioned.AlreadyExistsInWallet -> hideGoogleWalletButton()
is CanProvisionResult.CannotBeProvisioned.Error -> throw result.throwable
is CanProvisionResult.CannotBeProvisioned.UnknownFailure -> throw Exception("Unknown failure")
}
When the user taps the Add card to Google Wallet button the following sequence of operations should be triggered:
createSdkOutput()
method of the CardProvisioning
instance to create the sdkOutput
value.
suspend fun createSdkOutput(): CreateSdkOutputResult
paymentInstruments/{id}/networkTokenActivationData
request and pass the sdkOutput
value to provision the payment instrument. The response contains the sdkInput
object.provision()
method of the CardProvisioning
instance, passing in the sdkInput
value. This will trigger the Google provisioning flow and the function call will return the result of the provisioning request once the flow has completed.
suspend fun provision(sdkInput: String, cardDisplayName: String, cardAddress: CardAddress): ProvisionResult
Example:
val result = client.provision(sdkInput, "John Doe", CardAddress())
when (result) {
is ProvisionResult.Success -> handleProvisionSuccess(result)
is ProvisionResult.Failure -> handleProvisionFailure(result)
}