Click on the buttons i.e in the examples and prompted to pay, use the following test cards to complete your test payment.
Card 1: 4000 0000 0000 0002
Card 2: 4242 4242 4242 4242
Expiry - any future MM/YY
CVV - 123
Use own number. We have set small test amount of KES for M-Pesa test.
Normally, M-Pesa will refund payments made to test accounts within 72 hours, but that is not guaranteed.
<!-- This example use Axios to send post request. Feel free to use any other plugin that works for you -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.1/axios.min.js"></script>
body
<button class="btn btn-primary btn-lg" id="customBtn">Pay USD 10</button>
body
tag
function generateLink() {
// Use https://payment.intasend.com/api/v1/checkout/ for live payments
let url = "https://sandbox.intasend.com/api/v1/checkout/"
let payload = {
public_key: "REPLACE-WITH-YOUR-PUBLISHABLE-KEY",
amount: 10,
currency: "KES",
email: "john@doe.com",
first_name: "John",
last_name: "Doe",
country: "US"
}
axios.post(url, payload).then((resp) => {
if (resp.data.url) {
window.open(resp.data.url, '_blank').focus();
}
}).catch((err) => alert("Problem experienced while initializing your request: " + err))
}