Payment
In this document, you’ll learn what a payment is and how it's created, captured, and refunded.
What's a Payment?#
When a payment session is authorized, a payment, represented by the Payment data model, is created. This payment can later be captured or refunded.
A payment carries many of the data and relations of a payment session:
- It belongs to the same payment collection.
- It’s associated with the same payment provider, which handles further payment processing.
- It stores the payment session’s
data
property in itsdata
property, as it’s still useful for the payment provider’s processing.
Capture Payments#
When a payment is captured, a capture, represented by the Capture data model, is created. It holds details related to the capture, such as the amount, the capture date, and more.
The payment can also be captured incrementally, each time a capture record is created for that amount.
Refund Payments#
When a payment is refunded, a refund, represented by the Refund data model, is created. It holds details related to the refund, such as the amount, refund date, and more.
A payment can be refunded multiple times, and each time a refund record is created.
data Property#
Payment providers may need additional data to process the payment later. For example, the ID of the associated payment in the third-party provider.
The Payment
data model has a data
property used to store that data. The first time it's set is when the payment provider in Medusa authorizes the payment.
Then, the data
property is passed to the Medusa payment provider when the payment is captured or refunded, allowing the payment provider to utilize the data to process the payment with the third-party provider.
data
property in the Create Payment Provider guide.