Track payment status
Last updated: Oct 6th, 8:36am
After creating the order, you can track the payment status in two ways:
- Use webhooks
- Optional: Poll for updates
Note: Use webhooks for real-time updates, and poll the order status only if you cannot receive webhooks.
Use webhooks
To track the payment status using webhooks, follow these steps:
- Subscribe to webhook events in your PayPal developer dashboard or through the Webhooks API. For example:
CHECKOUT.ORDER.COMPLETED– Payment captured successfully after automatic capturePAYMENT.CAPTURE.DENIED– Payment capture failed
- Define a webhook handler in your server-side application to:
- Listen for incoming webhook events.
- Confirm receipt of the event to PayPal.
- Verify the source of the event notification.
- Complete further actions based on event data.
Note: If needed, use the List event notifications API to retrieve all webhook events or the Show event notification details API to get specific event details.
Extract the order ID from the "rel": "up" link in the webhook payload's resource.links array to correlate the capture to your original order.
Poll for updates
Note: Be aware of PayPal's API rate limits when polling for order status. Avoid polling during the 4-hour session timeout period while the buyer is on Afterpay's page. For best practices and details, see the Rate limiting guideline.
To check the status of an Afterpay order, you can poll the Orders API:
- Use a valid access token and send a GET request to the
/v2/checkout/orders/{id}endpoint, replacing{id}with the order ID from your Create order response. - Review the response to determine the current order status and take action as needed.
| Parameter name | Description |
|---|---|
id |
Unique order ID. |
status |
Current status of the order. |
purchase_units |
List of purchase units for the order, including amount and currency. |
payer |
Information about the buyer, including name and payer ID. |
For the comprehensive list of response parameters, see Show order details.