PT EN

Sessões de pagamento

URL base: $CONSUMER_API

O objecto

idstring · obrigatório
tenant_idstring · obrigatório
invoice_idstring · obrigatório
amountinteger (int64) · obrigatório
currencystring · obrigatório
statusstring · obrigatório

um de pending, confirmed, failed, expired, cancelled

next_actionunion · obrigatório
O objecto
{
  "id": "pay_2DxUipfYyfRuqNn2cZf00RTYqB3",
  "tenant_id": "ten_2ugFXIC316WXzGu1HGal90AxTA6",
  "invoice_id": "inv_2jnourvAGxXMMd5IyFbwc1LqUX1",
  "amount": 125000,
  "currency": "MZN",
  "status": "pending",
  "next_action": {
    "type": "redirect",
    "url": "https://example.org/"
  }
}

Listar sessões de pagamento

Registos

GET /payment-sessions

Pages the checkout sessions the caller started, across their tenants unless X-Tenant-ID selects one, with each session's status (for example pending, confirmed or failed). Pagination uses limit and after.

Parâmetros

limitinteger · consulta · opcional

Maximum resources to return (default 20, maximum 100).

afterstring · consulta · opcional

Opaque cursor returned by the previous page.

Devolve

200 Payment sessions visible to the authenticated consumer

curl -X GET "$CONSUMER_API/payment-sessions" \
  -H "Authorization: Bearer sk_test_..."
Resposta 200

Payment sessions visible to the authenticated consumer

Iniciar o pagamento de uma factura

Registos

POST /payment-sessions

Returns provider-neutral next_action instructions; WSMS does not process payment instruments.

Corpo application/json

invoice_idstring · obrigatório
methodstring · obrigatório

A checkout method code, as listed in the utility's checkout_methods in the consumer payment availability. The codes come from the utility's payment connectors; the server keeps no list of providers and refuses a method no live connector offers.

phonestring · opcional

Required when the chosen checkout method has requires_phone set.

return_urlstring (uri) · opcional

Devolve

201 Payment session created with an external provider

Mostrar atributos
idstring · obrigatório
tenant_idstring · obrigatório
invoice_idstring · obrigatório
amountinteger (int64) · obrigatório
currencystring · obrigatório
statusstring · obrigatório

um de pending, confirmed, failed, expired, cancelled

next_actionunion · obrigatório

Erros 403

curl -X POST "$CONSUMER_API/payment-sessions" \
  -H "Authorization: Bearer sk_test_..." \
  -H "Content-Type: application/json" \
  -d '{
  "invoice_id": "inv_2jnourvAGxXMMd5IyFbwc1LqUX1",
  "method": "method",
  "phone": "+258841234567",
  "return_url": "https://example.org/"
}'
Resposta 201
{
  "id": "pay_2DxUipfYyfRuqNn2cZf00RTYqB3",
  "tenant_id": "ten_2ugFXIC316WXzGu1HGal90AxTA6",
  "invoice_id": "inv_2jnourvAGxXMMd5IyFbwc1LqUX1",
  "amount": 125000,
  "currency": "MZN",
  "status": "pending",
  "next_action": {
    "type": "redirect",
    "url": "https://example.org/"
  }
}

Obter uma sessão de pagamento

Registos

GET /payment-sessions/{id}

Returns one checkout session the caller started, so a client can poll until it is confirmed or failed. Sessions started by someone else or outside the caller's scope return 404.

Parâmetros

idstring · caminho · obrigatório

Identifier of the payment session to return.

Devolve

200 Payment session and provider-neutral status

Mostrar atributos
idstring · obrigatório
tenant_idstring · obrigatório
invoice_idstring · obrigatório
amountinteger (int64) · obrigatório
currencystring · obrigatório
statusstring · obrigatório

um de pending, confirmed, failed, expired, cancelled

next_actionunion · obrigatório
curl -X GET "$CONSUMER_API/payment-sessions/{id}" \
  -H "Authorization: Bearer sk_test_..."
Resposta 200
{
  "id": "pay_2DxUipfYyfRuqNn2cZf00RTYqB3",
  "tenant_id": "ten_2ugFXIC316WXzGu1HGal90AxTA6",
  "invoice_id": "inv_2jnourvAGxXMMd5IyFbwc1LqUX1",
  "amount": 125000,
  "currency": "MZN",
  "status": "pending",
  "next_action": {
    "type": "redirect",
    "url": "https://example.org/"
  }
}

Confirmar uma sessão de pagamento na sandbox

Registos

POST /payment-sessions/{id}/sandbox/confirm

Confirm a sandbox session (development only, 404 otherwise)

Development-only call that confirms one of the caller's own checkout sessions as if the provider had settled it, recording the payment, receipt and invoice allocation. It is available only when the sandbox payment provider is configured and returns 404 otherwise. Confirming an already confirmed session returns it unchanged.

Parâmetros

idstring · caminho · obrigatório

Resource identifier

Devolve

200 Confirmed session

Mostrar atributos
idstring · obrigatório
tenant_idstring · obrigatório
invoice_idstring · obrigatório
amountinteger (int64) · obrigatório
currencystring · obrigatório
statusstring · obrigatório

um de pending, confirmed, failed, expired, cancelled

next_actionunion · obrigatório
curl -X POST "$CONSUMER_API/payment-sessions/{id}/sandbox/confirm" \
  -H "Authorization: Bearer sk_test_..."
Resposta 200
{
  "id": "pay_2DxUipfYyfRuqNn2cZf00RTYqB3",
  "tenant_id": "ten_2ugFXIC316WXzGu1HGal90AxTA6",
  "invoice_id": "inv_2jnourvAGxXMMd5IyFbwc1LqUX1",
  "amount": 125000,
  "currency": "MZN",
  "status": "pending",
  "next_action": {
    "type": "redirect",
    "url": "https://example.org/"
  }
}