@agorio/sdkDocs


Class: AcpClient

Constructors

new AcpClient()

new AcpClient(options): AcpClient

Parameters

options: AcpClientOptions

Returns

AcpClient

Defined in

src/client/acp-client.ts:28

Methods

cancelCheckout()

cancelCheckout(sessionId, opts): Promise<AcpCheckoutSession>

Cancel a checkout session. POST /checkout_sessions/:id/cancel

Parameters

sessionId: string

opts = {}

opts.idempotencyKey?: string

Returns

Promise<AcpCheckoutSession>

Defined in

src/client/acp-client.ts:109


completeCheckout()

completeCheckout(sessionId, params, opts): Promise<AcpCheckoutSession>

Complete a checkout session with payment. POST /checkout_sessions/:id/complete

Strongly recommended to pass idempotencyKey here — completing a checkout charges the buyer, so retries without a key risk double charges.

Parameters

sessionId: string

params

params.payment_handler: string

params.payment_token: string

opts = {}

opts.idempotencyKey?: string

Returns

Promise<AcpCheckoutSession>

Defined in

src/client/acp-client.ts:89


createCheckout()

createCheckout(params, opts): Promise<AcpCheckoutSession>

Create a new checkout session. POST /checkout_sessions

Pass idempotencyKey (v0.9) to make this request safe to retry — the merchant returns the original session on duplicate keys instead of creating two checkouts.

Parameters

params

params.line_items: object[]

params.shipping_address?: AcpShippingAddress

opts = {}

opts.idempotencyKey?: string

Returns

Promise<AcpCheckoutSession>

Defined in

src/client/acp-client.ts:44


getCheckout()

getCheckout(sessionId): Promise<AcpCheckoutSession>

Get an existing checkout session. GET /checkout_sessions/:id

Parameters

sessionId: string

Returns

Promise<AcpCheckoutSession>

Defined in

src/client/acp-client.ts:62


getEndpoint()

getEndpoint(): string

Get the configured endpoint URL.

Returns

string

Defined in

src/client/acp-client.ts:144


getOrder()

getOrder(orderId): Promise<AcpOrder>

Fetch a completed order by id.

NOTE: ACP defines no canonical order-pull endpoint — orders are delivered via the order_create / order_update webhook (see ADR 0009 and ./acp-order-events.ts). This method targets the agorio convention path GET /orders/{id} and returns the canonical Order shape. Use it to reconcile a missed webhook; prefer webhook ingestion as the primary path.

Parameters

orderId: string

Returns

Promise<AcpOrder>

Defined in

src/client/acp-client.ts:125


listOrders()

listOrders(params): Promise<AcpOrder[]>

List orders (agorio convention path GET /orders — see getOrder). Returns the canonical Order[].

Parameters

params = {}

params.checkout_session_id?: string

Returns

Promise<AcpOrder[]>

Defined in

src/client/acp-client.ts:133


updateCheckout()

updateCheckout(sessionId, params, opts): Promise<AcpCheckoutSession>

Update a checkout session (e.g., add shipping address, select payment handler). POST /checkout_sessions/:id

Parameters

sessionId: string

params

params.discount_code?: string

params.payment_handler?: string

params.shipping_address?: AcpShippingAddress

opts = {}

opts.idempotencyKey?: string

Returns

Promise<AcpCheckoutSession>

Defined in

src/client/acp-client.ts:70