Skip to main content
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 UFo3OC1QS0xJhsksksMjFFNEYtQ0VCNy00MjAzL4MDktQkU1NEM3NDY1RDRB");
        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>
{
  "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"
}

Authorizations

Authorization
string
header
required

Payaza {{Public API Key in Base 64}}

Body

application/json
service_payload
object
required

Response

Card Charge Responses

statusOk
boolean

Indicates if the initial request was valid.

Example:

true

message
string

Response message.

Example:

"Authentication Required"

debugMessage
string

Detailed debug message.

Example:

"3DS Authentication Required"

descriptor
string

Payment descriptor (if available).

Example:

""

waitForNotification
boolean

Whether the client should wait for a notification.

Example:

false

do3dsAuth
boolean

Flag indicating that 3DS authentication is required.

Example:

true

threeDsUrl
string<uri>

The URL to which the 3DS challenge should be submitted.

Example:

""

formData
string

Base64 encoded form data or payload for the 3DS request.

Example:

"eyJ0aHJlZURTU2VydmVyVHJhbnNJRCI6IjQ5ZGJ..."

threeDsHtml
string

Full HTML form required to auto-submit the 3DS challenge.

Example:

"<div id='threedsChallengeRedirect'> ... </div>"

paymentCompleted
boolean

Indicates if the payment is complete.

Example:

false

amountPaid
number

Amount successfully paid so far.

Example:

0

valueAmount
number

Total value amount processed.

Example:

0