Skip to content

fix: use test Paystack credentials for is_test service products#94

Merged
musale merged 1 commit into
mainfrom
fix/payment-tests
May 19, 2026
Merged

fix: use test Paystack credentials for is_test service products#94
musale merged 1 commit into
mainfrom
fix/payment-tests

Conversation

@musale

@musale musale commented May 19, 2026

Copy link
Copy Markdown
Contributor

Problem

The is_test flag on ServiceProduct existed but was completely ignored — all accounts (test and live) used the same single PAYSTACK_SECRET_KEY. Test service products were hitting live Paystack credentials.

Changes

  • Settings: Add PAYSTACK_TEST_SECRET_KEY and PAYSTACK_TEST_PUBLIC_KEY env vars alongside the existing live keys
  • services.py: get_paystack_secret_key(is_test=) and get_paystack_public_key(is_test=) now select the correct credential set; all Paystack API functions (initialise_transaction, verify_transaction, create_refund, fetch_transaction_details, _make_paystack_request) propagate the flag
  • validate_webhook_signature: Tries both keys so test and live Paystack webhooks are accepted at the same /payments/webhook/ endpoint
  • api_views.py: Passes request.service.is_test to initialise_transaction and create_refund
  • views.py: VerifyPaymentView passes payment.service.is_test when verifying
  • Docs: Note test mode behaviour in PRODUCT_PAYMENTS.md

Required env vars

Add to your .env:

PAYSTACK_TEST_SECRET_KEY=sk_test_...
PAYSTACK_TEST_PUBLIC_KEY=pk_test_...

- Add PAYSTACK_TEST_SECRET_KEY / PAYSTACK_TEST_PUBLIC_KEY settings
- Update get_paystack_secret_key/public_key to accept is_test flag
- All Paystack API functions (initialise, verify, refund, fetch) now
  propagate is_test to select the correct credential set
- validate_webhook_signature tries both keys so test and live webhooks
  are accepted at the same endpoint
- api_views passes request.service.is_test to every Paystack call
- VerifyPaymentView passes payment.service.is_test when verifying
- Document test mode behaviour in PRODUCT_PAYMENTS.md
@musale musale merged commit d999e66 into main May 19, 2026
2 checks passed
@musale musale deleted the fix/payment-tests branch May 19, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant