Payafter Feature

June 17, 2026 · 5 min read

The MedusaJS' Cart architecture is problematic when dealing with payments that are not authorized on the spot, such as pay-by-link payment gateways. This is because the cart is designed to be a temporary record that holds items until checkout, and it is not meant to be a long-lived record that can handle complex payment flows.

Payafter Cart Completion Flow

By calling the cart completion API route, the backend will accept unpaid orders and will not require payment authorization at the time of order creation.

Configuration

Specify the payment providers that should use the payafter flow:

medusa-config.ts

module.exports = defineConfig({
    /* ... */
    modules: [
        {
            resolve: "medusa-essentials/modules/payafter",
            options: {
                payment_providers: ["pp_tpay"] // list of payment provider IDs that should use the payafter flow
            }
        }
    ]
})