Language
Tools
Step 2: Create a payment
Creates a transfer by debiting your Kopo Kopo merchant account and sending funds to the recipients transfer account (bank account or mobile wallet).
Fees
Move Money Method | Fees in KSh |
---|---|
To Bank Account | 50 |
To Mobile Wallet | 50 |
To Mpesa Till | 50 |
To Mpesa Paybill | 50 |
Request and response
POST https://sandbox.kopokopo.com/api/v1/payments
Accept: application/json
Content-Type: application/json
Authorization: Bearer 0Sn0W6kzNicvoWhDbQcVSKLRUpGjIdlPSEYyrHqrDDoRnQwE7Q
{
"destination_reference": "c7f300c0-f1ef-4151-9bbe-005005aa3747",
"destination_type": "mobile_wallet",
"amount": {
"currency": "KES",
"value": "20000"
},
"description": "Salary payment for May 2018",
"category": "salaries",
"tags": ["tag 1", "tag 2"],
"metadata": {
"customerId": "8675309",
"notes": "Salary payment for May 2018"
},
"_links": {
"callback_url": "https://your-call-bak.yourapplication.com/payment_result"
}
}
...
HTTP/1.1 201 Created
Location: https://sandbox.kopokopo.com/api/v1/payments/d76265cd-0951-e511-80da-0aa34a9b2388
mobile_input = {
destination_reference: "c7f300c0-f1ef-4151-9bbe-005005aa3747",
destination_type: "mobile_wallet",
currency: "KES",
value: 20000,
description: "Salary payment for May 2018",
category: "salaries",
tags: ["tag 1", "tag 2"],
callback_url: "https://webhook.site/437a5819-1a9d-4e96-b403-a6f898e5bed3",
metadata: {
customerId: '8_675_309',
notes: 'Salary payment for May 2018'
}
}
# Using K2Connect - https://github.com/kopokpo/k2-connect-ruby (Recommended)
k2_pay = K2Pay.new('your_access_token')
k2_pay.create_payment(mobile_input)
k2_pay.payments_location_url # => "https://sandbox.kopokopo.com/api/v1/payments/d76265cd-0951-e511-80da-0aa34a9b2388"
var paymentRequest = {
destinationType: 'mobile_wallet',
destinationReference: 'c7f300c0-f1ef-4151-9bbe-005005aa3747',
amount: '20000',
currency: 'KES',
description: "Salary payment for May 2018",
category: "salaries",
tags: ["tag 1", "tag 2"],
metadata: {
customer_id: '8675309',
notes: 'Salary payment for May 2018'
},
callbackUrl: 'https://your-call-bak.yourapplication.com/payment_result'
}
// Using Kopo Kopo Connect - https://github.com/kopokopo/k2-connect-node (Recommended)
const PayService = K2.PayService
PayService
.sendPay(paymentRequest)
.then(function(res) {
console.log(response)
// => 'https://sandbox.kopokopo.com/api/v1/payments/d76265cd-0951-e511-80da-0aa34a9b2388'
})
.catch( error => {
console.log(error)
})
# Using K2-connect - https://github.com/kopokopo/k2-connect-python (Recommended)
k2connect.initialize(CLIENT_ID, CLIENT_SECRET, BASE_URL)
pay_service = k2connect.Pay
payment_request = {
"access_token": ACCESS_TOKEN,
"destination_reference": 'c7f300c0-f1ef-4151-9bbe-005005aa3747',
"destination_type": 'mobile_wallet',
"callback_url": 'https://webhook.site/52fd1913-778e-4ee1-bdc4-74517abb758d',
"amount": '10',
"currency": 'KES',
"description": 'Salary payment for May 2018',
"category": 'salaries',
"tags": ["tag 1", "tag 2"],
"metadata": {
"customerId": '8_675_309',
"notes": 'Salary payment for May 2018'
}
}
# Pay to Mobile Wallet
create_pay_location = pay_service.send_pay(payment_request)
create_pay_location # => 'https://sandbox.kopokopo.com/api/v1/payments/d76265cd-0951-e511-80da-0aa34a9b2388'
<?
// Using Kopo Kopo Connect - https://github.com/kopokopo/k2-connect-php (Recommended)
$pay = $K2->PayService();
$response = $pay->sendPay([
'destinationType' => 'mobile_wallet',
'destinationReference' => 'c7f300c0-f1ef-4151-9bbe-005005aa3747',
'amount' => '20000',
'currency' => 'KES',
'callbackUrl' => 'https://your-call-bak.yourapplication.com/payment_result',
'description' => 'Salary payment for May 2018',
'category' => salaries',
'tags' => ["tag 1", "tag 2"],
'metadata' => [
'customerId' => '8675309',
'notes' => 'Salary payment for May 2018'
],
'accessToken' => 'myRand0mAcc3ssT0k3n'
]);
if($response['status'] == 'success')
{
echo "The resource location is:" . json_encode($response['location']);
// => 'https://sandbox.kopokopo.com/api/v1/payments/d76265cd-0951-e511-80da-0aa34a9b2388'
}
© 2024 Kopo Kopo, Inc.