Handle partial approvals from your server
Confirm or cancel partially approved charges and payment sessions from your server using the partial approval API.
With server-to-server partial approval, a charge or payment session approved for less than the requested amount pauses for your server's decision. Display the approved amount to the customer, then confirm it, confirm a lower amount or predefined package, or cancel the payment.
Requirements
Before you start, make sure you have:
- Your API credentials and environment base URL (sandbox:
https://api.sandbox.pay.com/v1, with ansk-pay-com-sandbox-key). - A unique
idempotency-keyheader for eachPOSTrequest. - Server-to-server partial approval enabled on your account (contact your account manager). Without it, the confirm and cancel endpoints return
403withS2S Partial approval is not enabled for this merchant.
Handle a partial approval
Follow these steps to enable partial approvals on a payment and confirm or cancel the approved amount from your server.
- 1
Accept partial approval on the payment
Include
payment_method_options.card.partial_approvalwhen creating a charge (POST /v1/charges) or payment session (POST /v1/sessions/payment). This example requests $10.00 USD (1000in minor units) and cancels any approval below $5.00 USD or below 20% of the requested amount:{ "amount": 1000, "currency": "usd", "source": "pm_card_685125127054035968", "payment_method_options": { "card": { "partial_approval": { "accept": true, "percentage_threshold": 20, "amount_threshold": 500, "approved_by_default": true } } } }See Request fields for every option, including
productsfor packages, and Response fields for the details the payment returns. - 2
Detect the partial approval status
When the issuer approves a lower amount, the charge or payment session returns
status: "requires_partial_approval_action", and Pay.com sends thecharge.requires_partial_approval_actionwebhook event. The charge'samountreflects the approved amount rather than the originally requested amount.{ "id": "chrg_656422478087717888", "resource": "charge", "amount": 800, "status": "requires_partial_approval_action", "payment_method_details": { "card": { "partial_approval": { "status": "pending", "amount_requested": 1000, "amount_authorized": 800 } } } }No funds are captured yet. Show the customer the approved amount and confirm or cancel within 5 minutes (unless your account manager configured a different window). When time expires,
approved_by_defaultdetermines the outcome:trueor omitted: Pay.com confirms the approved amount. Ifproductswere sent, Pay.com charges the largest package that fits within the approved amount.false: Pay.com cancels the payment.
- 3
Confirm or cancel the partial approval
Call the confirm or cancel endpoint with the customer's decision.
Confirming captures the funds. Send
POST /v1/charges/{charge_id}/partial_approval/confirm(orPOST /v1/sessions/payment/{session_id}/partial_approval/confirmfor a payment session).With an empty body, Pay.com captures the full approved amount (
800for $8.00 USD). To capture less, sendamountin minor units. If you created the payment withproducts, you can sendproduct_idinstead to charge one of those packages, such asplan_basicfrom Offer packages. Neither can exceed the approved amount.{ "amount": 800 }{ "product_id": "plan_basic" }{ "id": "chrg_656494520417911808", "resource": "charge", "amount": 800, "payment_method": "pm_card_656494527799887872", "payment_method_details": { "card": { "partial_approval": { "amount_authorized": 800, "amount_charged": 800, "amount_requested": 1000, "product_id": null, "status": "accepted" } } }, "status": "succeeded_partially" }The charge status becomes
succeeded_partially, and a payment session status becomescompleted_partially. Thepartial_approvalobject reportsamount_requested(original amount),amount_authorized(approved amount), andamount_charged(captured amount).
Errors
The confirm and cancel endpoints return these HTTP error statuses.
| Status | Cause |
|---|---|
400 | The charge or session isn't awaiting a partial approval decision, amount exceeds the approved amount, or product_id doesn't match one of the payment's products. |
403 | Server-to-server partial approval isn't enabled for your account. |
404 | The charge or session doesn't exist or belongs to another account. |
Listen for webhooks
Subscribe to these webhook events to track partial approvals on your backend.
| Event type | Description |
|---|---|
charge.requires_partial_approval_action | The issuer approved a lower amount, and the charge awaits confirmation or cancellation. |
charge.succeeded | The partial approval was confirmed and funds were captured. The charge status is succeeded_partially. |
charge.failed | The partial approval was canceled or timed out with approved_by_default: false. No funds were captured. |
See Webhooks to set up an endpoint and verify event signatures.
Testing
The sandbox test cards approve 80% of the requested amount. See Testing for the card numbers.
Next steps
- Partial approvals overview: Review all options, packages, hosted checkout, and holds.
- Confirm partial approval (charge): API reference for
POST /v1/charges/{charge_id}/partial_approval/confirm. - Confirm partial approval (session): API reference for
POST /v1/sessions/payment/{session_id}/partial_approval/confirm.