Skip to main content

Checkout

Checkout

Give your users the option of making payments to your e-commerce store directly from their wallets on businesses we have in our ecosystem.

How Checkout Works

Prerequisites

  1. Create a Thepeer account.
  2. Navigate to the Settings page and click Preferences on the tab menu.
  3. Check the Checkout option on your Thepeer dashboard. In the Accept payments via section, click Checkout to be able to receive payments via the Checkout API.
Screenshot of Thepeer's settings page with checkout options enabled

Checking the Checkout option in the Process payments via section gives your users the option of making payments from their wallets on your business to e-commerce stores that have integrated the Checkout API.


Initiate Checkout

You can make use of Thepeer’s Checkout via any of Thepeer’s libraries. Find your preferred library on the libraries page.


Load Thepeer via CDN

Thepeer needs to be available on your app before you can make use of its APIs.

    <script type="application/javascript" src="https://cdn.thepeer.co/v1/chain.js"></script>

Instantiate Thepeer’s Checkout

Here, you create a checkout object containing details necessary for the transaction like amount, currency, and so on.


Checkout
<button onclick="checkout()">Checkout</button>
<script
type="application/javascript"
src="https://cdn.thepeer.co/v1/chain.js"
></script>
<script type="application/javascript">
function checkout() {
const checkout = new Thepeer.Checkout({
currency: "NGN",
amount: 480000,
email: "CUSTOMER_EMAIL",
publicKey: "YOUR_PUBLIC_KEY",
onSuccess(response) {
console.log(response.event);
},
onError(error) {
console.log(error);
},
onClose(event) {
console.log("User closed the widget ->", { event });
},
});
checkout.setup();
checkout.open();
}
</script>

Parameters

Parameter nameDescriptionRequiredData type
currencyThe currency the transaction should be carried out in. The supported value is NGN.falseString
amountThe amount you are debiting the customer. This should be in kobo. The minimum value is 10000trueNumber
emailThe customer’s email addresstrueString
publicKeyThe public key generated for your Thepeer account. You can retrieve this from Settings > API Keys & Webhooks on your dashboard.trueString
onSuccessA callback function that Thepeer calls after a successful charge transaction.trueFunction
onErrorA callback function that Thepeer calls after a failed charge transaction.trueFunction
onCloseA callback function that Thepeer calls after the user closes the payment modal.trueFunction
metaAn object containing additional attributes you will like to have in your transaction response.falseObject

After creating an instance of Thepeer’s Checkout with the details to be used for the transaction, like for the Direct Charge API, you will need to call its setup() method. The setup() method sends the details of the transaction to Thepeer and Thepeer, in turn, gets the transaction ready for your user to proceed with.


The Checkout instance’s open() method is what brings up the modal for your customer to proceed with the transaction.