# @provenanceauth/rails/checkout

@provenanceauth/rails/checkout in the Rails: 13 methods. Plain web checkout.

## Methods

### [checkoutBinding](https://provenanceauth.com/docs/sdks/rails/checkout/checkout-binding.md)

```ts
checkoutBinding(order: CheckoutOrder): CheckoutOrder
```

The exact object to pass as `action_payload` to `POST /v1/mandate/intents` (agent side) and to rebuild from your own order record (merchant side).

### [serviceDay](https://provenanceauth.com/docs/sdks/rails/checkout/service-day.md)

```ts
serviceDay(value: unknown): string | null
```

The calendar day of a service date or date-time, in its own offset (no time-zone conversion); null when invalid.

### [checkoutBindingHash](https://provenanceauth.com/docs/sdks/rails/checkout/checkout-binding-hash.md)

```ts
checkoutBindingHash(order: CheckoutOrder): Promise<string>
```

Sha256(canonical JSON) of the binding: the `payload_hash` a token bound to this order carries.

### [fulfillmentDigest](https://provenanceauth.com/docs/sdks/rails/checkout/fulfillment-digest.md)

```ts
fulfillmentDigest(address: Record<string, unknown>): Promise<string>
```

Sha256 hex over the canonical shipping address, for `fulfillment_digest`.

### [verifyIpCommitment](https://provenanceauth.com/docs/sdks/rails/checkout/verify-ip-commitment.md)

```ts
verifyIpCommitment(ip: string, nonce: string, commitment: string): Promise<boolean>
```

Check that the approving device's IP you received with a checkout approval (`signals.browser.ip` and `ip_nonce`) is the one Provenance saw: `commitment` (from the decision record, the receipt or an evidence pack) is the hex SHA-256 of the IP's UTF-8 bytes followed by the 16 nonce bytes (base64url).

### [approvalChallenge](https://provenanceauth.com/docs/sdks/rails/checkout/approval-challenge.md)

```ts
approvalChallenge(order: CheckoutOrder, opts: ApprovalChallengeOptions): { status: 401; headers: Record<string, string>; body: ApprovalProblem }
```

Merchant side: the `401` to send when you want the shopper's approval for this exact order.

### [cartSummary](https://provenanceauth.com/docs/sdks/rails/checkout/cart-summary.md)

```ts
cartSummary(binding: Pick<CheckoutOrder, "total" | "currency" | "items">, merchantName: string): string
```

The cart in one line, for an agent to show its person ("Harbor Bean Coffee: 2 items, USD 38.00").

### [mcpApprovalResult](https://provenanceauth.com/docs/sdks/rails/checkout/mcp-approval-result.md)

```ts
mcpApprovalResult(challenge: { body: ApprovalProblem } | ApprovalProblem | ApprovalRequest): McpApprovalResult
```

Goal 9b: for a store with its own MCP server.

### [checkoutHeaders](https://provenanceauth.com/docs/sdks/rails/checkout/checkout-headers.md)

```ts
checkoutHeaders(intentToken: string, mandateToken?: string): Record<string, string>
```

Agent side: the headers to add to the checkout request.

### [publicVerify](https://provenanceauth.com/docs/sdks/rails/checkout/public-verify.md)

```ts
publicVerify(baseUrl: string, opts?: { surface?: "page" | "embed" | "checkout" | "api"; fetch?: typeof fetch }): OnlineStatus
```

An `onlineStatus` callback for the free, keyless `POST /v1/verify`.

### [loadJwks](https://provenanceauth.com/docs/sdks/rails/checkout/load-jwks.md)

```ts
loadJwks(baseUrl: string, opts?: { maxAgeMs?: number; fetch?: typeof fetch }): { get: (o?: { refresh?: boolean }) => Promise<Jwks> }
```

A cached JWKS getter for `<baseUrl>/.well-known/jwks.json`.

### [verifyAgentCheckout](https://provenanceauth.com/docs/sdks/rails/checkout/verify-agent-checkout.md)

```ts
verifyAgentCheckout(headerValue: string | null | undefined, opts: CheckoutVerifyOptions): Promise<CheckoutVerifyResult>
```

Merchant side: verify the `Provenance-Intent` header against your own order record.

### [acceptNetworkOrder](https://provenanceauth.com/docs/sdks/rails/checkout/accept-network-order.md)

```ts
acceptNetworkOrder(headerValue: string | null | undefined, opts: NetworkAcceptOptions): Promise<NetworkAcceptResult>
```

Verify a network order offline (signature, the exact order, approval strength), then accept it online: the person's reserved budget becomes spend.
