Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/payment-provider-client-is-public.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@dashcommerce/core": patch
---

Docs: an on-page checkout's `client` data is public. `create-session` sends it to the browser, so provider authors must never put a secret key or webhook secret in it.
1 change: 1 addition & 0 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ For provider authors, `PaymentProvider` can declare:

- `credentialFields`: the label, accepted prefixes and help text for the settings form.
- `webhookHeaders`: the headers that identify its webhooks, besides `x-<id>-signature`. `verifyWebhook` receives every request header, and `credentials` (the provider's saved secret key and webhook secret) for headers signed with the API key rather than the webhook secret.
- `checkoutStyles`: `["hosted", "on_page"]` to offer checkout over the store's page. `initCheckout` then returns `{ kind: "on_page", client }`, and the storefront hands `client` to the provider's browser client. `client` is public: `create-session` sends it to the browser as JSON, so put only what the browser needs in it (Paystack sends `{ accessCode }`), never a secret key or webhook secret.
- `checkConnection`: one read-only call with the saved keys, behind a "Test connection" button in Settings. Return `{ ok, message }`, with `ok: false` and a message the merchant can act on for a wrong or under-permitted key.

`parseWebhookEvent` may return `refund.updated` to move a pending refund to `succeeded` or `failed`. A failed refund stops counting against its order: the refunded total, payment status and order status are worked out again, and stock the refund put back is taken back off.
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/payment-provider/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ export type InitCheckoutResult =
* Pay over the store's page. `client` is handed to the provider's
* browser client (see the package's checkout-client entry), e.g.
* Paystack's `{ accessCode }`. Never trusted as proof of payment.
* Public: `create-session` sends it to the browser as JSON, so
* never put a secret key or webhook secret in it.
*/
kind: "on_page";
checkoutReference: string;
Expand Down
Loading