Checkout Standard
Checkout Standard provides a simplified and secure flow for collecting payments from customers. It's easy to integrate.
Integrating the Checkout Standard
We'll use examples to show you how to integrate Kora's payment gateway using the Checkout Standard into your product. Feel free to make the necessary adjustments you need to provide a customized experience on your product. In our first example, we'll be using a simple "Pay" button that should load Checkout Standard on a webpage.
Let's get started:
1 - Get your API Keys
Obtain your API Keys from your dashboard. We recommend you integrate using your test keys to avoid changes to your live data or charging real customers while testing.
2 - Add the pay-ins/collections script
Next, you'll need to add the Kora pay-in/collection script to your website or application.
<form>
<script src="https://korablobstorage.blob.core.windows.net/modal-bucket/korapay-collections.min.js"></script>
<button type="button" onclick="payKorapay()"> Pay </button>
</form>
<script>
function payKorapay() {
window.Korapay.initialize({
key: "pk_live_*********************",
reference: "your-unique-reference",
amount: 22000,
currency: "NGN",
customer: {
name: "John Doe",
email: "john@doe.com"
},
notification_url: "https://example.com/webhook"
});
}
</script>
Warning!
Avoid exposing your secret key on the client-side (or front end) of your application. Requests to the Kora's API should be initiated from your server.
3 - Initialize the payment gateway.
Use the Korapay.initialize
function to pass the relevant transaction details needed to initialize the payment gateway and start accepting payments.
-
Set the sample API key with your test mode key obtained from your dashboard. This allows you to test through your Korapay account.
-
Indicate the amount and currency.
-
Indicate the customer name and email to show on the gateway as the sender of the transaction.
-
When you’re ready to accept live payments, replace the test key with your live/production key.
4 - Receive confirmation via webhook
When the payment is successful, we will make a POST request to your webhook URL (as set up in your dashboard, or while initializing the transaction using the key: notification_url
) in this format:
{
"even"t: "charge.success" //the notification is only sent for successful charge,
"data": {
"reference": "KPY-C-cUBkIH&98n8b",
"currency": "NGN",
"amount": "22000", //amount paid by the customer
"amount_expected": "22000", //amount that the customer is expected to pay
"fee": "25",
"status": "success",
"payment_reference": "your-unique-reference", //unique reference sent by the merchant
"transaction_status": "success" //the status of the charge base on the amount paid by the customer. This can either be `success`, `underpaid` or `overpaid`,
"metadata": {
"internalRef": "JD-12-67",
"age": 15,
"fixed": true,
}
}
}
Configuration parameters
Field | Data Type | Description |
---|---|---|
| String |
|
| String |
|
| Integer |
|
| String |
|
| Object |
|
| String |
|
| String |
|
| String |
|
| String |
|
| Array[string] |
|
| String |
Note that the default channel must also be specified in the |
| Object |
Each field name has a maximum length of 20 characters. Allowed characters: |
| String |
The recommended size for this container is 400px x 500px (width x height). However, this is not enforced and you can load the checkout in a smaller or larger container. |
| [Function] |
|
| [Function] |
|
| [Function] |
|
| [Function] | Optional - function to be called when card tokenization is completed successfully |
| [Function] |
|
| Boolean |
|
Interacting with Checkout Standard through the Korapay script
When using Checkout Standard, the payment gateway is opened in an iframe to ensure security. Some functions are exposed to allow interactions with the application when specific events occur during a transaction. These include:
Event | Field |
---|---|
Succesful Transaction | onSuccess |
Failed Transaction | onFailed |
Payment Modal Closed | onClose |
Card Tokenized | onTokenized |
Bank Transfer Pending | onPending |
You can pass functions into these fields while calling Korapay.initialize
as shown in the script below.
<script>
function payKorapay() {
window.Korapay.initialize({
key: "pk_juigfweofyfewby732gwo8923e",
reference: "your-unique-reference",
amount: 3000,
currency: "NGN",
customer: {
name: "John Doe",
email: "john@doe.com"
},
onClose: function () {
// Handle when modal is closed
},
onSuccess: function (data) {
// Handle when payment is successful
},
onFailed: function (data) {
// Handle when payment fails
}
...
});
}
</script>
The data returned should have the following fields. Note that no data is returned for the onPending
function as the transaction is not yet completed:
Field | Data Type | Description |
---|---|---|
amount | String | Transaction Amount |
reference | String | Transaction Reference |
status | String | Transaction Status |
To close the modal programmatically, use the Korapay.close
function.
Updated about 1 month ago