Skip to main content

Payment Providers

Payment providers handle payment processing, authorization, capture, refunds, and webhook events. Medusa’s payment provider interface supports complex payment flows including 3D Secure, async payment methods, and account holder management.

Available Payment Providers

Medusa includes the following payment providers:

Stripe Provider

The Stripe provider (@medusajs/medusa/payment-stripe) supports multiple payment methods:
  • stripe - Default Stripe payment (cards)
  • stripe-bancontact - Bancontact payments
  • stripe-blik - BLIK payments (Poland)
  • stripe-giropay - Giropay payments (Germany)
  • stripe-ideal - iDEAL payments (Netherlands)
  • stripe-przelewy24 - Przelewy24 payments (Poland)
  • stripe-promptpay - PromptPay payments (Thailand)
  • stripe-oxxo - OXXO payments (Mexico)

Installation

The Stripe payment provider is included in the core Medusa package:

Configuration

Configure the Stripe provider in your medusa-config.ts:

Environment Variables

Set the following environment variables in your .env file:
Get your API keys from the Stripe Dashboard. Create a webhook endpoint to get your webhook secret.

Payment Provider Interface

All payment providers implement the AbstractPaymentProvider interface with the following methods:

Core Payment Methods

initiatePayment(input: InitiatePaymentInput): Promise<InitiatePaymentOutput>

Creates a new payment session with the provider.

authorizePayment(input: AuthorizePaymentInput): Promise<AuthorizePaymentOutput>

Authorizes a payment (holds funds without capturing).

capturePayment(input: CapturePaymentInput): Promise<CapturePaymentOutput>

Captures an authorized payment.

cancelPayment(input: CancelPaymentInput): Promise<CancelPaymentOutput>

Cancels a payment before it’s captured.

refundPayment(input: RefundPaymentInput): Promise<RefundPaymentOutput>

Refunds a captured payment.

Account Holder Methods

Manage customer accounts in the payment provider (e.g., Stripe customers).

createAccountHolder(input: CreateAccountHolderInput): Promise<CreateAccountHolderOutput>

updateAccountHolder(input: UpdateAccountHolderInput): Promise<UpdateAccountHolderOutput>

deleteAccountHolder(input: DeleteAccountHolderInput): Promise<DeleteAccountHolderOutput>

Payment Method Methods

listPaymentMethods(input: ListPaymentMethodsInput): Promise<ListPaymentMethodsOutput>

List saved payment methods for an account holder.

savePaymentMethod(input: SavePaymentMethodInput): Promise<SavePaymentMethodOutput>

Save a payment method for future use.

Webhook Handling

getWebhookActionAndData(payload: ProviderWebhookPayload): Promise<WebhookActionResult>

Processes webhook events from the payment provider. Supported Stripe webhook events:
  • payment_intent.created
  • payment_intent.processing
  • payment_intent.succeeded
  • payment_intent.canceled
  • payment_intent.payment_failed
  • payment_intent.requires_action
  • payment_intent.amount_capturable_updated

Using the Payment Module

Access payment providers through the Payment Module:

Payment Workflows

Use payment workflows from @medusajs/core-flows:

Creating Custom Payment Providers

Create a custom payment provider by extending AbstractPaymentProvider:
packages/modules/providers/payment-custom/src/services/custom-payment.ts
Register your custom provider:
packages/modules/providers/payment-custom/src/index.ts

Reference

  • Source: packages/modules/providers/payment-stripe/
  • Base class: packages/core/utils/src/payment/abstract-payment-provider.ts
  • Types: packages/core/types/src/payment/provider.ts

Next Steps

Fulfillment Providers

Configure shipping and fulfillment

Notification Providers

Set up payment confirmation emails