IntaSend Integration Examples

How to test

Click on the buttons i.e in the examples and prompted to pay, use the following test cards to complete your test payment.

Test cards

Card 1: 4000 0000 0000 0002

Card 2: 4242 4242 4242 4242

Expiry - any future MM/YY

CVV - 123

M-Pesa test

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.

Payment Button - Standard

Install Plugin - Add it in your before closing the head tag
<script src="https://unpkg.com/intasend-inlinejs-sdk@3.0.2/build/intasend-inline.js"></script>
Add button tag in your body
<button class="btn btn-primary btn-lg intaSendPayButton" data-amount="10" data-currency="KES">Pay Now</button>
Add JavaScript code before closing the body tag
new window.IntaSend({
    publicAPIKey: "REPLACE-WITH-YOUR-PUBLISHABLE-KEY",
    live: false // set to true when going live
})
.on("COMPLETE", () => alert("Do something on success"))
.on("FAILED", () => alert("Do something on failure"))
.on("IN-PROGRESS", () => console.log("Payment in progress status"))

                
Simply add a pay now button to your site with a few lines of code.

Payment Button - Custom

Install Plugin - Add it in your before closing the head tag
<script src="https://unpkg.com/intasend-inlinejs-sdk@3.0.2/build/intasend-inline.js"></script>
Add button tag in your body
<button class="btn btn-primary btn-lg" id="customBtn">Pay USD 10</button>
Add JavaScript code before closing the body tag
let customBtnObj = new window.IntaSend({
    publicAPIKey: "REPLACE-WITH-YOUR-PUBLISHABLE-KEY",
    live: false // set to true when going live
})
document.getElementById("customBtn").onclick = () => {
    customBtnObj.run({
        amount: 10,
        currency: "USD",
        email: "john@doe.com",
        first_name: "John",
        last_name: "Doe",
        country: "US"
    })
    .on("COMPLETE", () => alert("Do something on success"))
    .on("FAILED", () => alert("Do something on failure"))
    .on("IN-PROGRESS", () => console.log("Payment in progress status"))
}
                
Parse extra parameters e.g customer email, amount etc after initialization.