Copy Sandbox: https://devbox.paydestal.com/pay
Prod: https://api.paydestal.com/pay
Copy
< <form id="paymentForm" action="/saveAndPay" method="POST">
<input type="hidden" name="customerEmail" id="customerEmail">
<input type="hidden" name="amount" id="amount">
<input type="hidden" name="reference" id="reference">
<button type="submit" name="payBtn" id="pay-now" title="Pay now">Pay now</button>
</form>
<script>
const email = "cust@email.com";
const amount = 4500;
const reference = "23445yyt";
// Populate the hidden input fields with values
document.getElementById('customerEmail').value = email;
document.getElementById('amount').value = amount;
document.getElementById('reference').value = reference;
</script>
Copy
Form-Data Request
const axios = require('axios');
const url = "{baseUrl}/api/v1/transaction/initialize";
const data = {
customerEmail: "cust@email.com",
amount: "4500",
callbackUrl: "https://pay.tech/callback",
};
axios.post(url, data, {
headers: {
Authorization: "Bearer {your client secret}",
"Cache-Control": "no-cache",
"Content-Type: "multipart/form-data"
}
})
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error('Error:', error.response ? error.response.data : error.message);
});
JSON Payload Request
if you prefer to make a json request instead of the form-data above, the endpoint to call is the one used in the snippet below:-
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer {{your client secret}}");
const raw = JSON.stringify({
"amount": 4500,
"customerEmail": "cust@email.com",
"callbackUrl": "https: //pay.tech/callback",
"reference": "3t4t4gthty754433455y5"
});
const requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
redirect: "follow"
};
fetch("{{baseUrl}}/pay/api/v1/transaction/initializer", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
Copy {
"responseCode": "201",
"responseMessage": "Payment Order Created Successfully!",
"data": {
"amount": 4500.0,
"customerEmail": "cust@email.com",
"currency": "NGN",
"reference": "06962146778",
"redirectUrl": "https://checkout.paydestal.com/charge/06962146778",
"callbackUrl": "https://paydestal.com",
"paymentStatus": "STARTED"
},
"success": true
}