Create an online marketplace

Number of APIs: 4

Introduction

The Marketplace collection is a group of Paystack APIs that you should use to build an online marketplace. An online marketplace allows third party vendors sell their goods and the platform receives a share of each sale. This process can be automated using Paystack.

Prerequisites

  1. Sign up on Paystack and retrieve your test Secret API Key. (see guide for more)
  2. Setup your API key as a collection variable on Qodex
  3. 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.

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.

APIs in this collection

Subaccount

Before accepting payments in the marketplace, you need to onboard vendors by creating subaccounts. The subaccount API is used to set up the bank account or mobile money account each vendor will receive their sales made less the platform fee. The subaccount will be automatically settled at the same schedule as the main account. You should ensure that the details provided are accurate using our Verification APIs.

Split API

Using the Split API, you can create fixed splits on transactions. This is best used when the split values are agreed upon before hand. It also allows a transaction to be shared among more parties. Once the split has been created, you can use it to initialize a transaction.

In cases where customers are able to buy from several vendors during checkout, the Dynamic split feature would work best. Essentially, it is initialising a transaction with a Split object with the shares for each subaccount. The subaccounts will be settled for free on the same schedule as the main account.

Initialize Transaction

Having setup subaccounts and transaction splits, we’re now able to initialize transactions depending on the various sale share agreements we have.

Refunds

Marketplaces have to factor in refunds in cases where customers aren’t satisfied with the product or service. Our Refunds API allows you to create transaction refunds either partially or fully and Paystack will refund the customer.

  1. Create Subaccount POST {{baseUrl}}/subaccount

  2. Create Split POST {{baseUrl}}/split

  3. Initialize Transaction POST {{baseUrl}}/transaction/initialize

  4. Create Refund POST {{baseUrl}}/refund