> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentcard.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Agentcard is for companies whose agent buys for their users. Pick one path: the opencommerce SDK (@agent-cards/commerce-sdk) gives your agent one buy tool that finds the product, builds the cart, gets the user's approval and places the order at real stores; the Agentcard SDK (@agent-cards/sdk) pays with the user's own card when your agent already shops in a browser (Browser Use, Kernel, Browserbase, Anchor or Notte); the Purchase API (POST /buy) does the same purchase flow over plain HTTP in any language; Issuing gives the agent its own card.
> Start with `npx agent-cards init` in the app's folder (Node 22 or later). No invite is needed: it creates your Agentcard account if you don't have one, installs the opencommerce SDK and puts the credentials in the env file, kept out of git. From a coding agent, run `npx agent-cards init --print --categories all --implementation tool --wallet vault --skip-install` to get the setup steps to apply yourself.
> Vault is by invitation: request it at https://agentcard.com/get-started?utm_source=docs&utm_medium=llms&utm_campaign=agent-instructions. opencommerce needs no invite.
> Never ask a user for a card number, expiry date or CVV in chat. Send them the Vault link; they add their card on Agentcard's page, and the agent never sees the number.
> Every purchase is approved by the user, with a passkey or Face ID, or by an auto-approval they granted. An approval covers one merchant and one exact total. If the total changes, ask again. When a result says the user already said yes, don't ask again.
> `init` writes PRODUCTION credentials, which place real orders, so test in sandbox first. For opencommerce, run `npx agent-cards credentials --mode sandbox` and put the two lines it prints in place of the production ones in the env file `init` wrote, because that command only prints them; sandbox then runs the whole flow against real stores and stops before payment, so no order is placed and nobody is charged. For Vault and Issuing, sandbox credentials issue test cards that no real merchant accepts; try the checkout against shop.agentcard.sh, a test store on Stripe test mode.
> Tell the user an order is placed only after Agentcard reports it placed.
> Vault is free up to 5,000 users (https://agentcard.com/pricing). opencommerce takes 1% of each completed order. Full docs in one file: https://docs.agentcard.com/llms-full.txt

# Add a card to Apple Pay or Google Pay

> Let your users add the card you issued them to Apple Pay or Google Pay with one tap in your app.

Let your users add their card to Apple Pay or Google Pay with one tap inside your app. Your app opens the phone's add-card screen, your server asks Agentcard for the card's encrypted wallet data, and your app hands that data to the wallet. Your server and your app never hold the card number.

> [!WARNING]
>
> One tap is not live yet. Every call on this page answers `wallet_provisioning_not_enabled` today, because phone wallets are not switched on for Agentcard cards yet. Your users can add their card to Apple Pay or Google Pay now by typing it into the Wallet app by hand, which works and needs nothing from you. Talk to us before you build against the shapes below: the finished integration runs partly through a wallet library inside your own app, so some of these fields will change.

## Check what you need

Three things have to be true before a card reaches a phone:

| What | Why |
| - | - |
| The card is a multi-use card and is open | A single-use card closes after its first charge, so it would sit in the wallet unable to pay. |
| Your iOS app holds Apple's in-app provisioning entitlement | Apple's add-card screen does not open in an app without it. Agentcard asks Apple for it on your behalf. |
| Your Android app is approved for Google Pay push provisioning | Google gives the add-card library only to approved apps. Agentcard confirms your app to Google. |

Always call Agentcard from your server, with your company access token. Your app never holds that token: it asks your server, and your server asks Agentcard.

## Add a card to Apple Pay

Show Apple's "Add to Apple Wallet" button only when the phone can add cards and this card is not in Wallet yet. When your user taps it, open Apple's add-card screen (`PKAddPaymentPassViewController`) with the card's last four digits and the cardholder's name.

Apple then hands your app three values: a list of certificates, a nonce and a nonce signature. Encode each one in base64, send them to your server, and have your server ask Agentcard right away, because the nonce expires within a few minutes:

```bash theme={null}
curl -X POST https://api.agentcard.sh/api/v2/cards/card_22943fc47c3865e20527c7a5/wallet_provisioning \
  -H "Authorization: Bearer $ORG_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "wallet": "apple_pay",
    "device_id": "install-6f1c2a",
    "certificates": ["MIIEnzCCBEWgAwIB...", "MIIDBjCCAqygAwIB..."],
    "nonce": "3q2+7w==",
    "nonce_signature": "MEUCIQDx..."
  }'
```

```json theme={null}
{
  "object": "wallet_provisioning",
  "card_id": "card_22943fc47c3865e20527c7a5",
  "wallet": "apple_pay",
  "activation_data": "TUFDQUNUSVZB...",
  "encrypted_pass_data": "eyJlbmNyeXB0ZWRE...",
  "ephemeral_public_key": "BEc6Hc2nBvRk..."
}
```

`device_id` is an id your app keeps for the phone the card goes to. Pass the three answer fields back to your app, decode them from base64, and give them to Apple in a `PKAddPaymentPassRequest`. Apple shows your user its terms, adds the card, and tells your app when the card is in Wallet.

If your server cannot get the data, give Apple an empty request. Apple then tells your user the card could not be added, and your user can try again.

## Add a card to Google Pay

Show Google's "Add to Google Pay" button only when the card is not in your user's Google Wallet yet. Send an id your app keeps for the phone to your server, and have your server ask Agentcard:

```bash theme={null}
curl -X POST https://api.agentcard.sh/api/v2/cards/card_22943fc47c3865e20527c7a5/wallet_provisioning \
  -H "Authorization: Bearer $ORG_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "wallet": "google_pay", "device_id": "wallet-9d2c47e1" }'
```

```json theme={null}
{
  "object": "wallet_provisioning",
  "card_id": "card_22943fc47c3865e20527c7a5",
  "wallet": "google_pay",
  "opaque_payment_card": "eyJjYXJkSW5mbyI6...",
  "network": "visa",
  "token_service_provider": "visa",
  "last4": "6803"
}
```

Pass the answer to your app. Build Google's push request with `opaque_payment_card` decoded from base64, the network and token service set to Visa, and `last4`, then call `pushTokenize`. Google shows your user its terms and adds the card.

## Pay with the card in the wallet

A payment from Apple Pay or Google Pay is a charge on the same card. The card's limit, its merchant rules and its pause all apply, and every charge reaches your server as a webhook, as it does for a card your agent types in. Pause the card, and the card network declines payments from the wallet too.

## Handle a refusal

Agentcard refuses a card that cannot go in a wallet before anything reaches the phone. A single-use card answers:

```json theme={null}
{
  "error": {
    "code": "card_not_reusable",
    "message": "Only a multi-use card can go in a phone wallet. A single-use card closes after its first charge."
  }
}
```

| Code | What it means | What to do |
| - | - | - |
| `card_not_reusable` | The card is single-use. | Issue a multi-use card with `"type": "multi_use"`. |
| `card_not_open` | The card is paused, closed or still being created. | Resume the card, or wait until its status reads `open`. |
| `wallet_provisioning_unavailable` | The card is a test-mode card, or it was made from a card the user added. | Use a live card your company issued. |
| `wallet_provisioning_not_enabled` | The card network has not enabled phone wallets for your cards yet, which is true of every card today. | Have your user add the card to the wallet by hand, and ask us where the one tap flow stands. |
| `wallet_provisioning_failed` | The card network did not return the wallet data. | Open the add-card screen again and retry. |
| `invalid_request` | A field is missing or is not base64. | Send the fields shown above for your wallet. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.