Delivery Completed API
This API is used to automatically mark the order as delivered on AtaraPay when the seller delivers the order from the eCommerce or delivery app which causes email/ SMS notification to be sent to the buyer to accept or reject same.
Below are the fields that are to be sent via API using the POST
Method to the URL:
For Staging: http://test-api.atarapay.com/api/callback/order
for live: https://api.atarapay.com/api/api/callback/order
Field name | Required | Description |
---|---|---|
authtoken | Yes | This is calculated using the steps mentioned here Calculation of Auth Token |
order | Yes | This is Order Number from AtaraPay |
status | Yes | This is the status to be marked. Pass the value as delivered |
Optional | Email address of the buyer | |
phone_number | Yes | Phone number of the buyer |
Successfull Response
{
"status": "success",
"message": "pod_created",
"data": {
"phone": "+2348082094382",
"email": "emeka.adeniyi@atarapay.com",
"order": "3021"
}
}
Failure Response
{
"status": "error",
"message": "Invalid request to Process, Order has been already Processed"
}
Sample codes
C#
var client = new RestClient("http://test-api.atarapay.com/api/callback/order");
var request = new RestRequest(Method.POST);
request.AddHeader("postman-token", "7eb16eb4-c395-7477-de57-1723ea02f1c6");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddParameter("application/x-www-form-urlencoded", "authtoken=__AUTH_TOKEN_CALCULATED__&order=__Order_NO__&status=delivered&phone_number=__Buyer_Phone_Number__&email=__Buyer_Email__", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://test-api.atarapay.com/api/callback/order",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "authtoken=__AUTH_TOKEN_CALCULATED__&order=__Order_NO__&status=delivered&phone_number=__Buyer_Phone_Number__&email=__Buyer_Email__",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/x-www-form-urlencoded",
"postman-token: 147f6e58-9642-81aa-fc66-e301fd7713a9"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Node Js
var unirest = require("unirest");
var req = unirest("POST", "http://test-api.atarapay.com/api/callback/order");
req.headers({
"postman-token": "43b9ee82-e77d-f0ee-645d-e658b86ad0ef",
"cache-control": "no-cache",
"content-type": "application/x-www-form-urlencoded"
});
req.form({
"authtoken": "__AUTH_TOKEN_CALCULATED__",
"order": "__Order_NO__",
"status": "delivered",
"phone_number":"__Buyer_Phone_Number__",
"email": "__Buyer_Email__"
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
Possible Error Message
Error Message | Field name | Possible Reason |
---|---|---|
Invalid authtoken. Does not match any record. | authtoken | The authtoken is not correctly calculated. Please refer here to the steps Calculation of Auth Token. |
No such order exists for the seller. | order | The order number sent does not belong to the seller associated with the calculated authtoken |
Invalid status sent. | status | This field accepts only the following values delivered ,cancelled ,buyer_cancel ,order . Any other value passed would generate the error. |
Invalid action. This request has already been processed | order | The order Id passed has been processed earlier. |