Language

Step 1: Create PAY recipients using the Kopo Kopo API

Your partners (customers, suppliers etc.) have an account or a relationship with your application. Your application holds their bank account or mobile wallet information. You can add Pay recipients directly in your Kopo Kopo merchant account or by using the API as prescribed below.

Step 1A. Obtain an application access token

Your application will exchange its client_id, client_secret, and grant_type=client_credentials for an application access token. An application access token can then be used to make calls to the API on behalf of your application.

Step 1B. Create a PAY recipient

Create a ‘pay recipient’ for every person you would like to make payments to. You can create recipients whose funds destinations are mobile wallets, bank accounts, other Kopo Kopo merchants and other till numbers. More details can be found in the Api docs

POST https://sandbox.kopokopo.com/api/v1/pay_recipients
Content-Type: application/json
Accept: application/json
Authorization: Bearer 0Sn0W6kzNicvoWhDbQcVSKLRUpGjIdlPSEYyrHqrDDoRnQwE7Q
{
  "type": "mobile_wallet"
  "pay_recipient" : {
    "first_name": "John",
    "last_name": "Doe",
    "email": "johndoe@nomail.net",
    "phone_number": "+254999999999",
    "network: "Safaricom"
  }
}

HTTP/1.1 201 Created
Location: https://sandbox.kopokopo.com/api/v1/pay_recipients/c7f300c0-f1ef-4151-9bbe-005005aa3747
mobile_input = {
    type: "mobile_wallet", 
    first_name: "John", 
    last_name: "Doe", 
    email: "johndoe@nomail.net", 
    phone_number: "+254999999999", 
    network: "Safaricom" 
}

# Using k2-connect - https://github.com/kopokopo/k2-connect-ruby(Recommended)
k2_pay = K2Pay.new('your_access_token')
# Mobile wallet recipient
k2_pay.add_recipient(mobile_input)
k2_pay.recipients_location_url # => "https://sandbox.kopokopo.com/pay_recipients/c7f300c0-f1ef-4151-9bbe-005005aa3747"
const PayService = K2.PayService

var requestBody = {
  type: 'mobile_wallet',
  firstName: 'John',
  lastName: 'Doe',
  network: 'Safaricom',
  email: 'johndoe@nomail.net',
  phoneNumber: '+254999999999',
  accessToken: 'myRand0mAcc3ssT0k3n'
}

PayService
  .addPayRecipient(requestBody)
  .then(function(res) {
    console.log(response)// => 'https://sandbox.kopokopo.com/api/v1/pay_recipients/c7f300c0-f1ef-4151-9bbe-005005aa3747'
  })
  .catch( error => {
    console.log(error)
  })

mobile_pay = {
  'access_token': ACCESS_TOKEN,
  'recipient_type': 'mobile_wallet',
  "first_name": "mobile_wallet_first_name",
  "last_name": "mobile_wallet_last_name",
  "phone_number": "+254123456789",
  "network": "mobile_wallet_network",
  "email": "test@test.com"
}


# Using k2-connect - https://github.com/kopokopo/k2-connect-python (Recommended)
k2connect.initialize(CLIENT_ID, CLIENT_SECRET, BASE_URL)
pay_service = k2connect.Pay

# Add mobile wallet pay recipient
mobile_wallet_resource_url = pay_service.add_pay_recipient(mobile_pay)
<?
$pay = $K2->PayService();

$response = $pay->addPayRecipient([
  'type' => 'mobile_wallet',
  'firstName'=> 'John',
  'lastName'=> 'Doe',
  'email'=> 'johndoe@nomail.net',
  'phoneNumber'=> '+254999999999',
  'network'=> 'Safaricom',
  'accessToken' => 'myRand0mAcc3ssT0k3n'
]);

if($response['status'] == 'success')
{
    echo "The resource location is:" . json_encode($response['location']);
}
//Get Java sample

When the PAY recipient is created, you’ll receive the Pay Recipient URL in the location header.

Please note, PAY recipients can also be created by logging into your Kopo Kopo account and creating them directly in the platform as opposed to via the API.