Bring your own keys (BYOK)
curl --request PUT \
--url https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/credentials/{provider} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"client_id": "...",
"client_secret": "...",
"merchant_code": "600980",
"environment": "sandbox"
}
'import requests
url = "https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/credentials/{provider}"
payload = {
"client_id": "...",
"client_secret": "...",
"merchant_code": "600980",
"environment": "sandbox"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
client_id: '...',
client_secret: '...',
merchant_code: '600980',
environment: 'sandbox'
})
};
fetch('https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/credentials/{provider}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/credentials/{provider}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'client_id' => '...',
'client_secret' => '...',
'merchant_code' => '600980',
'environment' => 'sandbox'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/credentials/{provider}"
payload := strings.NewReader("{\n \"client_id\": \"...\",\n \"client_secret\": \"...\",\n \"merchant_code\": \"600980\",\n \"environment\": \"sandbox\"\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/credentials/{provider}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"client_id\": \"...\",\n \"client_secret\": \"...\",\n \"merchant_code\": \"600980\",\n \"environment\": \"sandbox\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/credentials/{provider}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"client_id\": \"...\",\n \"client_secret\": \"...\",\n \"merchant_code\": \"600980\",\n \"environment\": \"sandbox\"\n}"
response = http.request(request)
puts response.read_body{
"status": {
"ok": true,
"code": 123,
"desc": "<string>"
},
"data": {
"provider": "mpesa",
"display": {
"shortcode": "600999",
"passkey": "****9999"
},
"updated_at": "2023-11-07T05:31:56Z",
"updated_by": "<string>"
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}Merchant rails
Bring your own keys (BYOK)
Write-only (responses are masked), AES-256-GCM at rest. Money then moves in the merchant’s own provider
account (custody byok). Fields: mpesa: consumer_key, consumer_secret, shortcode; passkey (collect),
initiator + security_credential (disburse), optional till_number, b2c_shortcode. sasapay: client_id,
client_secret, merchant_code. paystack: secret_key, public_key. Any provider: environment: sandbox
for the provider’s sandbox. Needs credentials. Staff can do the same from cloudpay-admin.
Shape checks (400 invalid_credentials): shortcode, till_number, b2c_shortcode and merchant_code are digits;
secret_key starts sk_live_/sk_test_, public_key pk_live_/pk_test_; environment is sandbox or production.
PUT
/
v1
/
merchants
/
{merchantID}
/
credentials
/
{provider}
Bring your own keys (BYOK)
curl --request PUT \
--url https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/credentials/{provider} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"client_id": "...",
"client_secret": "...",
"merchant_code": "600980",
"environment": "sandbox"
}
'import requests
url = "https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/credentials/{provider}"
payload = {
"client_id": "...",
"client_secret": "...",
"merchant_code": "600980",
"environment": "sandbox"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
client_id: '...',
client_secret: '...',
merchant_code: '600980',
environment: 'sandbox'
})
};
fetch('https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/credentials/{provider}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/credentials/{provider}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'client_id' => '...',
'client_secret' => '...',
'merchant_code' => '600980',
'environment' => 'sandbox'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/credentials/{provider}"
payload := strings.NewReader("{\n \"client_id\": \"...\",\n \"client_secret\": \"...\",\n \"merchant_code\": \"600980\",\n \"environment\": \"sandbox\"\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/credentials/{provider}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"client_id\": \"...\",\n \"client_secret\": \"...\",\n \"merchant_code\": \"600980\",\n \"environment\": \"sandbox\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/credentials/{provider}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"client_id\": \"...\",\n \"client_secret\": \"...\",\n \"merchant_code\": \"600980\",\n \"environment\": \"sandbox\"\n}"
response = http.request(request)
puts response.read_body{
"status": {
"ok": true,
"code": 123,
"desc": "<string>"
},
"data": {
"provider": "mpesa",
"display": {
"shortcode": "600999",
"passkey": "****9999"
},
"updated_at": "2023-11-07T05:31:56Z",
"updated_by": "<string>"
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}Authorizations
merchantKeybearer & merchantId