Overview
The Payment Module manages all payment-related operations including payment collection creation, payment session handling, payment capture, and refunds. It provides a provider-agnostic interface that works with various payment providers like Stripe, PayPal, and others. Key Features:- Payment collection management
- Payment session handling (authorize, capture)
- Multi-provider support (Stripe, PayPal, etc.)
- Payment capture and refund processing
- Webhook handling for async payments
- Account holder management
- Payment method tracking
When to Use
Use the Payment Module when you need to:- Process customer payments during checkout
- Authorize payments before capturing
- Capture authorized payments
- Process full or partial refunds
- Handle payment provider webhooks
- Store customer payment methods
- Track payment transactions
- Support multiple payment providers
Data Models
PaymentCollection
Groups payment sessions for a cart or order.string
required
Unique payment collection identifier
string
required
Three-letter ISO currency code
BigNumber
required
Total amount to be paid
BigNumber
Amount currently authorized
BigNumber
Amount successfully captured
BigNumber
Amount refunded to customer
PaymentCollectionStatus
required
Status:
not_paid, awaiting, authorized, partially_authorized, canceledPaymentSession[]
Payment sessions in this collection
Payment[]
Completed payments
string
Associated region ID
PaymentSession
Represents an active payment attempt.string
required
Unique payment session identifier
string
required
ID of the parent payment collection
string
required
Payment provider identifier (e.g., “stripe”, “paypal”)
string
required
Three-letter ISO currency code
BigNumber
required
Payment amount
PaymentSessionStatus
required
Status:
pending, authorized, error, canceledDateTime
When payment was authorized
object
Provider-specific data (e.g., Stripe payment intent)
object
Additional context data
Payment
Represents a completed payment.string
required
Unique payment identifier
string
required
ID of the payment collection
string
ID of the originating payment session
string
required
Payment provider identifier
string
required
Three-letter ISO currency code
BigNumber
required
Payment amount
DateTime
When payment was captured
Capture[]
Payment captures
Refund[]
Payment refunds
Capture
Represents a payment capture (full or partial).string
required
Unique capture identifier
string
required
ID of the payment being captured
BigNumber
required
Captured amount
string
User ID who initiated the capture
Refund
Represents a payment refund.string
required
Unique refund identifier
string
required
ID of the payment being refunded
BigNumber
required
Refund amount
string
ID of the refund reason
string
Refund note or explanation
string
User ID who initiated the refund
AccountHolder
Stores customer payment account information.string
required
Unique account holder identifier
string
Account holder email
string
Associated customer ID
string
required
Payment provider identifier
string
Provider-specific account ID
Service Interface
The Payment Module service is available at@medusajs/medusa/payment.
Create Payment Collection
Create a payment collection for a cart or order.CreatePaymentCollectionDTO
required
PaymentCollectionDTO
The created payment collection
Create Payment Session
Initiate a payment session with a provider.string
required
ID of the payment collection
CreatePaymentSessionDTO
required
PaymentSessionDTO
The created payment session
Authorize Payment Session
Authorize a payment (reserve funds).string
required
ID of the payment session to authorize
object
Provider-specific authorization context
PaymentDTO
The authorized payment
Capture Payment
Capture an authorized payment.CreateCaptureDTO
required
CaptureDTO
The created capture
Refund Payment
Refund a captured payment.CreateRefundDTO
required
RefundDTO
The created refund
Handle Provider Webhook
Process payment provider webhooks.ProviderWebhookPayload
required
WebhookActionResult
Webhook processing result with action type
Create Account Holder
Store customer payment account information.List Payment Providers
Retrieve available payment providers.Integration Examples
With Cart Module
Create payment collection for cart checkout.With Order Module
Track order payments.With Region Module
Region-based payment provider availability.Payment Providers
Medusa supports multiple payment providers through a provider pattern:Stripe
PayPal
Best Practices
- Authorization vs Capture: Use two-step authorization and capture for orders that require fulfillment before charging. Authorize during checkout, capture upon shipment.
-
Currency Precision: The module automatically rounds amounts to currency-specific precision using
Intl.NumberFormat. - Partial Operations: Support partial captures and refunds by specifying amounts less than the total payment amount.
- Webhook Security: Always verify webhook signatures using the raw request body. Providers include signature verification in their SDKs.
-
Error Handling: Payment sessions can fail due to insufficient funds, declined cards, etc. Handle
PaymentSessionStatus.ERRORappropriately. - Idempotency: Payment operations should be idempotent to prevent duplicate charges during retries.
Related Modules
- Cart Module - Create payment collections for carts
- Order Module - Link payments to orders
- Region Module - Configure region payment providers
- Customer Module - Store customer payment methods