Adyen Google Wallet Provisioning
Android SDK simplifies integration with Google Wallet.
The SDK is available from Maven Central.
- Import the SDK by adding this line to your
build.gradle
file.
implementation("com.adyen.issuing:provisioning:0.3.0")
The SDK interaction is performed through calls to an instance of CardProvisioning
. This instance is provided by a static function of the CardProvisioning
class:
fun create(
sdkInput: String,
activityProvider: () -> Activity,
): CardProvisioningCreateResult
The CardProvisioning
class utilises suspend
functions which return when the requested operation has either completed or failed and return objects which can be queried for the request state:
suspend fun canProvision(): CanProvisionResult
suspend fun createSdkOutput(): GetSdkOutputResult
suspend fun provision(sdkInput: String, cardDisplayName: String, cardAddress: CardAddress): ProvisionResult
Perform a GET
request to endpoint /paymentInstruments/{paymentInstrumentId}/networkTokenActivationData
from your backend. The response contains sdkInput
data.
Make a call to the CardProvisioning.create()
static function passing in the sdkInput
data and a function which returns an Activity
(this function should return the Activity
which hosts your application's card issuing functionality, or the main Activity
for a single Activity
application).
The create()
function returns a result object which indicates success or failure of the operation. Possible failure reasons are that Google Pay is not supported for the given card or the the sdkInput
data is invalid and cannot be parsed.
val result = CardProvisioning.create(
sdkInput = sdkInput,
activityProvider = { cardIssuingActivity },
)
val cardProvisioning = when(result) {
is CardProvisioningCreateResult.Success -> result.cardProvisioning
is CardProvisioningCreateResult.Failure.GooglePayNotSupported -> throw Exception("The card does not support Google Pay")
is CardProvisioningCreateResult.Failure.InvalidSdkInput -> throw Exception("The sdk input data is invalid")
}
Check if the cardholder can add a payment card to their Google Wallet.
val canProvision = cardProvisioning.canProvision() == CanProvisionResult.CanBeProvisioned
When the cardholder opts to add a card to Google Wallet, initiate provisioning by performing the following steps:
- Make a call to
cardProvisioning.createSdkOuput()
to retrieve thesdkOuput
string required for step 2. - Make a
POST
paymentInstruments/{paymentInstrumentId}/networkTokenActivationData
request from your backend to provision the payment instrument. The body must contain thesdkOuput
obtained from step 1. The response contains thesdkInput
object. - Make a call to
cardProvisioning.provision()
passing thesdkInput
value plus the cardholder name string and an instance ofCardAddress
:
cardProvisioning.provision(
sdkInput = sdkInput,
cardDisplayName = "John Doe",
cardAddress = CardAddress()
)
Note: If you provide an empty CardAddress
, as above, then the user will be prompted to enter their address during the Google Wallet provisioning flow.
For more documentation refer to our complete documentation
This SDK is available under the Apache License, Version 2.0. For more information, see the LICENSE file.