Repository navigation
feat: support Paystack restricted keys and webhook signing secrets - #26
Merged
Merged
Conversation
The webhook payload's amount and currency are no longer trusted on their own; the transaction is fetched from transaction/verify and its status, id, amount and currency must match before the entry is completed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GF_Paystack_Keys classifies sk_/rk_ keys, decides what a settings save needs (probe, wrong field, bad shape, missing or duplicated signing secret), exposes the gform_paystack_restricted_keys_enabled switch and redacts keys and whsec_ secrets from log text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g it GF_Paystack_Restricted_Key probes the key in sequence (ported from the BigCommerce validator, without the ident call): it must hold Transactions read and write and none of the money-moving scopes. Anything other than an exact scope refusal fails closed. probe_plans() checks Plans: write for subscription feeds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When a mode has a whsec_ signing secret, Paystack-Signature (HMAC-SHA512 of "<t>.<body>", 5-minute window, any v1 entry) decides alone, so a delivery can't be downgraded to the untimed legacy header. Without one, the legacy X-Paystack-Signature check runs only for a stored sk_; a restricted key is never used as an HMAC key. Keys for verification are read straight from settings, and an event with no data.domain is verified under each configured mode instead of the global one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every plugin log line goes through GF_Paystack_Keys::redact(), and an API call refused for a missing restricted-key scope logs "rk scope denied method=… path=…" so support can see which permission is missing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Test/Live secret key fields accept sk_ or rk_ keys and become password inputs, with new Test/Live webhook signing secret fields beside them. Saving a changed restricted key checks its permissions with Paystack, a restricted key requires its mode's signing secret, and credential fields are stored trimmed. Saving a subscription feed whose mode uses a restricted key checks Plans: write. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Redaction no longer stops at characters a restricted key may contain, a filter can't smuggle a second Authorization header into a probe, test and live probes share one time budget per request, and scope labels live in the probe table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A verify call that throws during charge.success answers 500 so Paystack retries; both branches now require the verified id and reference to match. - An event without data.domain only tries modes with a signing secret, and otherwise keeps the original api_mode fallback; failures log every attempt. - The admin ?secret=/?public= URL override no longer reaches Paystack calls. - Signing-secret fields validate themselves; switching a mode to a restricted key also checks Plans: write when that mode has active subscription feeds; subscription feeds are only re-probed when their type or mode changes, and keep Gravity Forms' own transaction type check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pins the full probe table, every classifier status, transport failures, redaction of every error_log line, per-field validation callbacks and the regressions fixed in the diff review. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A domainless webhook also tries the site's API mode after the signing-secret modes, so an sk merchant with a secret in only one mode keeps webhooks. - Restricted-key characters and the log redactor's stop characters no longer overlap; a failed verify answers with a fixed message. - The plans check covers inactive subscription feeds, resolves feeds without a mode like checkout does, and its settings-page copy fits that page. - The probe time budget renews in long-lived processes; header names are trimmed before the Authorization strip; chained feed callbacks get all args. - Changelog notes the removed ?secret=/?public= override. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lpers No behaviour change: shared helpers for the other mode, save errors and stored settings; webhook candidate modes in their own method; one request default and verdict builder in the probe class; a cheaper log redactor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… time New or changed keys must be rk_ keys; an sk_ key saved by an earlier version keeps working until it is replaced. The public key fields are gone (payments never used them). Test and Live fields show only for the selected mode, so credentials are validated from the Mode field for both modes: Gravity Forms skips validation of fields a dependency hides but still saves their values. Requires Gravity Forms 2.5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Permissions can change in the Paystack Dashboard without the key changing, so a kept rk_ key is probed again whenever settings are saved. A definite refusal blocks the save; an unreachable Paystack does not block a key that was already accepted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gravity Forms 2.5+ takes the settings field object by reference in set_field_error(). Passing an array crashed every refused save with a fatal error on PHP 8, including the existing custom-metadata checks on feeds. Errors now go through set_setting_error(), which looks the field up through the settings renderer and falls back to the field being validated. The test stubs now follow the same contract. Found by testing against real Gravity Forms 2.7. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Credential errors had no fallback: if Gravity Forms couldn't find the named field, the error was lost and a refused key would save. While validate_credentials() runs, errors now fall back to the Mode field, and an error with nowhere to go is logged. Scope labels in key errors are escaped, since Gravity Forms prints field errors as HTML. Tests: the stub set_field_error() now throws on anything Gravity Forms would ignore, the fixture renderer only finds the add-on's defined fields, and the fallback paths are covered. Note on f37a492: the array argument crashed on every supported PHP version (7.2+), not only PHP 8. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jules-paystack
marked this pull request as ready for review
November 23, 2026 12:58
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jules-paystack
requested review from
lukman-paystack,
oluwasemilore-ps and
samuel-ps
November 23, 2026 13:11
lukman-paystack
approved these changes
Nov 24, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Paystack restricted-key support to the Gravity Forms add-on, following the pattern in the Shopify, Ecwid and BigCommerce plugins. Releases as 2.0.10.
What changes for merchants
rk_test_…/rk_live_…), and new or changed keys must be restricted keys. The settings page no longer mentions secret keys.whsec_…), and a restricted key requires it. Once a mode has a signing secret, onlyPaystack-Signaturewebhooks are accepted for that mode.charge.successwebhook is now confirmed with Paystack (transaction/verify) before an entry is marked paid. If that check can't reach Paystack, the plugin returns HTTP 500 so Paystack retries.?secret=/?public=URL override for API keys has been removed.Existing merchants need to do nothing. Saved settings carry over unchanged. A site on an
sk_key keeps working, and can re-save its settings without a signing secret or a permission check. Only when the key is replaced must the new key be a restricted key with its signing secret; there is no switching back.Commits
readme.txtexplains restricted keys, signing secrets and the webhook events the plugin needs.README.mdhas the new settings screenshot and requires Gravity Forms 2.5.How it was checked
php tests/run.phppasses all 434 checks on PHP 8.5 and 7.2. An earlier mutation run (at 406 tests) showed the tests catch 188 of 200 deliberate breakages. Every PHP file also passesphp -lon 7.2, andgit archiveships the newincludes/files.charge.successmarks the entry Paid, a repeat changes nothing, and a secondv1signature (rotation) is accepted.sk_key, no signing secret) still completes payments and re-saves its settings with no extra calls. Switching it to a restricted key and signing secret then works.f37a492,ff0d80c).plans:writeprobe passes), and an invalid value shows a field error.charge.successmarks the entry Paid and adds the note and notification. A replay is ignored. A Paystack outage returns 500. Bad, stale or unpaid webhooks are refused.charge.successsaves the authorization code,subscription.createmarks the entry Active and records the payment, andsubscription.disable(after a real cancellation at Paystack) marks it Cancelled with a note. Replays are ignored.Release steps (after approval)
readme.txtto the release day, then merge.v2.0.10frommain. That release triggers the WordPress.org deploy, which checks the tag against the version header,GF_PAYSTACK_VERSIONand the Stable tag.Not in this PR
main: Feed's customer first/last name mapping is never sent to Paystack #27 (customer names never sent), Feed's Phone and Recurring Times mappings are ignored #28 (Phone and Recurring Times mappings ignored), and a warning noted on Subscription webhook and return-flow bugs (pre-existing) #23.Risks
charge.successnow makes one extra Paystack API call per payment.sk_site, it becomes the only accepted webhook signature for that mode. A wrong secret stops webhooks until it's fixed.🤖 Generated with Claude Code