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";
$card_tarrif = "BUSINESS-PAYS";
$mobile_tarrif = "BUSINESS-PAYS";
$wallet_id=null;
$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, $card_tarrif=$card_tarrif, $mobile_tarrif=$mobile_tarrif, $wallet_id=$wallet_id);
// Redirect the user to the URL to complete payment
print_r($resp->url);
const IntaSend = require('intasend-node');
let intasend = new IntaSend(
'<INTASEND_PUBLISHABLE_KEY>',
'<INTASEND_SECRET_KEY>',
true, // Test ? Set true for test environment
);
const IntaSend = require("IntaSend")
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);
});
List of payments payload fields
The following options can be parsed to the payload. If any of this data is available, it is highly recommended that you provide them so that we can shorten the payment form and provide a better user experience. Customers will not be prompted to provide this information if already added.
Parameter | Description |
---|---|
currency | Recommended: Options are USD, KES, GBP, EUR |
amount | Optional. If not defined customers will have the option to specify how much they want to pay |
phone_number | Optional. Customers will be prompted if required e.g M-Pesa payment |
Optional. Customers will be prompted if required e.g card payments | |
api_ref | Recommended - Tracking reference for own use. |
comment | Optional customer comment if any |
first_name | Optional customer first name |
last_name | Optional customer last name |
country | Optional country code e.g US, BR, KE, etc |
address | Optional user billing address |
city | Optional user billing city |
state | Optional user billing state |
zipcode | Optional user billing zipcode |
method | Optional - if specified only the method will be used. Options are M-PESA, CARD-PAYMENT. Leave blank to show all payment methods. |
card_tarrif | options are BUSINESS-PAYS and CUSTOMER-PAYS . Specify who pays the card charges. Set to BUSINESS-PAYS by default |
mobile_tarrif | options are BUSINESS-PAYS and CUSTOMER-PAYS . Specify who pays the mobile charges. Set to BUSINESS-PAYS by default |
redirect_url | Optional URL where we should redirect the user on payment success |
Updated 3 months ago