Skip to main content

Payment Customization Functions

A payment_customization function modifies the merchant’s payment-method list before it renders at checkout. Use it to hide a method conditionally (e.g. block COD for high-value orders), rename one for clarity, or pin a preferred method to the top of the radio list. Runs at both cart verification (preview) and order placement (enforcement) so a stale frontend can’t bypass a hide op — the backend rejects the order if a hidden method is submitted.

How It Works

Function Manifest

Input Schema

price and totalPrice are in display currency units, not cents. totalPrice: 599.99 means ₹599.99 / $599.99.The input is minimal — no tags, productType, or vendor is passed. customer is passed on the order-placement dispatch (addClientOrder) but not on the cart-verification dispatch, so don’t rely on it for preview-time rules. If your rules need richer data, look the customer up via your own backend using the customer email from the verify-cart payload (which your app receives via the App Bridge).

Output Schema

Either paymentMethod (the provider key like "cod") or paymentMethodId (the UUID) works for all ops. The backend matches against both. On a move op, index is accepted as an alias for position (either field works).
reorder is accepted as an alias for move — both produce the same result. New code should use move.

Operations

hide

Removes the method from the radio list (preview) and rejects the order if the customer submits it.
The order-place error message is: "Payment method 'cod' is not available for this order"

rename

Overrides the displayed name. The underlying provider key is unchanged — charging behaviour is identical, only the radio label is different.
On the frontend the renamed plan carries __renamed: true so the checkout payment list displays methodName instead of the provider’s built-in label.

move

Sets the index of the method in the radio list. Lower positions render first.

Examples

Hide COD for high-value orders

Region-based methods

Rename for clarity, pin preferred

How it renders in the UI

The checkout reads:
  • paymentMethods in the verified-cart response — filtered list (after hide)
  • Each plan carries __renamed: true + methodName when a rename op fired.

Best Practices

The backend doesn’t auto-recover — if all methods are hidden, the customer literally can’t pay. Always leave at least one method available for any reachable cart state.
Provider UUIDs differ per store. paymentMethod: 'cod' is portable across installs; paymentMethodId: '<uuid>' is not.
Drive /checkout with Puppeteer and screenshot the payment radio. JSON-only tests don’t catch the __renamed flag wiring; only the rendered label does.
Functions re-run on every cart change. Always derive ops from the current cart + config, not from cached state.

See Also