Payments API
Summary
This documentation page contains everything you need to know about integrating to Klasha’s Payment Gateway. Once integration is done, you can begin to process payments from anywhere in the world in seconds.
Whilst you start your integration, please remember to reach out to our Compliance team to go through the KYB process and get your business verified. This is a mandatory process before you can start using our production platform.
If you are going to be implementing the direct charge API, you would require additional verification as this is only available to businesses that are PCI-DSS certified.
Payment collection
As a business owner, here is a way we make it possible for you to collect payments from customers all over the world:
In all the following APIs, you can simply substitute the desired currency to the path variable {{gateway}}.
Before you begin
Get your API keys
Find your keys on the Klasha Dashboard → Settings → Generate API Keys (here)
Klasha Dashboard, Generate API Keys page
Encryption algorithm
We are treating payment data, therefore all requests from merchant to our APIs must be encrypted in line with the industry standard. We make use of the standard 3DES technology with Padding for data encryption.
Below are code snippets for the 3DES encryption in different languages:
Card payments
To accept a card payment, you need to integrate with the following flow:
First, initiate the card payment
Then charge the card
And at the end validate the payment (optional to provide OTP and/or PIN)
For all api calls here, you’d need to pass your public key as the value for x-auth-token in the request header. See guide here on how to retrieve your public key.
Parameter variables
see here for more explanation on the api parameters
Initiate card payment
POST- {{env_url}}/pay/aggregators/{{gateway}}/card/payment/v2
Headers
Content-Type
application/json
x-auth-token
Your merchant public key
Request Body (plain data to be encrypted)
must be encrypted before sending
Request Body (encrypted)
Response
Charge card
POST- {{env_url}}/pay/aggregators/{{gateway}}/charge/card/v2
Headers
Content-Type*
application/json
x-auth-token*
Your merchant public key
Request Body (plain data to be encrypted)
must be encrypted before sending
Request Body (encrypted)
Response
Validate charge
POST- {{env_url}}/pay/aggregators/{{gateway}}/validate/card/v2
Headers
Content-Type
application/json
x-auth-token
Your merchant public key
Request Body (plain data to be encrypted)
must be encrypted before sending
Request Body (encrypted)
Response
Bank transfer
POST- {{env_url}}/pay/aggregators/{{gateway}}/banktransfer/v3
Parameter variables
see here for more explanation on the api parameters
Headers
Content-Type
application/json
x-auth-token
Your merchant public key
Request Body (plain)
must be encrypted before sending
Request Body (encrypted)
Response
M-Pesa
POST- {{env_url}}/pay/aggregators/{{gateway}}/card/payment/v2
Parameter variables
see here for more explanation on the api parameters
Headers
Content-Type
application/json
x-auth-token
Your merchant public key
Request Body (encrypted)
Request Body (plain)
must be encrypted before sending
Response
Initiate a refund
POST{{env_url}}/nucleus/refund/initiate/v3
Headers
Content-Type
application/json
x-auth-token
Your merchant public key
Request Body (plain)
must be encrypted before sending
Request body field description
txRef*
String
Transaction reference
refundType*
String
Type of refund (must be either partial or full)
amount*
Double
Amount to be refunded
Request Body (encrypted)
Response
Get a refund status
GET- {{env_url}}/nucleus/refund/status/{{txRef}}/v2
Headers
Content-Type
application/json
x-auth-token
Your merchant public key
Response
Generate a bearer token
AuthenticationExchange rate
POST- {{env_url}}/nucleus/general/exchange/
Make a POST call to the exchange rate API.
Headers
Content-Type
application/json
Authorization
Bearer "token"
Request Body
sourceCurrency
currency users will pay in
amount
amount
destinationCurrency
destination currency
productType
KLASHA_PAY (static value)
businessId
your business ID

Response
Last updated
