GladysDevelopers

Capture and cancel

Take the money when you're ready, or let the payment go.

Automatic or manual capture

With capture_method: "AUTOMATIC", the default, the money moves the moment the payer approves: the payment goes straight to CAPTURED. Use it when you deliver right away.

With capture_method: "MANUAL", approving only holds the money in the payer's wallet: the payment becomes AUTHORIZED and waits for you. Use it when you might not be able to deliver, such as stock to confirm or a booking to check. You then capture, or cancel to release the hold.

Capturing

curl -X POST https://api.joingladys.com/api/v1/payments/pay_…/capture \
  -H "Authorization: Bearer access_…" \
  -H "Idempotency-Key: order-1042-capture"
  • Only an AUTHORIZED payment can be captured. Anything else is 400.
  • Capture takes the full amount. Partial capture isn't supported; to take less, capture and then refund the difference.
  • Capturing a payment that is already CAPTURED returns it unchanged, so retrying is safe.
  • Capture within 7 days of approval. After that the payment becomes EXPIRED and the hold is released.

Needs the payments:capture scope.

Cancelling

curl -X POST https://api.joingladys.com/api/v1/payments/pay_…/cancel \
  -H "Authorization: Bearer access_…" \
  -H "Idempotency-Key: order-1042-cancel" \
  -H "Content-Type: application/json" \
  -d '{ "reason": "Out of stock" }'
  • You can cancel a CREATED payment (the payer hasn't approved yet) or an AUTHORIZED one (the hold is released straight away).
  • reason is optional and becomes the payment's cancellation_reason. It defaults to Cancelled by the merchant.
  • Cancelling a payment that is already CANCELLED returns it unchanged.
  • A CAPTURED payment can't be cancelled: refund it instead.

Cancelling also uses the payments:capture scope.

When the payer declines

A payer can decline on the checkout page instead of approving. The payment becomes CANCELLED with the reason Declined by the payer, and you receive payment.cancelled.

On this page