# Pay via AI Agent

We are an approved payment partner for OpenAI's Instant Checkout. Integrate our APIs to enable ChatGPT Instant Checkout via the OpenAI "Agentic Commerce Protocol" (ACP).

Refer to OpenAI's documentation here: Agentic Commerce 

## Get started

Prerequisite
You must have an Access Worldpay `checkout ID` as well as API credentials.

There are six steps to the flow:

### 1. Product discovery: Agent can find your products (Merchant -> OpenAI)

You send a product feed to the Agent. See product feed specification for details.

### 2. Cart creation: Agent assembles cart based on customer intent (OpenAI -> Merchant)

Agent creates a cart (`checkout session`) with your customer's items. See agentic checkout specification for details.

You must return the Access Worldpay `checkout ID` in the `merchant_id` key:value.

### 3. Payment delegation: Agent creates delegate token (OpenAI -> Worldpay)

The Agent creates a `delegate token` representing the payment using the Worldpay [Sessions API](/access/products/sessions/). This encapsulates the payment instrument, and allowances such as the payment value and expiry specified by OpenAI.

Our [MCP server](/access/products/ai/mcp) also has a tool for this step to create the delegate token.

Sessions API schema
View the full schema with examples here


```JSON Request example
POST request /sessions/agentic_commerce/delegate_payment

{
  "payment_method": {
      "type": "card",
      "card_number_type": "fpan",
      "number": "4242424242424242",
      "exp_month": "11",
      "exp_year": "2026",
      "name": "Jane Doe",
      "cvc": "223",
      "checks_performed": [
          "avs",
          "cvv"
      ],
      "iin": "424242",
      "display_card_funding_type": "credit",
      "display_brand": "visa",
      "display_last4": "4242",
      "metadata": {
          "issuing_bank": "temp"
      }
  },
  "allowance": {
      "reason": "one_time",
      "max_amount": 2000,
      "currency": "usd",
      "checkout_session_id": "csn_01HV3P3...",
      "merchant_id": "acme",
      "expires_at": "2025-10-09T07:20:50.52Z"
  },
  "billing_address": {
      "name": "John Doe",
      "line_one": "123 Fake St.",
      "line_two": "Unit 1",
      "city": "San Francisco",
      "state": "CA",
      "country": "US",
      "postal_code": "12345"
  },
  "risk_signals": [
      {
          "type": "card_testing",
          "score": 10,
          "action": "manual_review"
      }
  ],
  "metadata": {
      "campaign": "q4"
  }
}
```


```JSON Response example

{
	"id": "https://try.access.worldpay-bsh.securedataplatform.com/sessions/eyJrIjoxLCJkIjoiMmlOVUFUMlNDSU5VbEpMcUd6cW8zV.....",
	"created": "2025-10-23T10:34:04.724644609Z",
	"metadata": {
		"idempotency_key": "an-idempotent-key",
		"source": "agent_checkout",
		"merchant_id": "550e8400-e29b-41d4-a716-446655440000"
	}
}
```

### 4. Checkout completion: Agent provides checkout session and delegate token to you (OpenAI -> Merchant)

* Providing the delegate token (`id` from step 3) as `payment_data.token`.



```JSON Request example
POST request to /checkout_sessions/checkout_session_123/complete

{
   "buyer": {
       "first_name": "John",
       "last_name": "Smith",
       "email": "johnsmith@example.com",
       "phone_number": "15552003434"
   },
   "payment_data": {
       "token": "https://try.access.worldpay-bsh.securedataplatform.com/sessions/eyJrIjoxLCJkIjoiMmlOVUFUMlNDSU5VbEpMcUd6cW8zV.....",
       "provider": "worldpay",
       "billing_address": {
           "name": "test",
           "line_one": "1234 Chat Road",
           "line_two": "Apt 101",
           "city": "San Francisco",
           "state": "CA",
           "country": "US",
           "postal_code": "94131"
       }
   }
}
```

### 5. Payment request: You process the payment using the delegate token in our Payments API (Merchant -> Worldpay)

* Apply the delegate token (`payment_data.token` from step 4) in the [Payments API](/access/products/payments/) as `paymentInstrument.sessionHref`.
* Set the `paymentInstrument.type` as `delegate`.



```json
POST Request /api/payments

{
    "transactionReference": "order1234",
    "merchant": {
        "entity": "default"
    },
    "instruction": { 
        "method": "card", // [!code focus:5] // [!code highlight:5]
        "paymentInstrument": {
            "type": "delegate",
            "sessionHref": "https://try.access.worldpay-bsh.securedataplatform.com/sessions/eyJrIjoxLCJkIjoialRBL0FFelBzcnZpNCtzRGNRemh0NzI0NE1rdUtjMUFJdjYxVnlibWZuUT0ifQ"
        },
        "customer": {
            "email": "john.appleseed@example.com",
            "phone": "00000000000",
            "ipAddress": "192.168.0.1"
        },
        "narrative": {
            "line1": "trading name"
        },
        "value": {
            "currency": "GBP",
            "amount": 42
        }
    }
}
```

Using delegate token with Payments API
Guide to using a delegate token with the Payments API. Features and limitations.

We validate the payment allowances specified by OpenAI before processing the payment.

### 6. Fulfillment: You complete the order as a normal e-commerce payment

## Sequence diagram


```mermaid

sequenceDiagram
    participant Agent
    participant Merchant
    participant Sessions as Worldpay Sessions API
    participant PAPI as Worldpay Payments API
    Merchant-->>Agent: Product feed (step 1)
    Agent->>+Merchant: POST to /checkout_sessions (step 2)
    Merchant-->>-Agent: Return PSP information inc. checkoutId
    Agent->>+Sessions: POST to /sessions/agentic_commerce/delegate_payment (step 3)
    Sessions->>Sessions: Store delegate payment data
    Sessions-->>-Agent: Return delegate token (sessionHref)
    Agent->>+Merchant: POST to /checkout_sessions/{id}/complete {payment_data:href} (step 4)
    Merchant->>+PAPI: POST to /api/payments {instruction.paymentInstrument.sessionHref} (step 5)
    PAPI->>+Sessions: GET {sessionHref}
    Sessions->>Sessions: Lookup session
    Sessions-->>-PAPI: Return delegate payment data
    PAPI->>PAPI: Validate delegate payment data against instruction
    opt : if valid
        PAPI->>PAPI: Authorize payment
    end
    PAPI-->>-Merchant: Return payment outcome
    Merchant-->>-Agent: Return payment outcome
```