3DS Authentication HTML
<body>
<div id='threedsChallengeRedirect' xmlns='http://www.w3.org/1999/html' style=' height: 100vh'>
<form id='threedsChallengeRedirectForm' method='POST' action='' target='challengeFrame'>
<input type='hidden' name='creq' id="creq" value=''/>
</form>
<iframe id='challengeFrame' name='challengeFrame' width='100%' height='100%'></iframe>
</div>
<script>
const cardNumber = "4187451844054629"; // Card Number
const expiryMonth = "07"; // Card Expiry Month
const expiryYear = "32"; // Card Expiry Year
const securityCode = "100"; // Card Security Code
//const pin = "1000"// Card PIN //For NGN cards
var myHeaders = new Headers();
myHeaders.append("Authorization", "Payaza <Public API Key encoded in base 64>");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"service_type": "Account",
"service_payload": {
"first_name": "John",
"last_name": "Doe",
"email_address": "johndoe@email.com",
"phone_number": "090121980906",
"amount": 11,
"transaction_reference": "PL-1KBPSCJCR" + Math.floor(
(Math.random() * 10000000) + 1
),
"currency": "NGN",
"description": "Test for 3DS",
"card": {
"expiryMonth": expiryMonth,
"expiryYear": expiryYear,
"securityCode": securityCode,
"cardNumber": cardNumber
//"pin": pin //For NGN cards
}
}
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.payaza.africa/live/card/card_charge/", requestOptions).then(response => response.text()).then(result => {
result = JSON.parse(result);
if (result.statusOk) { // ///Handle Success Response
const creq = document.getElementById("creq");
creq.value = result.formData;
const form = document.getElementById("threedsChallengeRedirectForm");
form.setAttribute("action", result.threeDsUrl);
form.submit();
} else { // ///Handle Error
console.log("Error found", result.debugMessage)
alert("Payment Failed: " + result.debugMessage)
}
}).catch(error => {
console.log("Error", error)
alert("Exception Error: " + error.debugMessage)
});
// ///////////Internal Payment Notification
window.addEventListener("message", (event) => {
console.log("::::::::::::::::::MESSAGE EVENT GOT BACK FROM BACK-END::::::::::::::::::::::")
try{
const response = JSON.parse(event.data);
console.log("Payment Notification", response)
if (response.statusOk !== undefined) {
if (response.statusOk === true && response.paymentCompleted === true) { // ////Handle payment successful, do business logic
alert("Payment Successful")
} else { // ///Handle Failed payment
alert("Payment Failed")
}
}
}catch(error){
console.log("Error from Parsing JSON",error)
}
});
</script>
</body>curl --request POST \
--url https://api.payaza.africa/live/card/card_charge/ \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"service_payload": {
"first_name": "John",
"last_name": "Doe",
"email_address": "johndoe@hotmail.com",
"phone_number": "0939344401",
"amount": 0.01,
"transaction_reference": "T13501973673737",
"currency": "USD",
"description": "TEST",
"card": {
"expiryMonth": "10",
"expiryYear": "26",
"securityCode": "686",
"cardNumber": "4865550017193640"
},
"callback_url": "https://calbackurl.com"
}
}
'import requests
url = "https://api.payaza.africa/live/card/card_charge/"
payload = { "service_payload": {
"first_name": "John",
"last_name": "Doe",
"email_address": "johndoe@hotmail.com",
"phone_number": "0939344401",
"amount": 0.01,
"transaction_reference": "T13501973673737",
"currency": "USD",
"description": "TEST",
"card": {
"expiryMonth": "10",
"expiryYear": "26",
"securityCode": "686",
"cardNumber": "4865550017193640"
},
"callback_url": "https://calbackurl.com"
} }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
service_payload: {
first_name: 'John',
last_name: 'Doe',
email_address: 'johndoe@hotmail.com',
phone_number: '0939344401',
amount: 0.01,
transaction_reference: 'T13501973673737',
currency: 'USD',
description: 'TEST',
card: {
expiryMonth: '10',
expiryYear: '26',
securityCode: '686',
cardNumber: '4865550017193640'
},
callback_url: 'https://calbackurl.com'
}
})
};
fetch('https://api.payaza.africa/live/card/card_charge/', 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.payaza.africa/live/card/card_charge/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'service_payload' => [
'first_name' => 'John',
'last_name' => 'Doe',
'email_address' => 'johndoe@hotmail.com',
'phone_number' => '0939344401',
'amount' => 0.01,
'transaction_reference' => 'T13501973673737',
'currency' => 'USD',
'description' => 'TEST',
'card' => [
'expiryMonth' => '10',
'expiryYear' => '26',
'securityCode' => '686',
'cardNumber' => '4865550017193640'
],
'callback_url' => 'https://calbackurl.com'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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.payaza.africa/live/card/card_charge/"
payload := strings.NewReader("{\n \"service_payload\": {\n \"first_name\": \"John\",\n \"last_name\": \"Doe\",\n \"email_address\": \"johndoe@hotmail.com\",\n \"phone_number\": \"0939344401\",\n \"amount\": 0.01,\n \"transaction_reference\": \"T13501973673737\",\n \"currency\": \"USD\",\n \"description\": \"TEST\",\n \"card\": {\n \"expiryMonth\": \"10\",\n \"expiryYear\": \"26\",\n \"securityCode\": \"686\",\n \"cardNumber\": \"4865550017193640\"\n },\n \"callback_url\": \"https://calbackurl.com\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.post("https://api.payaza.africa/live/card/card_charge/")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"service_payload\": {\n \"first_name\": \"John\",\n \"last_name\": \"Doe\",\n \"email_address\": \"johndoe@hotmail.com\",\n \"phone_number\": \"0939344401\",\n \"amount\": 0.01,\n \"transaction_reference\": \"T13501973673737\",\n \"currency\": \"USD\",\n \"description\": \"TEST\",\n \"card\": {\n \"expiryMonth\": \"10\",\n \"expiryYear\": \"26\",\n \"securityCode\": \"686\",\n \"cardNumber\": \"4865550017193640\"\n },\n \"callback_url\": \"https://calbackurl.com\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.payaza.africa/live/card/card_charge/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"service_payload\": {\n \"first_name\": \"John\",\n \"last_name\": \"Doe\",\n \"email_address\": \"johndoe@hotmail.com\",\n \"phone_number\": \"0939344401\",\n \"amount\": 0.01,\n \"transaction_reference\": \"T13501973673737\",\n \"currency\": \"USD\",\n \"description\": \"TEST\",\n \"card\": {\n \"expiryMonth\": \"10\",\n \"expiryYear\": \"26\",\n \"securityCode\": \"686\",\n \"cardNumber\": \"4865550017193640\"\n },\n \"callback_url\": \"https://calbackurl.com\"\n }\n}"
response = http.request(request)
puts response.read_body{
"response_code": 200,
"response_message": "Operation Completed",
"response_content": {
"statusOk": true,
"message": "Approved",
"debugMessage": "Transaction Successful",
"description": "Test",
"descriptor": " ",
"waitForNotification": true,
"transactionReference": "450Q03ed3dd613",
"customerReference": "450Q03ed3dd613",
"do3dsAuth": false,
"paymentCompleted": true,
"amountPaid": 0.01,
"valueAmount": 0.0095,
"rrn": "123456789012",
"risk": {},
"acquirer_response_code": "00"
},
"status": "00"
}Card Collection
Card Charge
This endpoint is used to initiate Card payments for merchants that use our platform. This document has various Request bodies and HTML text that are necessary for different integration purposes. See the full Cards guide for a step-by-step walkthrough.
Note:
- The Card Acquirer Response Codes with descriptions can be found here
- Please be advised that card collections to countries other than Nigeria are exclusively available upon request. To initiate this process, kindly send an email to support@payaza.africa. You will be granted access once our team reviews and approves your request.
POST
/
card
/
card_charge
/
3DS Authentication HTML
<body>
<div id='threedsChallengeRedirect' xmlns='http://www.w3.org/1999/html' style=' height: 100vh'>
<form id='threedsChallengeRedirectForm' method='POST' action='' target='challengeFrame'>
<input type='hidden' name='creq' id="creq" value=''/>
</form>
<iframe id='challengeFrame' name='challengeFrame' width='100%' height='100%'></iframe>
</div>
<script>
const cardNumber = "4187451844054629"; // Card Number
const expiryMonth = "07"; // Card Expiry Month
const expiryYear = "32"; // Card Expiry Year
const securityCode = "100"; // Card Security Code
//const pin = "1000"// Card PIN //For NGN cards
var myHeaders = new Headers();
myHeaders.append("Authorization", "Payaza <Public API Key encoded in base 64>");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"service_type": "Account",
"service_payload": {
"first_name": "John",
"last_name": "Doe",
"email_address": "johndoe@email.com",
"phone_number": "090121980906",
"amount": 11,
"transaction_reference": "PL-1KBPSCJCR" + Math.floor(
(Math.random() * 10000000) + 1
),
"currency": "NGN",
"description": "Test for 3DS",
"card": {
"expiryMonth": expiryMonth,
"expiryYear": expiryYear,
"securityCode": securityCode,
"cardNumber": cardNumber
//"pin": pin //For NGN cards
}
}
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.payaza.africa/live/card/card_charge/", requestOptions).then(response => response.text()).then(result => {
result = JSON.parse(result);
if (result.statusOk) { // ///Handle Success Response
const creq = document.getElementById("creq");
creq.value = result.formData;
const form = document.getElementById("threedsChallengeRedirectForm");
form.setAttribute("action", result.threeDsUrl);
form.submit();
} else { // ///Handle Error
console.log("Error found", result.debugMessage)
alert("Payment Failed: " + result.debugMessage)
}
}).catch(error => {
console.log("Error", error)
alert("Exception Error: " + error.debugMessage)
});
// ///////////Internal Payment Notification
window.addEventListener("message", (event) => {
console.log("::::::::::::::::::MESSAGE EVENT GOT BACK FROM BACK-END::::::::::::::::::::::")
try{
const response = JSON.parse(event.data);
console.log("Payment Notification", response)
if (response.statusOk !== undefined) {
if (response.statusOk === true && response.paymentCompleted === true) { // ////Handle payment successful, do business logic
alert("Payment Successful")
} else { // ///Handle Failed payment
alert("Payment Failed")
}
}
}catch(error){
console.log("Error from Parsing JSON",error)
}
});
</script>
</body>curl --request POST \
--url https://api.payaza.africa/live/card/card_charge/ \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"service_payload": {
"first_name": "John",
"last_name": "Doe",
"email_address": "johndoe@hotmail.com",
"phone_number": "0939344401",
"amount": 0.01,
"transaction_reference": "T13501973673737",
"currency": "USD",
"description": "TEST",
"card": {
"expiryMonth": "10",
"expiryYear": "26",
"securityCode": "686",
"cardNumber": "4865550017193640"
},
"callback_url": "https://calbackurl.com"
}
}
'import requests
url = "https://api.payaza.africa/live/card/card_charge/"
payload = { "service_payload": {
"first_name": "John",
"last_name": "Doe",
"email_address": "johndoe@hotmail.com",
"phone_number": "0939344401",
"amount": 0.01,
"transaction_reference": "T13501973673737",
"currency": "USD",
"description": "TEST",
"card": {
"expiryMonth": "10",
"expiryYear": "26",
"securityCode": "686",
"cardNumber": "4865550017193640"
},
"callback_url": "https://calbackurl.com"
} }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
service_payload: {
first_name: 'John',
last_name: 'Doe',
email_address: 'johndoe@hotmail.com',
phone_number: '0939344401',
amount: 0.01,
transaction_reference: 'T13501973673737',
currency: 'USD',
description: 'TEST',
card: {
expiryMonth: '10',
expiryYear: '26',
securityCode: '686',
cardNumber: '4865550017193640'
},
callback_url: 'https://calbackurl.com'
}
})
};
fetch('https://api.payaza.africa/live/card/card_charge/', 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.payaza.africa/live/card/card_charge/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'service_payload' => [
'first_name' => 'John',
'last_name' => 'Doe',
'email_address' => 'johndoe@hotmail.com',
'phone_number' => '0939344401',
'amount' => 0.01,
'transaction_reference' => 'T13501973673737',
'currency' => 'USD',
'description' => 'TEST',
'card' => [
'expiryMonth' => '10',
'expiryYear' => '26',
'securityCode' => '686',
'cardNumber' => '4865550017193640'
],
'callback_url' => 'https://calbackurl.com'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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.payaza.africa/live/card/card_charge/"
payload := strings.NewReader("{\n \"service_payload\": {\n \"first_name\": \"John\",\n \"last_name\": \"Doe\",\n \"email_address\": \"johndoe@hotmail.com\",\n \"phone_number\": \"0939344401\",\n \"amount\": 0.01,\n \"transaction_reference\": \"T13501973673737\",\n \"currency\": \"USD\",\n \"description\": \"TEST\",\n \"card\": {\n \"expiryMonth\": \"10\",\n \"expiryYear\": \"26\",\n \"securityCode\": \"686\",\n \"cardNumber\": \"4865550017193640\"\n },\n \"callback_url\": \"https://calbackurl.com\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.post("https://api.payaza.africa/live/card/card_charge/")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"service_payload\": {\n \"first_name\": \"John\",\n \"last_name\": \"Doe\",\n \"email_address\": \"johndoe@hotmail.com\",\n \"phone_number\": \"0939344401\",\n \"amount\": 0.01,\n \"transaction_reference\": \"T13501973673737\",\n \"currency\": \"USD\",\n \"description\": \"TEST\",\n \"card\": {\n \"expiryMonth\": \"10\",\n \"expiryYear\": \"26\",\n \"securityCode\": \"686\",\n \"cardNumber\": \"4865550017193640\"\n },\n \"callback_url\": \"https://calbackurl.com\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.payaza.africa/live/card/card_charge/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"service_payload\": {\n \"first_name\": \"John\",\n \"last_name\": \"Doe\",\n \"email_address\": \"johndoe@hotmail.com\",\n \"phone_number\": \"0939344401\",\n \"amount\": 0.01,\n \"transaction_reference\": \"T13501973673737\",\n \"currency\": \"USD\",\n \"description\": \"TEST\",\n \"card\": {\n \"expiryMonth\": \"10\",\n \"expiryYear\": \"26\",\n \"securityCode\": \"686\",\n \"cardNumber\": \"4865550017193640\"\n },\n \"callback_url\": \"https://calbackurl.com\"\n }\n}"
response = http.request(request)
puts response.read_body{
"response_code": 200,
"response_message": "Operation Completed",
"response_content": {
"statusOk": true,
"message": "Approved",
"debugMessage": "Transaction Successful",
"description": "Test",
"descriptor": " ",
"waitForNotification": true,
"transactionReference": "450Q03ed3dd613",
"customerReference": "450Q03ed3dd613",
"do3dsAuth": false,
"paymentCompleted": true,
"amountPaid": 0.01,
"valueAmount": 0.0095,
"rrn": "123456789012",
"risk": {},
"acquirer_response_code": "00"
},
"status": "00"
}Response
Card Charge Responses
- Card Charge 3DS Response
- Card Charge Successful Callback Response
- Card Charge Failed Callback Response