Checkout Link API
How to generate a checkout link and send to your customers to complete payment
The Checkout Link API allows you to generate a secure link that you can share with your customer to complete payment. Once the customer click on the link, IntaSend provides a guide on how to complete payment and notify both you and the customers on the status of the payment.
from intasend import APIService
publishable_key = "INTASEND_PUBLISHABLE_KEY"
service = APIService(token=None, publishable_key=publishable_key, test=True)
response = service.collect.checkout(phone_number=2547...,
email="[email protected]", amount=10, currency="KES", comment="Service Fees", redirect_url="http://example.com/thank-you")
print(response.get("url"))
use IntaSend\IntaSendPHP\Checkout;
use IntaSend\IntaSendPHP\Customer;
$credentials = [
'publishable_key' => env('INTASEND_PUBLISHABLE_KEY'),
'test' => env('INTASEND_TEST_ENVIRONMENT', true),
];
$customer = new Customer();
$customer->first_name = "Joe";
$customer->last_name = "Doe";
$customer->email = "[email protected]";
$customer->country = "KE";
$amount = 10;
$currency = "KES";
// Add your website and redirect url where the user will be redirected on success
$host = "https://example.com";
$redirect_url = "https://example.com/callback";
$ref_order_number = "test-order-10";
$checkout = new Checkout();
$checkout->init($credentials);
$resp = $checkout->create($amount = $amount, $currency = $currency, $customer = $customer, $host=$host, $redirect_url = $redirect_url, $api_ref = $ref_order_number, $comment = null, $method = null);
// Redirect the user to the URL to complete payment
print_r($resp->url);
const IntaSend = require("IntaSend")
let intasend = new IntaSend(
publishable_key='<INTASEND_PUBLISHABLE_KEY>',
test_mode=true // set to false when going live
);
let collection = intasend.collection();
collection
.charge({
first_name: 'Joe',
last_name: 'Doe',
email: '[email protected]',
host: 'https://yourwebsite.com',
amount: 10,
currency: 'KES',
api_ref: 'test',
redirect_url:'http://example.com/thank-you'
})
.then((resp) => {
// Redirect user to URL to complete payment
console.log(`Charge Resp:`, resp);
})
.catch((err) => {
console.error(`Charge error:`, err);
});
Updated 2 months ago