Create a betting platform
Number of APIs: 5
Introduction
The Betting collection is a group of Paystack APIs that you should use to build products in the betting industry. The goal of betting companies is to allow customers to place bets and successfully withdraw their winnings.
Prerequisites
- Sign up on Paystack and retrieve your test Secret API Key. (see guide for more)
- Setup your API key as a collection variable on Qodex
- Checkout our Developer Docs and API Reference for detailed explanations
Getting Started
We’re going to assume you’ve already signed up on Paystack
Adding the collection to your Qodex
Go to the [Paystack’s public workspace] on Qodex and fork the collection you’re interested in testing.
Give your collection a memorable label to differentiate it from the original collection and add it to your preferred workspace. Checking the “Watch original collection” option allows your collection to get updated as we update the collection.
After importing it, you should see it in your collections sidebar with the label you provided.
Import collection from Github
If you’d like to use a different API testing tool, you can clone or fork the Paystack Open API repository from Github and use the files in the use_cases
folder.
Setting up your API keys
Once you’ve setup your Paystack account, get your test secret key and add it as a [collection variable] on the Variables tab on Qodex.
Switch to the Authorization tab and clear the Token field and use two curly braces and enter the variable name you setup.
The value of secret_key
should appear when you hover your mouse on the variable as shown below.
If everything looks good, save your changes and you’re ready to explore the collection!
Using the collection
Each endpoint in the collection has example request data and responses. The responses show you how the API responds in different scenarios.
Initialize Transaction
The Initialize Transaction endpoint returns an authorization_url
where your users will load our Checkout for them to make payment. The required parameters are email and amount. All amounts in the API are in the lowest currency unit (i.e. Kobo for Naira, Pesewas for Cedis, and, Cents for USD and Rand).
You should open the authorization_url
in your browser to load the checkout and complete the transaction.
For this usecase, you should complete the transaction using the Card payment channel. Cards are the channel that currently supports Recurring Charges.
Charge Authorization
The Charge Authorization endpoint works with cards only. You’ll use this endpoint to charge customers cards without them entering their card details again. This means that a customer must have successfully completed a first transaction before you can use this API to charge them.
The authorization_code
is found in the authorization
object in the Verify Transaction endpoint.
The information in the authorization object can be used to show user friendly card details on your frontend.
To use this API successfully, you should use the email from the first transaction above, the authorization_code
and amount to charge. Now this customer doesn’t have to enter their card details whenever they want to place a bet. If a user wants to add another card, you’ll use the Initialize transaction API again and then store the user’s email and the authorization_code
.
Resolve Account Number
This API is available for businesses in Ghana and Nigeria. South Africa based businesses should use the Validate Account endpoint.
Use this endpoint to ensure the customer has provided correct account details to receive their winnings.
To get the bank_code
, use the List Banks endpoint. You can use the data here to display the bank names for the customer to choose from.
Create Transfer Recipient
After successfully resolving the account number, you can use those details to create a transfer recipient. There’re different types of recipients depending on the currency. You can checkout our documentation here.
Initiate Bulk Transfer
The best way to send your customers their winnings is by using the Bulk Transfer api. This is because it allows you to send multiple payouts with one API call. You’ll then receive webhook events for each transfer.
-
Resolve Account Number GET {{baseUrl}}/bank/resolve?account_number=51605246&bank_code=51
-
Create Transfer Recipient POST {{baseUrl}}/transferrecipient
-
Initiate Bulk Transfer POST {{baseUrl}}/transfer/bulk
-
transaction - Charge Authorization POST {{baseUrl}}/transaction/charge_authorization
-
transaction - Initialize Transaction POST {{baseUrl}}/transaction/initialize