Skip to main content
Version: v1

Checkout

The header redirects the user to PayJustNow where the checkout process is completed. The merchant will be notified of a success or failure using the provided urls: success_callback_url or fail_callback_url.

For successful orders, the following query parameters are attached to success_callback_url: ?token=xyz&status=SUCCESS.

For failed orders, the following query parameters are attached to fail_callback_url: ?token=xyz&status=FAIL&reason=CANCELLED.

In the case where an order has expired (considered abandoned), the fail callback above will send reason=ABANDONED instead of CANCELLED to allow the merchant to action accordingly.

URL#

POST https://sandbox.payjustnow.com/api/v1/merchant/checkout

Request#

{    "customer": {        "first_name": "John",        "last_name": "Doe",        "email": "[email protected]",        "mobile_number": "+27831234567",        "address": {            "address_line_1": "123 Some street",            "address_line_2": "Concorse Singel",            "city": "Johannesburg",            "province": "Gauteng",            "postal_code": 1611        }    },    "order": {        "amount": 10000,        "merchant_reference": "checkout112233",        "success_callback_url": "https://myshop.com/order-success",        "fail_callback_url": "https://myshop.com/order-fail",        "expires_at" : "2022-04-13 15:36:00",        "items": {            "1": {                "merchant_reference": "Shirt",                "quantity": 1,                "description": "Blue Striped Shirt",                "unit_price": 5000            },            "2": {                "merchant_reference": "Pants",                "quantity": 1,                "description": "Navy Pants",                "unit_price": 5000            }        }    }}

Request Data Validation#

NameDesciptionFormatExample
customer.first_nameCustomer First Namestring required"John"
customer.last_nameCustomer Last Namestring required"Doe"
customer.emailCustomer Email Addressstring required"[email protected]"
customer.mobile_numberCustomer Mobile Numberstring required"+27841112233" (Formatted to E164)
customer.address.address_line_1Customer Address Line 1string required"123 Some street"
customer.address.cityCustomer Citystring required"Johannesburg"
customer.address.provinceCustomer Postal Codestring required"Gauteng"
customer.address.postal_codeCustomer Postal Codeinteger required1611
order.amountOrder Amountinteger required10000 (In Cents)
order.merchant_referenceMerchant Referencestring required"checkout112233"
order.success_callback_urlRedirect URL on successstring required"https://myshop.com/order-success"
order.fail_callback_urlRedirect URL on failurestring required"https://myshop.com/order-fail"
order.expires_atDate and time till when the order will be valid for checkout (Defaults to 60min)string Date Time"2022-04-13 15:36:00"
order.items.*.merchant_referenceOrder Item Referencestring required"Shirt"
order.items.*.quantityOrder Item Quantityinteger required1
order.items.*.descriptionOrder Item Descriptionstring required"Blue Striped Shirt"
order.items.*.unit_priceOrder Item Descriptioninteger required5000 (In Cents)

Response#

{    "data": {        "token": "ad8c487e4f16a00d142db025fb2158f4",        "expires_at": "2022-02-07 13:32:26",        "redirect_to": "https://sandbox-pwa.payjustnow.com/checkout/4zbqj62dpr?exists=1"    }}

Return data for callback_url#

info

success_callback_url/fail_callback_url must return a json response containing the following information:

[    'token' => "ad8c487e4f16a00d142db025fb2158f4", // The same token that we sent to the merchant.    'return_url' => "/order-success/checkout112233", // The url to return after successful payment eg. /order-success-page/{merchant_reference}'    'cancel_on_pjn' => "true", // OPTIONAL parameter in the case of a FAIL callback to control whether the order on PayJustNow should be cancelled or not. Default is TRUE.]

The return_url will be used to redirect the user to after all actions are completed on PayJustNow's side.

The cancel_on_pjn is only applicable to a FAIL callback and is optional, if NOT provided OR if provided and set to TRUE, the order will be cancelled on PayJustNow. If set to FALSE then the order will not be cancelled on PayJustNow, useful in the case where the user attempts to retry the same order.

This should complete the payment process.