Cash Collection

How it works

Cowpay service to collect cash from customers

Initiating the charge request

Initiate a POST charge request to using the following environments URLS

Request Endpoints

https://cowpay.me/api/v1/charge/cash-collection
https://staging.cowpay.me/api/v1/charge/cash-collection

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

Headers

HeaderValues
AuthorizationBearer [your token]
Content-Typeapplication/json
Acceptapplication/json

Keys

FieldRequiredTypeDescription
merchant_reference_idyesstringUnique alphanumeric value required as identifier for the charge request
customer_merchant_profile_idyesstringAlphanumeric ID of the customer being charged on your system
amountyesstringtwo decimal value like: "15.60"
customer_nameyesstringcustomer full name
customer_mobileyesstringinternationally formatted customer mobile
customer_emailyesstringcustomer valid email
addressyesstringdetailed address cash will be collected from
flooryesstringFloor number of your customer
districtyesstringDistrict name of the collection address
apartmentyesstringApartment number of the collection address
city_codeyesstringCity to collect cash from, a list of available cities ate the end of this page
signatureyesstringsha-256 hash for the following concatenated params: merchant_code + merchant_reference_id + customer_merchant_profile_id + amount + 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": "mc-8654",
    "customer_merchant_profile_id": "253",
    "amount": "2000",
    "customer_name": "John Doe",
    "customer_email": "example@gmail.com",
    "customer_mobile": "+201xxxxxxxxx",
    "address": "31 Institute street, 4th area, 5th settlement",
    "district": "3rd district",
    "apartment": "1",
    "floor": "1",
    "signature": "2ca4c078ab0d4c50ba90e31b3b0339d4d4ae5b32f97092dd9e9c07888c7eef36",
    "description": "charge request description",
    "city_code": "EG-01"
}

Code Examples

POST /api/v1/charge/cash-collection HTTP/1.1
Host: cowpay.me
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjA4YzExYWRkOTgxYmEyMTAxMjBiNDU4NjU0YzJhNmFkYjdhYjRkNTg0M2UxYTFkMzVlMDM2MDdlNmY2ODMyN2QwZTA1ZmVhY2ExOWExYWIxIn0.eyJhdWQiOiIzIiwianRpIjoiMDhjMTFhZGQ5ODFiYTIxMDEyMGI0NTg2NTRjMmE2YWRiN2FiNGQ1ODQzZTFhMWQzNWUwMzYwN2U2ZjY4MzI3ZDBlMDVmZWFjYTE5YTFhYjEiLCJpYXQiOjE2MDAwODMwNjgsIm5iZiI6MTYwMDA4MzA2OCwiZXhwIjoxNjMxNjE5MDY4LCJzdWIiOiIxNyIsInNjb3BlcyI6W119.f--W72hdY9ABlepGkzFubQx4PNNbxiYJZj8hPfXC2EwsUhPwWYGOL3rTSFnhYTuubJcEXLKnncoXInhBf9Ho2g
Content-Type: application/json

{
    "merchant_reference_id": "mc-8654",
    "customer_merchant_profile_id": "253",
    "amount": "2000",
    "customer_name": "John Doe",
    "customer_email": "example@gmail.com",
    "customer_mobile": "+201xxxxxxxxx",
    "address": "31 Institute street, 4th area, 5th settlement",
    "district": "3rd district",
    "apartment": "1",
    "floor": "1",
    "signature": "2ca4c078ab0d4c50ba90e31b3b0339d4d4ae5b32f97092dd9e9c07888c7eef36",
    "description": "charge request description",
    "city_code": "EG-01"
}
let axios = require('axios');

let data = {
  "merchant_reference_id": "mc-8654",
  "customer_merchant_profile_id": "253",
  "amount": "2000",
  "customer_name": "John Doe",
  "customer_email": "example@gmail.com",
  "customer_mobile": "+201xxxxxxxxx",
  "address": "31 Institute street, 4th area, 5th settlement",
  "district": "3rd district",
  "apartment": "1",
  "floor": "1",
  "signature": "2ca4c078ab0d4c50ba90e31b3b0339d4d4ae5b32f97092dd9e9c07888c7eef36",
  "description": "charge request description",
  "city_code": "EG-01"
}

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

axios(axiosConfig)
    .then(response => {
        console.log(response.data)
    })
    .catch(error => {
        console.log(error.response.data)
    })
$client = new \GuzzleHttp\Client([
    'base_uri' => 'http://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('POST', 'charge/cash-collection', [
        'json' => [
            'merchant_reference_id' => 'mc-8654',
            'customer_merchant_profile_id' => '253',
            'customer_name' => 'Testing',
            'customer_email' => 'dev@cowpay.me',
            'customer_mobile' => '+201096545211',
            'amount' => '10.00',
            'signature' => '09dfae8d79f63e1e81b4ea6808f9de764512dc238391efbc5aa3c1634dc65447',
            'description' => 'Charge request description',
            'address' => '31 Institute street, 4th area, 5th settlement',
            'floor' => '1',
            'district' => '3rd district',
            'apartment' => '1',
            'city_code' => 'EG-01',
        ]
    ]);

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

    $paymentReferenceId = $result['payment_gateway_reference_id']; // used in outlet payment
    
} catch (\GuzzleHttp\Exception\RequestException $exception) {

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

    if ($response['status_code'] == 422) {

        $errors = $response['errors']; // check invalid date messages

    }

}

Available Cities

CodeCityDistrict
EG-01CairoDowntown Cairo
EG-01Giza & HaramGiza
EG-02Downtown AlexDowntown Alexandria
EG-03SahelSahel
EG-04BehiraDamanhour
EG-05DakahliaAl Mansoura
EG-06El KalioubiaSheben Alkanater
EG-07GharbiaTanta
EG-08Kafr AlsheikhKafr Alsheikh
EG-09MonufiaShebin El Koom
EG-10SharqiaZakazik
EG-11IsamiliaHay 1
EG-12SuezAl Suez District
EG-13Port SaidSharq
EG-14DamiettaDamietta
EG-15FayoumFayoum
EG-16Bani SuifBani Suif
EG-17AsyutAsyut
EG-18SohagSohag
EG-19MenyaMenya
EG-20QenaQena
EG-21AswanAswan
EG-22LuxorLuxor