Repository navigation
Conversation
cavewebs
left a comment
There was a problem hiding this comment.
HMAC is done the way we asked: SHA-512 of the raw body, Web Crypto, constant-time compare, both Paystack-Signature (whsec_, 300 second window) and x-paystack-signature (sk_). When the current header and a whsec_ secret are present, a stale replay cannot sneak through on the legacy header. Amounts come from the cart, then /transaction/verify, then core's reconcile. ctx.http.fetch only, host api.paystack.co. No extra npm deps. Keeping this as its own package, not inside core, is right.
Please set providerEventId on refund events. You already have data.id. Empty string skips core's event dedup, and two refund.failed deliveries can both reverse the order (#82's pending check is not a lock). Something like refund.failed:19244346 is enough. For charge.success, core's unique index on the payment reference still stops a second order. Now that #81 drops the dedup row on ConfirmationFailure, you could also set charge.success:${reference} so a retry after a down verify still works, and two overlapping deliveries do not both run the handler.
README says the package is private and not published. package.json is public 0.0.0 with a minor changeset. If we merge as-is, the next release will publish @dashcommerce/paystack. Either add "private": true until you mean to ship it, or say in the README that 0.1.0 goes out with this core.
Webhook URL: tell merchants to append ?provider=paystack so a future header clash cannot depend on registry order. stripe-signature already wins for Stripe.
A PaymentProvider for Paystack on core's provider interface: card and M-Pesa through Paystack's hosted page or its Popup over the store's own checkout. - Orders come only from a signed charge.success, confirmed with /transaction/verify. Both signature schemes are checked with the key each is signed with: Paystack-Signature with a whsec_ secret (final when present, so its 300-second replay window holds) and x-paystack-signature with the sk_ key. In a real test-mode run Paystack sent only x-paystack-signature on an account with a whsec_ secret, so both matter. - Refunds by transaction reference, tagged with core's refundRequestId so a retry returns the existing refund instead of creating a second one; refund.* webhooks (which carry the refund id as a string) map to refund.updated. - A payment refunded in full at Paystack before its order exists is not confirmed, so a late webhook retry creates no order. Paystack reports reversed after partial refunds too, so the refunded total decides. - "Test Paystack connection" checks the saved key, test or live. - The Popup client (./checkout-client) loads js.paystack.co only when the customer presses Pay. Tested end to end in Paystack test mode: hosted and Popup, card and M-Pesa, declined cards, duplicate and stale webhooks, refunds that succeed and fail.
….4.0 - Set providerEventId on refund.* events (`<event>:<refund id>`), so two refund.failed deliveries reverse a refund once, and on charge.success (`charge.success:<reference>`), so overlapping deliveries run once. Core still releases the record when confirming with Paystack fails. - Peer @dashcommerce/core ^0.4.0 instead of workspace:*, which made changesets version this package 1.0.0. It now releases as 0.1.0. - README: needs core 0.4.0, install step, why ?provider=paystack, removed the pre-merge core requirements section. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dc2f9e0 to
fadc0ef
Compare
|
Thanks for the review. All three points are in fadc0ef, on top of the branch rebased onto main (after #90). Event ids. Refund events now carry
The existing test where verify is down on the first delivery still passes: Tested by hand against Paystack test mode (24 Nov, this branch, EmDash 1.6, webhooks through a tunnel with
Publishing. It ships. The README says 0.1.0 goes out with core 0.4.0. I also changed the peer from Webhook URL. The setup step now says to include Also on the earlier PRs: noted on #84 that |
|
The follow-ups from this review round are up, so they're ready when you finish here. Each is small, tested and has a changeset. Any order, independent of #85:
After #85:
At the 0.4.0 / 0.1.0 release:
For discussion only, no action needed now:
|
|
Heads-up for the Paystack package, since subscriptions are the next item in #108: Core now has a provider-neutral subscription seam in #114 (open, independent). It adds optional #85 currently declares No action needed if it is out of scope — just flagging it so the seam is there when you get to the "Subscriptions with Paystack" item. Happy to share the Flutterwave adapter details if useful. |
|
@cavewebs the three points from your review are in fadc0ef (details in my comment above), so I'm re-requesting your review. CI is green and the branch merges cleanly with main. @alexasomba thanks for the pointer to #114. I'll keep subscriptions out of this PR so it stays small. Paystack Plans fit #114 well, as you say, so Paystack subscriptions will build on it once it lands. They're listed in #108. |
[FIK-57] feat(paystack): Paystack payment provider package (fork integration of upstream emdashCommerce#85)
Part of the Paystack set described in #76. Builds on #84.
What
packages/paystack: aPaymentProviderfor Paystack on core's provider interface. It covers card and M-Pesa, through Paystack's hosted page or its Popup over the store's checkout, in KES, NGN, GHS, ZAR and USD. It registers itself onimport "@dashcommerce/paystack". The README covers setup:allowedHosts: ["api.paystack.co"], keys, webhook URL and the Popup client.How it behaves
charge.success, confirmed with/transaction/verifybefore core writes the order. Paystack sends nocharge.failed, so a failed or abandoned payment leaves no order.Paystack-Signaturewith awhsec_secret. When it's present, it alone decides, so its 300-second replay window can't be sidestepped by the older header sent with it.x-paystack-signature, with ansk_key saved in either field.x-paystack-signature, on an account with awhsec_secret, so both paths matter.refundRequestId, so a retry returns the existing refund instead of creating a second one. Paystack itself accepts identical duplicates.refund.*webhooks map torefund.updated. Real ones carry the refundidas a string; Paystack's docs don't show it.reversedafter partial refunds too, so for areversedorreversal-pendingpayment the package adds up its refunds. One refunded in full is not confirmed, so a latecharge.successretry creates no order; a partly refunded one is../checkout-clientloadsjs.paystack.coonly when the customer presses Pay.Package
publishConfig.access: public, author "DashCommerce contributors". Minor changeset takes it to 0.1.0.bun.lockgains only the new workspace entry.Tests
Paystack-Signaturethat must not fall back.End to end in Paystack test mode (20 Nov 2026)
whsec_saved, onlyx-paystack-signaturesentduplicate, one order / 400 outside the windowrefund.pending→refund.processed(succeeded) andrefund.failed(failed)Screenshots