Overview
The Charges resource allows you to receive payments from your customers. It provides a way to create payment requests and track their status, giving you control over incoming transactions. This section covers how to create and manage charges and integrate them into your application workflow.
Charges follow a consistent flow. Your application creates a charge, presents payment instructions to the customer, and listens for events to confirm the payment.
Charge Lifecycle
The diagram below shows the interaction between your application, KingsPay, and your customer during a typical charge flow.
1. Create a charge
Create a charge by calling POST /v1/payments/charges with the required payment details.
The API returns a charge object with status = pending. Store this charge in your database so you can track its status and reconcile it later.
See Creating a Charge for detailed examples.
2. Show payment instructions
After creating the charge, provide the payment instructions to your customer.
You can either:
- Redirect the customer to the hosted payment URL, or
- Display the payment details in your application.
The customer uses this information to complete the payment.
3. Wait for payment completion
After the charge is created, your application should wait for the payment to be completed.
KingsPay monitors the payment and updates the charge status automatically.
4. Handle events
When the charge status changes, KingsPay emits an event to your configured webhook destination.
See Charge Events for the full list of events emitted for charges, and the Events overview for details on how to receive and process events.
5. Update your records
Once you receive and process the event, update whatever records or workflows in your application depend on the charge.
Mark the charge as successful only after the payment_charge.succeeded event arrives, and then let your customer know their payment succeeded.