medusa-payment-cod
v1.0.0
Published
Cash on Delivery payment provider for Medusa v2 — essential for Indian e-commerce
Maintainers
Readme
medusa-payment-cod
Cash on Delivery (COD) payment provider for Medusa v2 — essential for Indian e-commerce where 60%+ orders are COD.
Features
- Instantly authorizes orders (no external API calls)
- Configurable COD fee (default: ₹50)
- Capture triggered on delivery confirmation (via fulfillment webhook)
- Graceful cancellation (no money moved)
- Works with any fulfillment provider (Shiprocket, Delhivery, manual)
Installation
npm install medusa-payment-codConfiguration
Add to your medusa-config.ts:
module.exports = defineConfig({
// ...
modules: [
{
resolve: "@medusajs/payment",
options: {
providers: [
{
resolve: "medusa-payment-cod",
id: "cod",
options: {},
},
],
},
},
],
})No environment variables required.
How It Works
| Method | Action |
|--------|--------|
| initiatePayment | Returns authorized status immediately |
| authorizePayment | Auto-authorized (customer commits to pay on delivery) |
| capturePayment | Called when delivery is confirmed |
| refundPayment | Records refund (processed offline via bank transfer) |
| cancelPayment | No-op (no money was collected) |
Storefront Integration
Show COD as a payment option at checkout. When selected, the order is placed immediately — no payment modal or redirect needed.
// No special integration required
// Just call cart.complete() after selecting COD
await sdk.store.cart.complete(cartId)COD Fee
The provider stores a cod_fee_paise field in session data (default: 5000 = ₹50). Display this in your checkout summary UI. The fee is informational — add it to your cart total display logic in the storefront.
Triggering Capture on Delivery
When your fulfillment provider confirms delivery (e.g., Shiprocket "delivered" webhook), call capturePayment on the order's payment to mark it as collected:
// In your shipment-delivered subscriber:
const paymentService = container.resolve(Modules.PAYMENT)
await paymentService.capturePayment({ payment_session_id: session.id })License
MIT
