Creating a Payment
To create a payment, send a POST request to:
POST /v2/checkoutHeaders
| Header | Value | Description |
|---|---|---|
| Content-Type | application/json | Request body is in JSON format |
| Authorization | Basic <base64(public_key + ":")> | Base64-encoded public key with colon |
Request Body
Provide payment details in JSON format:
json
{
"currency": "PHP",
"amount": 100,
"merchantReferenceNumber": "qwerty-uiop"
}Response
If successful, the server responds with:
json
{
"referenceNumber": "asdfg-hjkl",
"checkoutUrl": "http://localhost:5173/v2/checkout?id=asdfg-hjkl"
}Redirect the user to the checkoutUrl to complete the payment.
Sample JavaScript Code
js
const response = await fetch("http://localhost:8080/v2/checkout", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Basic " + btoa("YOUR_PUBLIC_KEY" + ":"),
},
body: JSON.stringify({
currency: "PHP",
amount: 100,
merchantReferenceNumber: "qwerty-uiop",
}),
});
const data = await response.json();
if (data.checkoutUrl) {
window.location.href = data.checkoutUrl;
}