payload-cod-adapter
v0.1.0
Published
Cash on Delivery payment adapter for PayloadCMS ecommerce plugin
Maintainers
Readme
payload-cod-adapter
Cash on Delivery (COD / Pouzeće) payment adapter for PayloadCMS ecommerce plugin.
Enables customers to pay upon delivery — no external payment gateway redirect needed. Orders are created directly with a configurable surcharge.
Features
- Full integration with
@payloadcms/plugin-ecommerce - No external API calls — orders created instantly
- Optional COD surcharge (flat fee)
- Complete pricing breakdown (subtotal, discount, shipping, surcharge, grandTotal)
- Address passthrough (billing + shipping) to orders
- TypeScript support with full type safety
Installation
npm install payload-cod-adapter
# or
pnpm add payload-cod-adapter
# or
yarn add payload-cod-adapterRequirements
- PayloadCMS 3.x
@payloadcms/plugin-ecommerce^3.60.0
Quick Start
Server Configuration
// payload.config.ts
import { buildConfig } from 'payload'
import { ecommercePlugin } from '@payloadcms/plugin-ecommerce'
import { codAdapter } from 'payload-cod-adapter'
export default buildConfig({
plugins: [
ecommercePlugin({
payments: {
paymentMethods: [
codAdapter({
label: 'Cash on Delivery',
surcharge: 200, // Optional: 200 cents = 2.00 surcharge
}),
],
},
}),
],
})Client Configuration
COD does not require a client adapter — no payment form is needed. The payment method appears as a selectable option in checkout automatically.
Configuration Options
| Option | Type | Default | Description |
| ----------- | -------- | -------------------- | ----------------------------------------- |
| label | string | 'Cash on Delivery' | Display label for the payment method |
| surcharge | number | 0 | COD surcharge in cents (e.g., 200 = 2.00) |
Payment Flow
- Customer selects COD at checkout
initiatePayment()called — creates transaction with statussucceeded- Order created immediately (no redirect, no webhook)
- Cart marked as purchased
- Customer receives order confirmation
Unlike card payment adapters, COD skips the external gateway entirely. The order is confirmed instantly.
Transaction Fields
The adapter adds a cod group field to transactions with:
surcharge- COD surcharge amount appliednote- Payment collection note
TypeScript
import { codAdapter } from 'payload-cod-adapter'
import type { CodAdapterArgs } from 'payload-cod-adapter'Changelog
0.1.0
- Initial release
- Full
@payloadcms/plugin-ecommercePaymentAdapter implementation - COD surcharge support
- Pricing breakdown passthrough
License
MIT
