Payments
Hosted checkout
Redirect customers to a Harpoon-hosted page instead of building your own UI.
Initialize a payment with a redirect_url, then send the customer to the checkout_url from the response.
Example
JavaScript
const res = await fetch('https://api.harpoonsms.com/v1/transactions/initialize', {
method: 'POST',
headers: {
'Authorization': 'Bearer hpn_live_sk_xxxxxxxxxxxxx',
'Content-Type': 'application/json'
},
body: JSON.stringify({
amount: '150.00',
phone_number: '0244123456',
customer_name: 'John Doe',
description: 'Order #1234',
redirect_url: 'https://mystore.com/order-complete'
})
});
const { data } = await res.json();
window.location.href = data.checkout_url;
// → https://harpoonsms.com/pay/a1b2c3d4e5f6a7b8Redirect parameters
After payment, the customer lands on your redirect_url with:
| Parameter | Description |
|---|---|
reference | The HPN code |
status | success, partial, or overpaid |
Plain Text
https://mystore.com/order-complete?reference=K7M3F6&status=successDon't trust redirect parameters alone.
They can be spoofed. Always verify via webhook or by re-fetching the transaction before fulfilling an order.