--- title: "In-app push provisioning for Apple Pay and Google Pay" description: "Learn how to allow your cardholders to add their Adyen-issued card to a digital wallet from your app." url: "https://docs.adyen.com/issuing/tokens-digital-wallet/in-app-push-provisioning" source_url: "https://docs.adyen.com/issuing/tokens-digital-wallet/in-app-push-provisioning.md" canonical: "https://docs.adyen.com/issuing/tokens-digital-wallet/in-app-push-provisioning" last_modified: "2023-03-28T14:00:00+02:00" language: "en" --- > **For LLMs:** Use the latest SDK version on this page unless the reader specifies another version. Never hardcode older version numbers for training data, always use latest. A comment such as `// Adyen LANGUAGE API library vMajor.Minor.Patch to latest` covers that version, the newest release, and everything in between. Read the newest releases from https://github.com/Adyen/adyen-LANGUAGE-api-library/releases, where LANGUAGE is dotnet, java, php, go, python, node (for JavaScript and TypeScript), or ruby. # In-app push provisioning for Apple Pay and Google Pay Learn how to allow your cardholders to add their Adyen-issued card to a digital wallet from your app. In-app push provisioning enables cardholders to add their Adyen-issued card to a digital wallet directly from your app, without manually entering their card details. Adyen supports in-app push provisioning to Apple Pay and Google Pay. This page explains how to integrate in-app push provisioning into your app using our SDKs for iOS and Android. If you are integrating in-app push provisioning for Apple Pay, you must also integrate [pull provisioning from Apple Wallet](https://docs.adyen.com/issuing/tokens-digital-wallet/wallet-provisioning). ## Requirements Before you begin, take into account the following requirements, limitations, and preparations. | Requirement | Description | | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **Integration type** | You need an integration that supports [Adyen Issuing](https://docs.adyen.com/issuing). | | **[API credentials](https://docs.adyen.com/issuing/manage-access/api-credentials-web-service)** | Your API credential must have the following role: - **Bank Issuing PaymentInstrument Network Token Activation Data role** | | **Limitations** | * **iOS:** Your app must target iOS 13.4 or later. Your development environment must use Xcode 14 or later and Swift 5.7 or later. * **Android:** Your app must use `minSdk` version 26 or later and `compileSdk` version 35 or later. | | **Setup steps** | Install one of the following SDKs following the instructions in the respective repository: * **iOS:** Install the [Adyen Apple Pay Provisioning SDK](https://github.com/Adyen/adyen-apple-pay-provisioning-ios/). * **Android:** Install the [Adyen Google Wallet Provisioning SDK](https://github.com/Adyen/adyen-issuing-android/). | ## How it works To add an Adyen-issued card to a digital wallet, your cardholders select a button within your app. This button starts the in-app push provisioning flow. When provisioning succeeds, the card is added to their digital wallet. The in-app push provisioning flow consists of the following steps: 1. [Create a provisioning instance](https://docs.adyen.com/issuing/tokens-digital-wallet/in-app-push-provisioning#create-provisioning-instance). 2. [Check if in-app push provisioning is possible](https://docs.adyen.com/issuing/tokens-digital-wallet/in-app-push-provisioning#check-provisioning). 3. [Start the provisioning process](https://docs.adyen.com/issuing/tokens-digital-wallet/in-app-push-provisioning#start-provisioning). 4. [Show provisioning status](https://docs.adyen.com/issuing/tokens-digital-wallet/in-app-push-provisioning#show-provisioning-status). The following diagram shows the flow of data for in-app push provisioning after the cardholder selected your app's button to add their card. ![Sequence diagram for in-app push provisioning](https://docs.adyen.com/media/466f2e2cf48cb4286896ba73310502c8d73c4728951b3c08486a97cddba00cf9.svg?decoding=auto\&fetchpriority=auto) The following sections explain each step of the in-app push provisioning flow. ## 1. Create a provisioning instance Before you start the provisioning process, you must create a provisioning instance. To create the instance, you must get activation data for the specified payment instrument. The following tabs show how to do this for both iOS and Android. ### Tab: iOS 1. From your backend, make a GET [/paymentInstruments/{id}/networkTokenActivationData](https://docs.adyen.com/api-explorer/balanceplatform/latest/get/paymentInstruments/\(id\)/networkTokenActivationData) request, specifying the `id` of the payment instrument in the path. **Get activation data** #### curl ```bash curl https://balanceplatform-api-test.adyen.com/bcl/v2/paymentInstruments/PI00000000000000000000001/networkTokenActivationData \ -H 'x-api-key: ADYEN_BALANCE_PLATFORM_API_KEY' \ -H 'content-type: application/json' \ -X GET ``` #### Java ```java // Adyen Java API Library v38.0.0 to latest import com.adyen.Client; import com.adyen.Config; import com.adyen.enums.Environment; import com.adyen.model.*; import com.adyen.service.*; import java.math.*; import com.adyen.model.balanceplatform.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.service.balanceplatform.*; Config config = new Config() .apiKey("ADYEN_BALANCE_PLATFORM_API_KEY") .environment(Environment.TEST); Client client = new Client(config); // Send the request PaymentInstrumentsApi service = new PaymentInstrumentsApi(client); NetworkTokenActivationDataResponse response = service.getNetworkTokenActivationData("id", null); ``` #### PHP ```php setXApiKey("ADYEN_BALANCE_PLATFORM_API_KEY"); $client->setEnvironment(Environment::TEST); // Send the request $service = new PaymentInstrumentsApi($client); $response = $service->getNetworkTokenActivationData('id'); ``` #### C\# ```cs // Adyen .NET API Library v34.0.0 to latest using Adyen.BalancePlatform.Extensions; using Adyen.BalancePlatform.Models; using Adyen.BalancePlatform.Services; using Adyen.Core.Client; using Adyen.Core.Client.Extensions; using Adyen.Core.Options; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; var host = Host.CreateDefaultBuilder() .ConfigureBalancePlatform( (context, services, config) => { config.ConfigureAdyenOptions(options => { options.AdyenApiKey = "ADYEN_BALANCE_PLATFORM_API_KEY"; options.Environment = AdyenEnvironment.Test; }); services.AddAllBalancePlatformServices(); }) .Build(); var paymentInstrumentsService = host.Services.GetRequiredService(); // Send the request var result = await paymentInstrumentsService.GetNetworkTokenActivationDataAsync("id"); if (result.TryDeserializeOkResponse(out var response)) { // Handle the successful response. } ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v30.0.0 to latest const { Client, Config, EnvironmentEnum, BalancePlatformAPI } = require('@adyen/api-library'); const config = new Config({ apiKey: "ADYEN_BALANCE_PLATFORM_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Send the request const balancePlatformAPI = new BalancePlatformAPI(client); const response = await balancePlatformAPI.PaymentInstrumentsApi.getNetworkTokenActivationData("id"); ``` #### Go ```go // Adyen Go API Library v21.0.0 to latest import ( "context" "github.com/adyen/adyen-go-api-library/v21/src/common" "github.com/adyen/adyen-go-api-library/v21/src/adyen" ) client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_BALANCE_PLATFORM_API_KEY", Environment: common.TestEnv, }) // Send the request service := client.BalancePlatform() req := service.PaymentInstrumentsApi.GetNetworkTokenActivationDataInput("id") res, httpRes, err := service.PaymentInstrumentsApi.GetNetworkTokenActivationData(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v14.0.0 to latest import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_BALANCE_PLATFORM_API_KEY" adyen.client.platform = "test" # The environment to use library in. # Send the request result = adyen.balancePlatform.payment_instruments_api.get_network_token_activation_data(id="id") ``` #### Ruby ```rb # Adyen Ruby API Library v11.0.0 to latest require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_BALANCE_PLATFORM_API_KEY' adyen.env = :test # Set to "live" for live environment # Send the request result = adyen.balance_platform.payment_instruments_api.get_network_token_activation_data('id') ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v30.0.0 to latest import { Client, Config, EnvironmentEnum, BalancePlatformAPI, Types } from "@adyen/api-library"; const config = new Config({ apiKey: "ADYEN_BALANCE_PLATFORM_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Send the request const balancePlatformAPI = new BalancePlatformAPI(client); const response = await balancePlatformAPI.PaymentInstrumentsApi.getNetworkTokenActivationData("id"); ``` 2. Verify that the response contains the `sdkInput` object that you need to initialize the provisioning service in the next step. 3. Return the `sdkInput` to your app. 4. Create an instance of the `ProvisioningService` class, providing the `sdkInput` as a parameter. **Create provisioning instance** ```swift import AdyenApplePayProvisioning let provisioningService = try ProvisioningService(sdkInput: sdkInput) ``` ### Tab: Android 1. From your backend, make a GET [/paymentInstruments/{id}/networkTokenActivationData](https://docs.adyen.com/api-explorer/balanceplatform/latest/get/paymentInstruments/\(id\)/networkTokenActivationData) request, specifying the `id` of the payment instrument in the path. **Get activation data** #### curl ```bash curl https://balanceplatform-api-test.adyen.com/bcl/v2/paymentInstruments/PI00000000000000000000001/networkTokenActivationData \ -H 'x-api-key: ADYEN_BALANCE_PLATFORM_API_KEY' \ -H 'content-type: application/json' \ -X GET ``` #### Java ```java // Adyen Java API Library v38.0.0 to latest import com.adyen.Client; import com.adyen.Config; import com.adyen.enums.Environment; import com.adyen.model.*; import com.adyen.service.*; import java.math.*; import com.adyen.model.balanceplatform.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.service.balanceplatform.*; Config config = new Config() .apiKey("ADYEN_BALANCE_PLATFORM_API_KEY") .environment(Environment.TEST); Client client = new Client(config); // Send the request PaymentInstrumentsApi service = new PaymentInstrumentsApi(client); NetworkTokenActivationDataResponse response = service.getNetworkTokenActivationData("id", null); ``` #### PHP ```php setXApiKey("ADYEN_BALANCE_PLATFORM_API_KEY"); $client->setEnvironment(Environment::TEST); // Send the request $service = new PaymentInstrumentsApi($client); $response = $service->getNetworkTokenActivationData('id'); ``` #### C\# ```cs // Adyen .NET API Library v34.0.0 to latest using Adyen.BalancePlatform.Extensions; using Adyen.BalancePlatform.Models; using Adyen.BalancePlatform.Services; using Adyen.Core.Client; using Adyen.Core.Client.Extensions; using Adyen.Core.Options; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; var host = Host.CreateDefaultBuilder() .ConfigureBalancePlatform( (context, services, config) => { config.ConfigureAdyenOptions(options => { options.AdyenApiKey = "ADYEN_BALANCE_PLATFORM_API_KEY"; options.Environment = AdyenEnvironment.Test; }); services.AddAllBalancePlatformServices(); }) .Build(); var paymentInstrumentsService = host.Services.GetRequiredService(); // Send the request var result = await paymentInstrumentsService.GetNetworkTokenActivationDataAsync("id"); if (result.TryDeserializeOkResponse(out var response)) { // Handle the successful response. } ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v30.0.0 to latest const { Client, Config, EnvironmentEnum, BalancePlatformAPI } = require('@adyen/api-library'); const config = new Config({ apiKey: "ADYEN_BALANCE_PLATFORM_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Send the request const balancePlatformAPI = new BalancePlatformAPI(client); const response = await balancePlatformAPI.PaymentInstrumentsApi.getNetworkTokenActivationData("id"); ``` #### Go ```go // Adyen Go API Library v21.0.0 to latest import ( "context" "github.com/adyen/adyen-go-api-library/v21/src/common" "github.com/adyen/adyen-go-api-library/v21/src/adyen" ) client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_BALANCE_PLATFORM_API_KEY", Environment: common.TestEnv, }) // Send the request service := client.BalancePlatform() req := service.PaymentInstrumentsApi.GetNetworkTokenActivationDataInput("id") res, httpRes, err := service.PaymentInstrumentsApi.GetNetworkTokenActivationData(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v14.0.0 to latest import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_BALANCE_PLATFORM_API_KEY" adyen.client.platform = "test" # The environment to use library in. # Send the request result = adyen.balancePlatform.payment_instruments_api.get_network_token_activation_data(id="id") ``` #### Ruby ```rb # Adyen Ruby API Library v11.0.0 to latest require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_BALANCE_PLATFORM_API_KEY' adyen.env = :test # Set to "live" for live environment # Send the request result = adyen.balance_platform.payment_instruments_api.get_network_token_activation_data('id') ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v30.0.0 to latest import { Client, Config, EnvironmentEnum, BalancePlatformAPI, Types } from "@adyen/api-library"; const config = new Config({ apiKey: "ADYEN_BALANCE_PLATFORM_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Send the request const balancePlatformAPI = new BalancePlatformAPI(client); const response = await balancePlatformAPI.PaymentInstrumentsApi.getNetworkTokenActivationData("id"); ``` 2. Verify that the response contains the `sdkInput` object that you need to initialize the provisioning service in the next step. 3. Return the `sdkInput` to your app. 4. Call the `CardProvisioning.create()` function, providing the following parameters: * The `sdkInput` that you received from Adyen in the GET `/networkTokenActivationData` response. * The `activityProvider`, a lambda that you create to return a reference to your app's [Activity](https://developer.android.com/reference/android/app/Activity). Adyen's Android SDK uses this Activity to present the screens of the provisioning flow to the cardholder. The function returns a result object that indicates whether the call was successful or not. **Create provisioning instance** ```kotlin val result = CardProvisioning.create( sdkInput = sdkInput, activityProvider = { cardIssuingActivity }, ) ``` 5. Implement logic that handles the result object returned by the function call. **Create provisioning instance** ```kotlin val cardProvisioning = when(result) { is CardProvisioningCreateResult.Success -> result.cardProvisioning is CardProvisioningCreateResult.Failure -> handleCardProvisioningCreateFailure(result) } ``` ## 2. Check if in-app push provisioning is possible Before you try to start the provisioning process for a card, check if it is possible to add the card to a digital wallet using in-app push provisioning. The most common reasons why in-app push provisioning may not be possible are the following: * The card is already added to the cardholder's digital wallet. * A technical error occurred during the provisioning process. Adyen's iOS and Android SDKs return specific values that indicate if in-app push provisioning is possible. If it is not possible, the returned values specify the cause of the failure. The following tabs show how to check if in-app push provisioning is possible in both iOS and Android apps. ### Tab: iOS To check if the card can be added to the cardholder's Apple Wallet: 1. Call the `ProvisioningService.canAddCardDetails()` method.\ If you also want to check if the card can be added to Apple Watch: 1. Create an instance of the `WatchAvailability` class. 2. Provide the `WatchAvailability` instance as a parameter to the `ProvisioningService.canAddCardDetails()` method. The following example shows how to check if a card can be added to both iPhone and Apple Watch. **Check card eligibility** ```swift let isWatchActivated = await WatchAvailability.activate() let state = provisioningService.canAddCardDetails(isWatchActivated: isWatchActivated) ``` 2. Check the value of `ProvisioningService.canAddCardDetails.canAddCard`: * If the value is `true`, the card can be provisioned, you can add the card to all applicable devices. Show the **Add card to Apple Wallet** button in your app. * If the value is `false`, the card is already provisioned to all applicable devices. * If the value is `true`, but the card is already provisioned, the card scheme has not completed the configuration of the card. In this case, reach out to your Adyen contact. ### Tab: Android To check if the card can be added to the cardholder's Google Wallet: 1. Call the `cardProvisioning.canProvision()` function. **Call the function that checks if a card can be provisioned** ```kotlin val canProvision = cardProvisioning.canProvision() ``` 2. Implement logic that handles the result of the function call. The following table shows the possible results: | Result | Description | | -------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `CanProvisionResult.CanBeProvisioned` | The card can be provisioned to Google Wallet. Show the **Add to Google Wallet** button on your app. | | `CanProvisionResult.CannotBeProvisioned.AlreadyExistsInWallet` | The card is already provisioned in Google Wallet. Hide the **Add to Google Wallet** button on your app. | | Any other subtype of `CanProvisionResult.CannotBeProvisioned` | An error occurred while checking if the card can be provisioned. For more details about these errors, see the [Android SDK documentation](https://docs.adyen.com/payment-methods/google-pay/api-reference/#canprovisionresult). If the error persists, reach out to your Adyen contact. | **Example of how to handle the result** ```kotlin when(canProvision) { is CanProvisionResult.CanBeProvisioned -> displayGoogleWalletButton() // The card can be provisioned is CanProvisionResult.CannotBeProvisioned.AlreadyExistsInWallet -> hideGoogleWalletButton() // The card is already provisioned is CanProvisionResult.CannotBeProvisioned -> handleCanProvisionError(result) // Everything else is an error } ``` ## 3. Start the provisioning process If in-app push provisioning is possible, you can start the provisioning process using the provisioning instance that you [created](https://docs.adyen.com/issuing/tokens-digital-wallet/in-app-push-provisioning#create-provisioning-instance). The following tabs explain how to do this for both iOS and Android. ### Tab: iOS When the cardholder selects the **Add card to Apple Wallet** button, you can initiate the provisioning process. Do this as follows: 1. Implement the provisioning service delegate. When called, this delegate instructs your backend to [retrieve the network token data](https://docs.adyen.com/issuing/tokens-digital-wallet/in-app-push-provisioning#retrieve-network-token-data) from Adyen.\ The provisioning service delegate must accept the `sdkOutput` parameter. The `sdkOutput` is automatically provided by the SDK. **Provision the card** ```swift func provision(sdkOutput: Data) async -> Data? { let sdkInput = // Make a request to your backend to get the network token data return sdkInput } ``` 2. Call the `ProvisioningService.start()` function on the provisioning instance that you [created](https://docs.adyen.com/issuing/tokens-digital-wallet/in-app-push-provisioning#create-provisioning-instance). Provide the following parameters: * `delegate`: The provisioning service delegate that you implemented. Provide **self**. * `presentingViewController`: A `UIViewController` object that the SDK uses to present the screens of the provisioning flow to the cardholder. Make sure that the screens of the provisioning flow follow [Apple Pay's in-app provisioning guidelines](https://applepaydemo.apple.com/in-app-provisioning). **Initiate card provisioning** ```swift try provisioningService.start( delegate: self, presentingViewController: viewController ) ``` The function returns an `sdkOutput` object. ### Retrieve the network token data To retrieve the network token data from Adyen, use your backend to: 1. Make a POST [/paymentInstruments/{id}/networkTokenActivationData](https://docs.adyen.com/api-explorer/balanceplatform/latest/post/paymentInstruments/\(id\)/networkTokenActivationData) request and include the `sdkOutput` in the request body. **Create network token provisioning data** #### curl ```bash curl https://balanceplatform-api-test.adyen.com/bcl/v2/paymentInstruments/PI00000000000000000000001/networkTokenActivationData \ -H 'x-api-key: ADYEN_BALANCE_PLATFORM_API_KEY' \ -H 'content-type: application/json' \ -X POST \ -d '{ "sdkOutput": "YOUR_SDK_OUTPUT" }' ``` #### Java ```java // Adyen Java API Library v38.0.0 to latest import com.adyen.Client; import com.adyen.Config; import com.adyen.enums.Environment; import com.adyen.model.*; import com.adyen.service.*; import java.math.*; import com.adyen.model.balanceplatform.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.service.balanceplatform.*; Config config = new Config() .apiKey("ADYEN_BALANCE_PLATFORM_API_KEY") .environment(Environment.TEST); Client client = new Client(config); // Create the request object(s) NetworkTokenActivationDataRequest networkTokenActivationDataRequest = new NetworkTokenActivationDataRequest() .sdkOutput("YOUR_SDK_OUTPUT"); // Send the request PaymentInstrumentsApi service = new PaymentInstrumentsApi(client); NetworkTokenActivationDataResponse response = service.createNetworkTokenProvisioningData("id", networkTokenActivationDataRequest, null); ``` #### PHP ```php setXApiKey("ADYEN_BALANCE_PLATFORM_API_KEY"); $client->setEnvironment(Environment::TEST); // Create the request object(s) $networkTokenActivationDataRequest = new NetworkTokenActivationDataRequest(); $networkTokenActivationDataRequest ->setSdkOutput("YOUR_SDK_OUTPUT"); // Send the request $service = new PaymentInstrumentsApi($client); $response = $service->createNetworkTokenProvisioningData('id', $networkTokenActivationDataRequest); ``` #### C\# ```cs // Adyen .NET API Library v34.0.0 to latest using Adyen.BalancePlatform.Extensions; using Adyen.BalancePlatform.Models; using Adyen.BalancePlatform.Services; using Adyen.Core.Client; using Adyen.Core.Client.Extensions; using Adyen.Core.Options; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; var host = Host.CreateDefaultBuilder() .ConfigureBalancePlatform( (context, services, config) => { config.ConfigureAdyenOptions(options => { options.AdyenApiKey = "ADYEN_BALANCE_PLATFORM_API_KEY"; options.Environment = AdyenEnvironment.Test; }); services.AddAllBalancePlatformServices(); }) .Build(); var paymentInstrumentsService = host.Services.GetRequiredService(); // Create the request object(s) var networkTokenActivationDataRequest = new NetworkTokenActivationDataRequest { SdkOutput = "YOUR_SDK_OUTPUT" }; // Send the request var result = await paymentInstrumentsService.CreateNetworkTokenProvisioningDataAsync("id", networkTokenActivationDataRequest); if (result.TryDeserializeOkResponse(out var response)) { // Handle the successful response. } ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v30.0.0 to latest const { Client, Config, EnvironmentEnum, BalancePlatformAPI } = require('@adyen/api-library'); const config = new Config({ apiKey: "ADYEN_BALANCE_PLATFORM_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Create the request object(s) const networkTokenActivationDataRequest = { sdkOutput: "YOUR_SDK_OUTPUT" }; // Send the request const balancePlatformAPI = new BalancePlatformAPI(client); const response = await balancePlatformAPI.PaymentInstrumentsApi.createNetworkTokenProvisioningData("id", networkTokenActivationDataRequest); ``` #### Go ```go // Adyen Go API Library v21.0.0 to latest import ( "context" "github.com/adyen/adyen-go-api-library/v21/src/common" "github.com/adyen/adyen-go-api-library/v21/src/adyen" "github.com/adyen/adyen-go-api-library/v21/src/balanceplatform" ) client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_BALANCE_PLATFORM_API_KEY", Environment: common.TestEnv, }) // Create the request object(s) networkTokenActivationDataRequest := balanceplatform.NetworkTokenActivationDataRequest{ SdkOutput: common.PtrString("YOUR_SDK_OUTPUT"), } // Send the request service := client.BalancePlatform() req := service.PaymentInstrumentsApi.CreateNetworkTokenProvisioningDataInput("id").NetworkTokenActivationDataRequest(networkTokenActivationDataRequest) res, httpRes, err := service.PaymentInstrumentsApi.CreateNetworkTokenProvisioningData(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v14.0.0 to latest import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_BALANCE_PLATFORM_API_KEY" adyen.client.platform = "test" # The environment to use library in. # Create the request object(s) json_request = { "sdkOutput": "YOUR_SDK_OUTPUT" } # Send the request result = adyen.balancePlatform.payment_instruments_api.create_network_token_provisioning_data(request=json_request, id="id") ``` #### Ruby ```rb # Adyen Ruby API Library v11.0.0 to latest require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_BALANCE_PLATFORM_API_KEY' adyen.env = :test # Set to "live" for live environment # Create the request object(s) request_body = { "sdkOutput" => "YOUR_SDK_OUTPUT" } # Send the request result = adyen.balance_platform.payment_instruments_api.create_network_token_provisioning_data(request_body, 'id') ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v30.0.0 to latest import { Client, Config, EnvironmentEnum, BalancePlatformAPI, Types } from "@adyen/api-library"; const config = new Config({ apiKey: "ADYEN_BALANCE_PLATFORM_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Create the request object(s) const networkTokenActivationDataRequest: Types.balancePlatform.NetworkTokenActivationDataRequest = { sdkOutput: "YOUR_SDK_OUTPUT" }; // Send the request const balancePlatformAPI = new BalancePlatformAPI(client); const response = await balancePlatformAPI.PaymentInstrumentsApi.createNetworkTokenProvisioningData("id", networkTokenActivationDataRequest); ``` 2. Verify that the response contains an `sdkInput`. This `sdkInput` is a block of data that contains the encrypted network token data. 3. Return the `sdkInput` to the SDK. ### Tab: Android When the cardholder selects the **Add to Google Wallet** button, you can initiate the provisioning process. Do this as follows: 1. Implement a provider interface for [Opaque Payment Card](https://developers.google.com/pay/issuers/apis/push-provisioning/android/push-provisioning-google-opc) (OPC) data. When called, this OPC provider instructs your backend to [retrieve the OPC data](https://docs.adyen.com/issuing/tokens-digital-wallet/in-app-push-provisioning#retrieve-opc-data) from Adyen.\ The OPC provider must accept the following parameters: * `paymentInstrumentId`: The payment instrument ID of the card that you want to provision. * `sdkOutput`: An encoded block of data provided automatically by the SDK. **Create an OPC provider** ```kotlin val opcProvider = OpcProvider { paymentInstrumentId, sdkOutput -> // Make a request to your backend to get the OPC // Return the OPC string from the response return@OpcProvider sdkInput } ``` 2. Call the `CardProvisioning.provision()` method on the provisioning instance that you [created](https://docs.adyen.com/issuing/tokens-digital-wallet/in-app-push-provisioning#create-provisioning-instance). Provide the following parameters: * `cardDisplayName`: A string with the cardholder name to show in Google Wallet. Your app must provide this information. * `cardAddress`: The cardholder address. Your app must provide this information. If you leave this field empty, Google Wallet prompts the cardholder to enter their address. * `opcProvider`: The OPC provider that you implemented. **Provision the card** ```kotlin val result = cardProvisioning.provision( cardDisplayName = "John Doe", cardAddress = CardAddress(), opcProvider = opcProvider ) ``` ### Retrieve the Opaque Payment Card (OPC) data To retrieve the OPC data from Adyen, use your backend to: 1. Make a POST [/paymentInstruments/{id}/networkTokenActivationData](https://docs.adyen.com/api-explorer/balanceplatform/latest/post/paymentInstruments/\(id\)/networkTokenActivationData) request. Specify the `paymentInstrumentId` in the path and `sdkOutput` in the request body. **Create network token provisioning data** #### curl ```bash curl https://balanceplatform-api-test.adyen.com/bcl/v2/paymentInstruments/PI00000000000000000000001/networkTokenActivationData \ -H 'x-api-key: ADYEN_BALANCE_PLATFORM_API_KEY' \ -H 'content-type: application/json' \ -X POST \ -d '{ "sdkOutput": "YOUR_SDK_OUTPUT" }' ``` #### Java ```java // Adyen Java API Library v38.0.0 to latest import com.adyen.Client; import com.adyen.Config; import com.adyen.enums.Environment; import com.adyen.model.*; import com.adyen.service.*; import java.math.*; import com.adyen.model.balanceplatform.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.service.balanceplatform.*; Config config = new Config() .apiKey("ADYEN_BALANCE_PLATFORM_API_KEY") .environment(Environment.TEST); Client client = new Client(config); // Create the request object(s) NetworkTokenActivationDataRequest networkTokenActivationDataRequest = new NetworkTokenActivationDataRequest() .sdkOutput("YOUR_SDK_OUTPUT"); // Send the request PaymentInstrumentsApi service = new PaymentInstrumentsApi(client); NetworkTokenActivationDataResponse response = service.createNetworkTokenProvisioningData("id", networkTokenActivationDataRequest, null); ``` #### PHP ```php setXApiKey("ADYEN_BALANCE_PLATFORM_API_KEY"); $client->setEnvironment(Environment::TEST); // Create the request object(s) $networkTokenActivationDataRequest = new NetworkTokenActivationDataRequest(); $networkTokenActivationDataRequest ->setSdkOutput("YOUR_SDK_OUTPUT"); // Send the request $service = new PaymentInstrumentsApi($client); $response = $service->createNetworkTokenProvisioningData('id', $networkTokenActivationDataRequest); ``` #### C\# ```cs // Adyen .NET API Library v34.0.0 to latest using Adyen.BalancePlatform.Extensions; using Adyen.BalancePlatform.Models; using Adyen.BalancePlatform.Services; using Adyen.Core.Client; using Adyen.Core.Client.Extensions; using Adyen.Core.Options; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; var host = Host.CreateDefaultBuilder() .ConfigureBalancePlatform( (context, services, config) => { config.ConfigureAdyenOptions(options => { options.AdyenApiKey = "ADYEN_BALANCE_PLATFORM_API_KEY"; options.Environment = AdyenEnvironment.Test; }); services.AddAllBalancePlatformServices(); }) .Build(); var paymentInstrumentsService = host.Services.GetRequiredService(); // Create the request object(s) var networkTokenActivationDataRequest = new NetworkTokenActivationDataRequest { SdkOutput = "YOUR_SDK_OUTPUT" }; // Send the request var result = await paymentInstrumentsService.CreateNetworkTokenProvisioningDataAsync("id", networkTokenActivationDataRequest); if (result.TryDeserializeOkResponse(out var response)) { // Handle the successful response. } ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v30.0.0 to latest const { Client, Config, EnvironmentEnum, BalancePlatformAPI } = require('@adyen/api-library'); const config = new Config({ apiKey: "ADYEN_BALANCE_PLATFORM_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Create the request object(s) const networkTokenActivationDataRequest = { sdkOutput: "YOUR_SDK_OUTPUT" }; // Send the request const balancePlatformAPI = new BalancePlatformAPI(client); const response = await balancePlatformAPI.PaymentInstrumentsApi.createNetworkTokenProvisioningData("id", networkTokenActivationDataRequest); ``` #### Go ```go // Adyen Go API Library v21.0.0 to latest import ( "context" "github.com/adyen/adyen-go-api-library/v21/src/common" "github.com/adyen/adyen-go-api-library/v21/src/adyen" "github.com/adyen/adyen-go-api-library/v21/src/balanceplatform" ) client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_BALANCE_PLATFORM_API_KEY", Environment: common.TestEnv, }) // Create the request object(s) networkTokenActivationDataRequest := balanceplatform.NetworkTokenActivationDataRequest{ SdkOutput: common.PtrString("YOUR_SDK_OUTPUT"), } // Send the request service := client.BalancePlatform() req := service.PaymentInstrumentsApi.CreateNetworkTokenProvisioningDataInput("id").NetworkTokenActivationDataRequest(networkTokenActivationDataRequest) res, httpRes, err := service.PaymentInstrumentsApi.CreateNetworkTokenProvisioningData(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v14.0.0 to latest import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_BALANCE_PLATFORM_API_KEY" adyen.client.platform = "test" # The environment to use library in. # Create the request object(s) json_request = { "sdkOutput": "YOUR_SDK_OUTPUT" } # Send the request result = adyen.balancePlatform.payment_instruments_api.create_network_token_provisioning_data(request=json_request, id="id") ``` #### Ruby ```rb # Adyen Ruby API Library v11.0.0 to latest require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_BALANCE_PLATFORM_API_KEY' adyen.env = :test # Set to "live" for live environment # Create the request object(s) request_body = { "sdkOutput" => "YOUR_SDK_OUTPUT" } # Send the request result = adyen.balance_platform.payment_instruments_api.create_network_token_provisioning_data(request_body, 'id') ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v30.0.0 to latest import { Client, Config, EnvironmentEnum, BalancePlatformAPI, Types } from "@adyen/api-library"; const config = new Config({ apiKey: "ADYEN_BALANCE_PLATFORM_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Create the request object(s) const networkTokenActivationDataRequest: Types.balancePlatform.NetworkTokenActivationDataRequest = { sdkOutput: "YOUR_SDK_OUTPUT" }; // Send the request const balancePlatformAPI = new BalancePlatformAPI(client); const response = await balancePlatformAPI.PaymentInstrumentsApi.createNetworkTokenProvisioningData("id", networkTokenActivationDataRequest); ``` 2. Verify that the response contains an `sdkInput`. This `sdkInput` is the OPC data block. 3. Return the `sdkInput` to the SDK. ## 4. Show provisioning status After the provisioning process is complete, you can update your UI to reflect the result. The following tabs explain how to do this for both iOS and Android. ### Tab: iOS To reflect the result of the provisioning process in your UI: * Write the body of the `didFinishProvisioning` method to implement logic that handles the result of the provisioning process. This logic must update your UI and show **Added to Apple Wallet** or **Available in Apple Wallet**.\ The method receives the following parameters: * `pass`: The payment pass that represents the provisioned card. * `error`: An error object that contains information about why provisioning failed, if it did. **Example definition of the didFinishProvisioning method** ```swift func didFinishProvisioning(with pass: PKPaymentPass?, error: Error?) { // Update your UI } ``` The SDK automatically calls the `didFinishProvisioning` method and provides the `PKPaymentPass` and `Error` objects as parameters. ### Tab: Android After the Google Wallet provisioning flow finishes, the `cardProvisioning.provision()` function returns a `ProvisionResult` object. To update your UI to reflect the result: 1. Implement logic to handle the `ProvisionResult` object. **Example logic for handling the ProvisionResult object** ```kotlin when (result) { is ProvisionResult.Success -> handleProvisionSuccess(result) is ProvisionResult.Failure -> handleProvisionFailure(result) } ``` 2. If the result is `ProvisionResult.Success`, update your UI to show that the card has been successfully added to Google Wallet. ## Next steps [required](https://docs.adyen.com/issuing/tokens-digital-wallets/wallet-provisioning) [Pull provisioning from Apple Wallet](https://docs.adyen.com/issuing/tokens-digital-wallets/wallet-provisioning) [Learn how to allow your cardholders to add their Adyen-issued card to Apple Wallet from the Apple Wallet app.](https://docs.adyen.com/issuing/tokens-digital-wallets/wallet-provisioning) [required](https://docs.adyen.com/issuing/manage-network-tokens) [Manage network tokens](https://docs.adyen.com/issuing/manage-network-tokens) [Learn how to manage network tokens for cards added to digital wallets.](https://docs.adyen.com/issuing/manage-network-tokens)