Checkout

1. Create Session.

First you need to create a session from your backend using the API key generated through the dashboard, a session must have one of two types, add_card or payment.

Add Card

the add_card session is used to store a customer card, a unique customerId is required for add_card session type, while creating a new session, using this Id, you can get the corresponding customer cards when calling the getSession() method in the SDK

Request

curl --location --request POST 'https://sandbox.nearpay.io/checkout/sessions' \
--header 'Authorization: RoD43N1tjJs221nM37LR72Kf7IHG3uDYJAF4pu2HlrBkj9oxGdiUBO1sBGYN' \
--header 'Content-Type: application/json' \
--data-raw '{
    "type": "add_card",
    "customer": {
        "id": "${UUID}",
        "name": "", // optional
        "email": "", // optional
        "mobile": "+966XXXXXXXXX" // optional
    }
}'

Response

2. Install SDK.

Install the payment SDK using either npm or yarn

3. PaymentSDK.

Using the SDK, you can use a previously created session to add cards, create payments and fetch previous payments as well.

List Cards

You can list the cards associated with the customer_id, you can get details about your current session and the cards associated to the customer that owns the session by calling the getSession() method, this method will return a list of saved customer cards along with the session details

Request:

Session Object:

Last updated