Get Status

How it works

This service provide the capability to pull the current charge status

Initiate the request

Send a GET request to one of the following endpoints

Request Endpoints

https://cowpay.me/api/v1/charge/status
https://staging.cowpay.me/api/charge/status

Make sure to send all the listed below headers and keys with the proper values

Headers

HeaderValue
AuthorizationBearer [your token]
Acceptapplication/json

Keys

ParameterRequiredTypeDescription
merchant_reference_idyesstringThe order merchant_reference_id used in the creation request
signatureyesstringsha-256 hash for the following concatenated params: merchant_code + merchant_reference_id + hash_key
Both merchant_code and hash_key are being found in your API settings page in your cowpay dashboard
You can generate signatures while testing here

Request Payload Example

{
    "merchant_reference_id": "12458",
    "signature": "e6176890abb492c13d08e40da76c268af73ee974c2b1ceda763a5c5ba22c34ac"
}

Response

{
    "success": true,
    "status_code": 200,
    "status_description": "Operation done successfully",
    "merchant_reference_id": "12458",
    "cowpay_reference_id": 1000257,
    "order_status": "UNPAID"
}

Code Examples

GET /api/v1/charge/status?merchant_reference_id=12458&signature=e6176890abb492c13d08e40da76c268af73ee974c2b1ceda763a5c5ba22c34ac HTTP/1.1
Host: cowpay.me
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjA4YzExYWRkOTgxYmEyMTAxMjBiNDU4NjU0YzJhNmFkYjdhYjRkNTg0M2UxYTFkMzVlMDM2MDdlNmY2ODMyN2QwZTA1ZmVhY2ExOWExYWIxIn0.eyJhdWQiOiIzIiwianRpIjoiMDhjMTFhZGQ5ODFiYTIxMDEyMGI0NTg2NTRjMmE2YWRiN2FiNGQ1ODQzZTFhMWQzNWUwMzYwN2U2ZjY4MzI3ZDBlMDVmZWFjYTE5YTFhYjEiLCJpYXQiOjE2MDAwODMwNjgsIm5iZiI6MTYwMDA4MzA2OCwiZXhwIjoxNjMxNjE5MDY4LCJzdWIiOiIxNyIsInNjb3BlcyI6W119.f--W72hdY9ABlepGkzFubQx4PNNbxiYJZj8hPfXC2EwsUhPwWYGOL3rTSFnhYTuubJcEXLKnncoXInhBf9Ho2g  
let axios = require('axios');

let params = {
    "merchant_reference_id": "12458",
    "signature": "e6176890abb492c13d08e40da76c268af73ee974c2b1ceda763a5c5ba22c34ac",
}

let axiosConfig = {
    method: 'get',
    baseURL: 'https://cowpay.me/api/v1/', // or https://staging.cowpay.me/api/v1/,
    url: 'charge/status',
    headers: {
        'Content-Type': 'application/json',
        'Accept': 'application/json',
        'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjA4YzExYWRkOTgxYmEyMTAxMjBiNDU4NjU0YzJhNmFkYjdhYjRkNTg0M2UxYTFkMzVlMDM2MDdlNmY2ODMyN2QwZTA1ZmVhY2ExOWExYWIxIn0.eyJhdWQiOiIzIiwianRpIjoiMDhjMTFhZGQ5ODFiYTIxMDEyMGI0NTg2NTRjMmE2YWRiN2FiNGQ1ODQzZTFhMWQzNWUwMzYwN2U2ZjY4MzI3ZDBlMDVmZWFjYTE5YTFhYjEiLCJpYXQiOjE2MDAwODMwNjgsIm5iZiI6MTYwMDA4MzA2OCwiZXhwIjoxNjMxNjE5MDY4LCJzdWIiOiIxNyIsInNjb3BlcyI6W119.f--W72hdY9ABlepGkzFubQx4PNNbxiYJZj8hPfXC2EwsUhPwWYGOL3rTSFnhYTuubJcEXLKnncoXInhBf9Ho2g'
    },
    params: params
}

axios(axiosConfig)
    .then(response => {
        console.log(response.data)
    })
    .catch(error => {
        console.log(error.response.data)
    })
$client = new \GuzzleHttp\Client([
    'base_uri' => 'https://cowpay.me/api/v1/', // or https://staging.cowpay.me/api/v1
    'headers' => [
        'Content-Type' => 'application/json',
        'Accept' => 'application/json',
        'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjA4YzExYWRkOTgxYmEyMTAxMjBiNDU4NjU0YzJhNmFkYjdhYjRkNTg0M2UxYTFkMzVlMDM2MDdlNmY2ODMyN2QwZTA1ZmVhY2ExOWExYWIxIn0.eyJhdWQiOiIzIiwianRpIjoiMDhjMTFhZGQ5ODFiYTIxMDEyMGI0NTg2NTRjMmE2YWRiN2FiNGQ1ODQzZTFhMWQzNWUwMzYwN2U2ZjY4MzI3ZDBlMDVmZWFjYTE5YTFhYjEiLCJpYXQiOjE2MDAwODMwNjgsIm5iZiI6MTYwMDA4MzA2OCwiZXhwIjoxNjMxNjE5MDY4LCJzdWIiOiIxNyIsInNjb3BlcyI6W119.f--W72hdY9ABlepGkzFubQx4PNNbxiYJZj8hPfXC2EwsUhPwWYGOL3rTSFnhYTuubJcEXLKnncoXInhBf9Ho2g'
    ]
]);

try {
    $response = $client->request('GET', 'charge/status', [
        'query' => [
            'merchant_reference_id' => '12458',
            'signature' => 'e6176890abb492c13d08e40da76c268af73ee974c2b1ceda763a5c5ba22c34ac',
        ]
    ]);

    $result = json_decode($response->getBody()->getContents(), true);

    $status = $result['order_status'];

} catch (\GuzzleHttp\Exception\RequestException $exception) {

    $response = json_decode($exception->getResponse()->getBody()->getContents(), true);

    if ($response['status_code'] == 404) { 
      
      // handle not found order

    }
}