Checkout

Checkout is a simple, secure and fast way to provide your customers with a seamless checkout experience. It is a hosted payment page that is easy to integrate with your website or application.

Checkout uses a session-based approach to handle payments. This means that you first create a checkout session and then redirect your customer to the checkout page. The checkout page will then use the session to process the payment.

Integration guide

To integrate Checkout with your website, you need the following:

  • Paypack account
  • Paypack application
  • Register your checkout page

Paypack account

To create a Paypack account, visit the Paypack website and click on the Get Started button. You will be redirected to the sign up page where you will be asked to provide your email address and a password. Once you have provided the required information, click on the Register button to create your account.

Paypack application

To create a Paypack application, navigate to the applications tab and click on the Create Application button. You will be asked to provide a name for your application and a description. Once you have provided the required information, click on the Create button to create your application.

Register your checkout page

Once you have created your Paypack application, you need to register your checkout page. To do this, click on the configure button on the application row. You will be redirected to the application configuration page where you will be asked to provide details regarding your checkout. Once you have provided the required information, click on the Save button to save your changes.

Creating a checkout session

To create a checkout session, you need to make a POST request to the following endpoint:

Endpoint

https://checkout.paypack.rw/api/checkouts/initiate

Request Headers

FieldTypeDescription
Acceptstringapplication/json
Content-Typestringapplication/json

Body

FieldTypeDescription
itemsarrayAn array of items to be purchased.
app_idstringThe application key.
emailstringThe customer's email address.

Example

cURL
curl --location --request POST 'https://checkout.paypack.rw/api/checkouts/initiate' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-raw '{
  "items": [ { "name": "T-shirt", "price": 1000, "quantity": 1 } ],
  "app_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxx",
  "email": "mail@mail.com"
}'
Go
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://paypack-checkout.fly.dev/api/checkouts/initiate"
  method := "POST"

  payload := strings.NewReader(`{
    "items": [{
        "name": "T-shirt",
        "price": 1000,
        "quantity": 1
    }],
    "app_id": "xxx-xxx-xxx-xxx-xxx",
    "email": "mail@mail.com"
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
JavaScript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://paypack-checkout.fly.dev/api/checkouts/initiate',
  'headers': {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "items": [{
        "name": "T-shirt",
        "price": 1000,
        "quantity": 1
    }],
    "app_id": "xxx-xxx-xxx-xxx-xxx",
    "email": "mail@mail.com"
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
PHP
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://paypack-checkout.fly.dev/api/checkouts/initiate',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "items": [{
        "name": "T-shirt",
        "price": 1000,
        "quantity": 1
    }],
    "app_id": "xxx-xxx-xxx-xxx-xxx",
    "email": "mail@mail.com"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
Python
import requests
import json

url = "https://paypack-checkout.fly.dev/api/checkouts/initiate"

payload = json.dumps({
  "items": [{
        "name": "T-shirt",
        "price": 1000,
        "quantity": 1
    }],
  "app_id": "xxx-xxx-xxx-xxx-xxx",
  "email": "mail@mail.com"
})
headers = {
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Response

FieldTypeDescription
session_idstringThe checkout session id.
amountintThe total amount to be paid.
kindstringThe kind of session you have created session:created,session:commited,session:processed
payment_linkstringThe payment link to redirect the customer to.
created_atstringThe date and time the session was created.

Process a checkout session

To process a checkout session, you need to support webhooks to receive the session:processed event. This event is triggered when the customer has completed or cancelled the payment process. You can then process the payment and update the order status.

To learn more about webhooks, please refer to the webhooks documentation.

Troubleshooting

Phone number is not found

When you have an unverified account, you are allowed to use no more than 3 phone numbers which are registered to your account. To resolve this issue, you need to register the phone number to your account by navigating to the Approved numbers tab. You can also verify your account to be able to use any phone number.