Payments
How cash on delivery, Stripe, and platform billing work.
Prolifto supports cash on delivery and Stripe for store orders. Polar is used for platform subscription billing, not for storefront checkout.
Cash on delivery
Cash on delivery (COD) is the default for the Algerian market and the only payment method currently offered by the storefront checkout UI.
Flow:
- The customer places an order. A payment row is created with provider
CASH_ON_DELIVERYand statusPENDING. - The order starts as Pending and is usually confirmed by phone.
- When cash is collected, an admin records the COD payment.
- Recording payment marks the payment succeeded, marks the order paid, locks the invoice as Paid, and creates a receipt.
The order status does not change when payment is recorded. Fulfilment and payment are separate.
Stripe
Stripe is supported by the payment layer and the API. The storefront checkout
currently submits CASH_ON_DELIVERY; Stripe is available for admin-created
orders and API integrations when STRIPE_ENABLED="true".
The Stripe provider:
- Creates a payment intent for the order amount in the smallest currency unit.
- Returns a client secret and provider payment ID.
- Verifies
payment_intent.succeededandpayment_intent.payment_failedwebhooks. - Marks the payment succeeded or failed and records the provider payment ID.
There is no Stripe refund API call in the current codebase. A return records the refund and updates internal status, but a gateway refund must be issued through Stripe's dashboard or an integration you add.
Required environment variables:
STRIPE_ENABLED="true"
STRIPE_SECRET_KEY="sk_live_..."
STRIPE_WEBHOOK_SECRET="whsec_..."
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY="pk_live_..."Keys are only required when STRIPE_ENABLED="true".
Payment confirmation
confirmPayment is the shared service behind COD payments and Stripe
confirmation. It:
- Marks the payment succeeded.
- Marks the order paid and sets
paidAt. - Links the payment to the invoice, sets
issuedAtandlockedAt, and marks the invoice Paid. - Creates a
CHARGEtransaction. - Creates a receipt for the transaction if one does not already exist.
- For Stripe, transitions the order to Confirmed.
The receipt is idempotent per transaction, so confirming twice does not create a duplicate.
Returns and refunds
Returns are handled by the order return service:
- Records a return reason, notes, and optional carrier fee.
- Restores stock when Restock items is enabled.
- Records the refund amount and method.
- For a full paid refund, marks the invoice and successful payments Refunded.
- Leaves unpaid orders with no refund due and voids the unpaid invoice.
Refund methods: cash, bank transfer, store credit, gateway, or none. For gateway refunds, see the Stripe note above.
Platform billing
Store subscriptions and platform invoices use Polar:
POLAR_ENABLED,POLAR_ACCESS_TOKEN,POLAR_WEBHOOK_SECRET, andPOLAR_SUCCESS_URL.- Polar webhooks are verified with an HMAC signature using the webhook secret.
- Subscription lifecycle jobs handle renewals and grace periods.
Platform billing is separate from storefront orders. See Settings → Plan and billing.