Skip to content

Try a Paystack sandbox payment

Use a Paystack test account to open hosted checkout and verify a test payment from the command line. The sample uses the gateway adapter directly, so it needs no database. It builds against the PayBridge source in the checkout.

Set up

  1. Install the .NET 10 SDK.
  2. Clone the PayBridge repository.
  3. Set PAYSTACK_SECRET_KEY in your shell using the test secret key from your Paystack dashboard. The sample only accepts keys starting with sk_test_.

Create and verify a payment

From the repository root, start a test checkout for NGN 2,500.50:

dotnet run --project examples/PaystackSandbox -- create sandbox@example.com

Copy the transaction reference and open the checkout URL in your browser. Complete the checkout using one of Paystack's test payment methods. Then run:

dotnet run --project examples/PaystackSandbox -- verify YOUR_TRANSACTION_REFERENCE

The sample confirms that Paystack reports a successful payment for the expected amount and currency. In an application, keep the expected amount, currency and reference with the order, and verify them on the server before fulfilment.

Run the sandbox tests

To exercise checkout creation, leave PAYSTACK_SECRET_KEY set. To also test successful verification, set PAYSTACK_SUCCESSFUL_TRANSACTION_REFERENCE to the reference from a completed NGN sandbox checkout.

dotnet test PayBridge.SDK.Test/PayBridge.SDK.Test.csproj \
  --filter 'Category=Integration&FullyQualifiedName~PaystackIntegrationTests'

The tests skip when their required credentials or reference are absent. See the sandbox testing guide for the GitHub Actions setup and the webhook security guide before adding callbacks to an application.