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.
#
URLPOST 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 ValidationName | Desciption | Format | Example |
---|---|---|---|
customer.first_name | Customer First Name | string required | "John" |
customer.last_name | Customer Last Name | string required | "Doe" |
customer.email | Customer Email Address | string required | "[email protected]" |
customer.mobile_number | Customer Mobile Number | string required | "+27841112233" (Formatted to E164) |
customer.address.address_line_1 | Customer Address Line 1 | string required | "123 Some street" |
customer.address.city | Customer City | string required | "Johannesburg" |
customer.address.province | Customer Postal Code | string required | "Gauteng" |
customer.address.postal_code | Customer Postal Code | integer required | 1611 |
order.amount | Order Amount | integer required | 10000 (In Cents) |
order.merchant_reference | Merchant Reference | string required | "checkout112233" |
order.success_callback_url | Redirect URL on success | string required | "https://myshop.com/order-success" |
order.fail_callback_url | Redirect URL on failure | string required | "https://myshop.com/order-fail" |
order.expires_at | Date 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_reference | Order Item Reference | string required | "Shirt" |
order.items.*.quantity | Order Item Quantity | integer required | 1 |
order.items.*.description | Order Item Description | string required | "Blue Striped Shirt" |
order.items.*.unit_price | Order Item Description | integer required | 5000 (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_urlinfo
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.