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

# Browser Pay

> Use a wallet payment credential on a merchant website, then report the actual payment result.

Browser Pay lets an Agent complete a merchant website's card checkout using a payment credential issued by Clink. The merchant does not need to be registered with Clink in advance. The Agent operates the merchant website; Clink handles the wallet, purchase authorization, and credential issuance.

Before starting, connect to MCP and read its current business rules. The user must have authorized the purchase and its budget range, and the following conditions must be met:

* **Payment card.** The current wallet response's `agent_pay_support` indicates whether the card supports Agent Pay. The merchant or issuer may still decline this payment.
* **Merchant checkout page.** The Agent can read the final total, fill the card form including embedded payment fields, submit payment, and view the merchant's payment or order result.
* **User verification.** The user can complete any verification the bank requires, such as 3-D Secure or a one-time code.

A platform that receives encrypted credentials also needs to implement [credential decryption](https://docs.clinkbill.com/guides/agent/browser_pay/decryption.md).

> [tab] Main payment flow
>
> When a valid purchase authorization covers this payment, `get_credential` can return the credential directly. Use `credential.card` as provided; decrypt only when the response contains `key` and `payload`.
>
> ```mermaid theme={null}
> %%{init: {"theme":"base","themeVariables":{"fontFamily":"inherit","actorBkg":"#F7F7F7","actorBorder":"#E7E7E7","actorTextColor":"#161616","actorLineColor":"#E7E7E7","signalColor":"#71717A","signalTextColor":"#3F3F46","noteBkgColor":"#F8E1CC","noteBorderColor":"#F8E1CC","noteTextColor":"#161616"},"sequence":{"width":116,"height":44,"actorMargin":64,"diagramMarginX":12,"diagramMarginY":12,"messageMargin":28,"noteMargin":14,"boxMargin":12,"wrap":false,"mirrorActors":false,"actorFontSize":14,"messageFontSize":14,"noteFontSize":14}}}%%
> sequenceDiagram
>   participant M as Merchant website
>   participant A as Agent / platform
>   participant C as Clink MCP
>   A->>M: Read checkout total
>   M-->>A: Amount and currency
>   A->>C: get_credential
>   C-->>A: Credential and payment IDs
>   Note over A: Decrypt encrypted credential if needed
>   A->>M: Recheck amount, fill card, and submit
>   M-->>A: Payment result
>   A->>C: confirm_result
>   C-->>A: Report recorded
> ```

> [tab] When user action is required
>
> If `get_credential` returns a `REDIRECT_USER` link, complete the following flow first, then return to the main payment flow to use the credential.
>
> ```mermaid theme={null}
> %%{init: {"theme":"base","themeVariables":{"fontFamily":"inherit","actorBkg":"#F7F7F7","actorBorder":"#E7E7E7","actorTextColor":"#161616","actorLineColor":"#E7E7E7","signalColor":"#71717A","signalTextColor":"#3F3F46","noteBkgColor":"#F8E1CC","noteBorderColor":"#F8E1CC","noteTextColor":"#161616"},"sequence":{"width":116,"height":44,"actorMargin":64,"diagramMarginX":12,"diagramMarginY":12,"messageMargin":28,"noteMargin":14,"boxMargin":12,"wrap":false,"mirrorActors":false,"actorFontSize":14,"messageFontSize":14,"noteFontSize":14}}}%%
> sequenceDiagram
>   participant U as User
>   participant A as Agent / platform
>   participant C as Clink MCP
>   C-->>A: REDIRECT_USER
>   A-->>U: Show user action link
>   U->>C: Complete card setup or authorization
>   A->>C: get_operation
>   C-->>A: Setup complete
>   A->>C: get_credential
>   C-->>A: Credential and payment IDs
> ```
>
> Wait for the returned setup Operation to complete, then call `get_credential` again with the same checkout facts and keep the selected `paymentInstrumentId`, if any. Do not pass the setup operation ID. Other `SETUP_REQUIRED` cases are described in step 2.

The diagrams show the successful path. If the card was not submitted, report `NOT_SUBMITTED`; if it was submitted but the result cannot be confirmed, report `UNKNOWN`.

## 1. Read the final checkout amount

Use the final total shown on the merchant checkout page, including shipping and tax. Do not use the product list price, and do not treat the user's maximum budget as the payment amount. Obtain contact and delivery details from the user or their merchant account.

Select the website's card payment option and disable any option to save payment details. If the user named a specific wallet card, obtain its `paymentInstrumentId` from a fresh `get_account_state` response and check `agent_pay_support: true`. Otherwise, omit the card selector to use the default card.

## 2. Get the payment credential

The following is a `tools/call` request. For a checkout total of USD 12.50, send `amount: 1250`:

```json theme={null}
{
  "name": "get_credential",
  "arguments": {
    "merchantUrl": "https://shop.example.com/checkout",
    "merchantName": "Example Store",
    "amount": 1250,
    "currency": "USD"
  }
}
```

Required scopes are `wallet:read`, `payment:execute`, `instruction:read`, and `instruction:write`.

Clink checks the payment card and matches an active purchase authorization. If an existing authorization covers this payment, the call can return the credential immediately. Otherwise, it can start a one-time authorization for the current checkout. You do not need to list or create purchase authorizations before every Browser Pay call.

Handle the actual response:

| Response | Next step |
| :- | :- |
| Contains `credential` | Continue to step 3. |
| `REDIRECT_USER` / `PASSKEY` | Give the user `next_action.params.redirect_url` to authorize this payment. |
| `REDIRECT_USER` / `PAYMENT_METHOD_SETUP` | Give the user the returned link to add or choose a card and authorize this payment. |
| `SETUP_REQUIRED` / `DEFAULT_CARD` | Show the card brand and last four digits from `wallet_cards`. Let the user choose a card for this checkout only, or change the default card. |
| `SETUP_REQUIRED` / `PURCHASE_INSTRUCTION` | Complete the [purchase authorization setup](https://docs.clinkbill.com/guides/agent/wallet_service.md) for the returned card and amount, then get the credential. |

Read the action details from the structured response instead of inferring them from the label:

* `next_action.type` is the action category (`REDIRECT_USER` or `SETUP_REQUIRED`).
* `next_action.params.redirect_kind` explains the reason for a redirect, such as `PASSKEY` or `PAYMENT_METHOD_SETUP`.
* `next_action.params.setup_kind` explains the reason for setup, such as `DEFAULT_CARD` or `PURCHASE_INSTRUCTION`.
* `next_action.params.resumable` tells you whether the original checkout request can be retried after setup. Preserve the original checkout facts either way.
* `next_action.params.actor` identifies who opens the link. Treat `USER_DEVICE_ONLY` as a user-device action.

When a redirect returns `actor: "USER_DEVICE_ONLY"`, the user opens the link on their own device. The Agent must not open or preview it in its own browser. After presenting a Passkey or card setup link, wait for the same setup Operation:

```json theme={null}
{
  "name": "get_operation",
  "arguments": {
    "operationId": "<setup operation_id>",
    "maxWaitSeconds": 60
  }
}
```

Recovery normally needs the business scope plus `events:read events:consume`; also request `offline_access` when the platform needs a Refresh Token. Clink configures each platform's scopes according to its enabled capabilities. See [How to integrate MCP](https://docs.clinkbill.com/guides/agent/platform_integration/mcp_integration.md#scopes).

Once setup is complete, call `get_credential` again with the checkout facts. Do not pass the setup `operationId`. If the user selected a card for this checkout, keep the same `paymentInstrumentId` on every call. If the user chose to change the default card, call `set_default_card` first, then retry without the card selector.

Opening a link does not mean authorization is complete. If the response still requires action, follow the current `next_action`.

## 3. Read or decrypt the credential

Handle the actual returned shape rather than assuming every client receives the same result:

| Shape | How to use it |
| :- | :- |
| `credential.card` | Card details are provided directly. Use this object; no decryption is required. |
| `credential.key` and `credential.payload` | Preserve both strings exactly and decrypt them using the [credential decryption example](https://docs.clinkbill.com/guides/agent/browser_pay/decryption.md). |

Cloud platforms configure their public key by contacting Clink offline. See [Register an RSA public key](https://docs.clinkbill.com/guides/agent/platform_credentials.md#rsa-public-key).

### How payment credentials are protected

![Visa](https://mintcdn.com/clink/WOHh_9VfSF-k-jkf/images/partners/visa-blue.png?fit=max\&auto=format\&n=WOHh_9VfSF-k-jkf\&q=85\&s=dd416e18fa3d7f11748b4b2d9282ee53)

The current Visa flow uses a tokenized card number and a dynamic security code to fill the merchant's card form. The tokenized number replaces the user's original card number, and the dynamic security code has an expiry. Use the returned credential and its expiry information to complete this checkout.

When a platform receives `key` and `payload`, the credential is additionally encrypted with the platform's public key. Decrypt it with the matching private key to read the card fields. This layer protects credential delivery; the [purchase authorization confirmed with a Passkey](https://docs.clinkbill.com/guides/agent/wallet_service.md#passkeys-and-purchase-authorization) determines the purchase scope. A response that returns `credential.card` directly is also subject to the authorization scope and credential expiry.

### Keep payment identifiers

Keep these identifiers for reporting the result:

| `confirm_result` argument | Source |
| :- | :- |
| `operationId` | `operation_id` from the `get_credential` response that issued this card credential; also corresponds to `clientReferenceId` in the credential payload |
| `orderId` | Payload `orderId`, or `resources.payment_order_id` |
| `paymentExecutionDetailId` | Payload `paymentExecutionDetailId`, or `resources.payment_execution_detail_id` |

`orderId` identifies Clink's payment order; it is not the merchant's order number. If the merchant returns an order number, keep that merchant order number separately.

> [!NOTE]
>
> A `get_credential` Operation with `status: "SUCCEEDED"` means the credential was issued. It does not mean the merchant has been paid. `get_operation` never returns the credential and cannot independently verify the merchant's payment result.

`get_credential.amount` and `confirm_result.paidAmount` use minor currency units; the credential payload's `amount` uses major currency units. For example, USD 12.50 is `1250` and `12.50` respectively. Convert according to the currency's precision; do not multiply every currency by 100.

## 4. Fill and submit the merchant payment

Fill the returned card number, expiry, and security code into the card fields on the current checkout page, including payment provider fields embedded in the page. Use the expiry format the form requires. Use the returned `cardholderName` and `billingAddress` when present; if billing information is missing, ask the user for it instead of inventing it.

Use the credential within its validity period. The decrypted expiry information and `ttlMinutes`, when present, take precedence over the estimate in the outer `credential.expires_at`.

Recheck the total before submitting:

* Total unchanged: submit and check the merchant's result. If 3-D Secure or a one-time code is required, the user completes it.
* Total changed: do not submit the old credential. Report `NOT_SUBMITTED` with `failureReason: "AMOUNT_CHANGED"`, then get a credential for the new total within the user's authorization.

Use card details only in this checkout's payment fields. Do not write them to chat, logs, or saved notes. Use `credential.display` to describe the card to the user.

## 5. Report the observed result

Call `confirm_result` to report this Browser Pay payment using the identifiers kept in step 3. The following example reports an observed successful payment:

```json theme={null}
{
  "name": "confirm_result",
  "arguments": {
    "orderId": "<issued orderId>",
    "paymentExecutionDetailId": "<issued paymentExecutionDetailId>",
    "operationId": "<issuing operation_id>",
    "outcome": "SUCCEEDED",
    "paidAmount": 1250,
    "currency": "USD"
  }
}
```

| Outcome | Use when |
| :- | :- |
| `SUCCEEDED` | The merchant page explicitly confirmed that payment succeeded. |
| `FAILED` | After submission, the merchant explicitly showed a payment failure. |
| `NOT_SUBMITTED` | The card was not submitted, for example because the total changed, decryption failed, or the user cancelled. This outcome does not require clicking Pay first. |
| `UNKNOWN` | The card was submitted, but the result could not be determined. |

When the success page shows the actual paid amount, supply both `paidAmount` and `currency`. `failureReason` applies only to `FAILED` and `NOT_SUBMITTED`. See the [full parameter reference](https://docs.clinkbill.com/api-reference/mcp/browser_pay.md#confirm_result).

For `UNKNOWN`, keep the payment identifiers and check the merchant's existing order or payment result. Do not pay again. Report the final result before the returned `report_deadline`. Repeating the same outcome is safe; a conflicting final outcome is refused.

Clink records the Agent's report and returns an `agent_reported_result` message. This record is not independent confirmation from the merchant. Refunds for this flow are handled by the merchant.

Give the user a brief result based on what the merchant page actually shows. For example, when the page confirms the following details:

> Example Store confirmed payment of USD 12.50. Merchant order number: EX-1042.

If the page does not show a merchant order number, omit it. Do not invent one or substitute Clink's `orderId`.

## Recovery without a duplicate purchase

| Situation | Recovery |
| :- | :- |
| The credential request timed out, returned `issuance_incomplete`, or its response was lost before submission | Retry `get_credential` with the same checkout facts and selected card. Before the final result is reported, Clink reuses the outstanding credential and does not create another purchase. |
| The credential expired before submission | Repeat the same request to get a new credential for the same order. If `credential_unavailable` is returned, use the known identifiers to report `NOT_SUBMITTED` with `CREDENTIAL_EXPIRED`. |
| Decryption failed | Do not submit. Report `NOT_SUBMITTED`, using the identifiers in `resources` if available. If the identifiers are unavailable, read the issuing Operation and resolve the integration problem; do not invent IDs or start a new payment. |
| Result reporting failed or returned `result_reporting_unavailable` | Retry `confirm_result` with the same arguments. Do not pay again. |
| A final result was already reported | This purchase is finished. A later `get_credential` call with the same facts starts a new purchase, so call it only when the user authorizes a new purchase. |

`confirm_result` is used only for Browser Pay. UCP Checkout and direct payments obtain their results through their own tools and must not be reported through this endpoint.

## Code examples

The following examples show only how to request a credential and report the merchant result. Your browser executor still opens the merchant page, reads the final amount, fills the card fields, and submits payment. Do not write the card number, expiry, or security code to logs, model context, or persistent storage.

> [tab] MCP
>
> Call `get_credential` through your MCP Client. `amount` uses minor currency units; for USD 12.50, send `1250`.
>
> ```json theme={null}
> {
>   "method": "tools/call",
>   "params": {
>     "name": "get_credential",
>     "arguments": {
>       "merchantUrl": "https://shop.example.com/checkout",
>       "merchantName": "Example Store",
>       "merchantCountryCode": "US",
>       "amount": 1250,
>       "currency": "USD"
>     }
>   }
> }
> ```
>
> After reading the final result on the merchant page, call `confirm_result` with the identifiers returned by the same `get_credential` call:
>
> ```json theme={null}
> {
>   "method": "tools/call",
>   "params": {
>     "name": "confirm_result",
>     "arguments": {
>       "orderId": "<issued orderId>",
>       "paymentExecutionDetailId": "<issued paymentExecutionDetailId>",
>       "operationId": "<issuing operation_id>",
>       "outcome": "SUCCEEDED",
>       "paidAmount": 1250,
>       "currency": "USD"
>     }
>   }
> }
> ```
>
> If the response contains `credential.key` and `credential.payload`, decrypt them in a trusted platform component first, then pass the card fields to a controlled browser-filling component. Do not pass the decrypted result back to the model.

> [tab] RESTful API
>
> The RESTful API uses a Portal Token, and `amount` is a decimal string in major currency units; for USD 12.50, send `"12.50"`. The example assumes the platform has already created and activated an `instruction_id` and `mandate_id` that cover this purchase.
>
> ```bash theme={null}
> curl -X POST "$API_BASE_URL/agent/platform/credential" \
>   -H "Authorization: Bearer $PORTAL_USER_TOKEN" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "instruction_id": "inst_...",
>     "mandate_id": "mand_...",
>     "client_reference_id": "platform-ref-001",
>     "amount": "12.50",
>     "currency_code": "USD",
>     "merchant_url": "https://shop.example.com/checkout",
>     "merchant_name": "Example Store",
>     "merchant_country_code": "US",
>     "merchant_order_id": "shop-order-1"
>   }'
> ```
>
> After your browser executor completes the merchant payment with the credential from the response, report the result with the same `client_reference_id`:
>
> ```bash theme={null}
> curl -X POST "$API_BASE_URL/agent/platform/credential-results" \
>   -H "Authorization: Bearer $PORTAL_USER_TOKEN" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "client_reference_id": "platform-ref-001",
>     "outcome": "SUCCEEDED",
>     "paid_amount": "12.50",
>     "currency_code": "USD",
>     "failure_reason": null
>   }'
> ```
>
> In production, decrypt `key` / `payload` on a trusted server, and let the browser executor use the card details only briefly in the payment fields. For the full prerequisite steps for the credential endpoint, see [RESTful API integration](https://docs.clinkbill.com/guides/agent/platform_integration/restful_api.md).

For field constraints and error codes, see [Browser Pay tools](https://docs.clinkbill.com/api-reference/mcp/browser_pay.md) and [Operations and recovery](https://docs.clinkbill.com/api-reference/mcp/operations.md).


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