fix: use test Paystack credentials for is_test service products#94
Merged
Conversation
- 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
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.
Problem
The
is_testflag onServiceProductexisted but was completely ignored — all accounts (test and live) used the same singlePAYSTACK_SECRET_KEY. Test service products were hitting live Paystack credentials.Changes
PAYSTACK_TEST_SECRET_KEYandPAYSTACK_TEST_PUBLIC_KEYenv vars alongside the existing live keysservices.py:get_paystack_secret_key(is_test=)andget_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 flagvalidate_webhook_signature: Tries both keys so test and live Paystack webhooks are accepted at the same/payments/webhook/endpointapi_views.py: Passesrequest.service.is_testtoinitialise_transactionandcreate_refundviews.py:VerifyPaymentViewpassespayment.service.is_testwhen verifyingPRODUCT_PAYMENTS.mdRequired env vars
Add to your
.env: