Polling
Polling API Requests
Poll Buygoods Transactions between the specified dates for a particular till or for the whole company
POST https://sandbox.kopokopo.com/api/v2/polling
Content-Type: application/json
Accept: application/json
Authorization: Bearer < AccessToken >
User-Agent: "< product >/< product-version > < comment >"
- JSON
- Ruby
- Python
- JavaScript
- PHP
- Dart
{
"scope": "company",
"scope_reference": "",
"from_time": "2021-04-12T08:50:22+03:00",
"to_time": "2021-04-19T08:50:22+03:00",
"_links": {
"callback_url": "https://callback_to_your_app.your_application.com"
}
}
# Using K2Connect - https://github.com/kopokopo/k2-connect-ruby (Recommended)
your_input =
{
scope: "company",
scope_reference: "",
from_time: "2021-04-12T08:50:22+03:00",
to_time: "2021-04-19T08:50:22+03:00",
callback_url: 'https://call_back_to_your_app.your_application.com'
}
k2_polling = K2Polling.new("your_access_token")
k2_polling.poll(your_input)
k2_polling.location_url # => "https://sandbox.kopokopo.com/api/v2/polling/247b1bd8-f5a0-4b71-a898-f62f67b8ae1c"
request_body =
{
"access_token": ACCESS_TOKEN,
"callback_url": "https://webhook.site/52fd1913-778e-4ee1-bdc4-74517abb758d",
"scope": "company",
"scope_reference": "",
"from_time": "2021-04-12T08:50:22+03:00",
"to_time": "2021-04-19T08:50:22+03:00"
}
# Using K2Connect - https://github.com/kopokopo/k2-connect-python (Recommended)
k2connect.initialize(environ.get('CLIENT_ID'), environ.get('CLIENT_SECRET'), 'sandbox.kopokopo.com')
polling_service = k2connect.Polling
polling_location = polling_service.create_polling_request(request_body)
polling_location # => 'https://sandbox.kopokopo.com/api/v2/polling/247b1bd8-f5a0-4b71-a898-f62f67b8ae1c'
const PollingService = K2.PollingService
var pollingOptions = {
scope: "company",
scopeReference: "",
fromTime: "2021-04-12T08:50:22+03:00",
toTime: "2021-04-19T08:50:22+03:00",
callbackUrl: 'https://callback_to_your_app.your_application.com/endpoint',
accessToken: 'myRand0mAcc3ssT0k3n'
}
PollingService
.pollTransactions(pollingOptions)
.then( response => {
console.log(response)
// => 'https://sandbox.kopokopo.com/api/v2/polling/247b1bd8-f5a0-4b71-a898-f62f67b8ae1c'
})
.catch( error => {
console.log(error)
})
<?
$polling = $K2->PollingService();
$response = $polling->pollTransactions([
'scope' => "company",
'scopeReference' => "",
'fromTime' => "2021-04-12T08:50:22+03:00",
'toTime' => "2021-04-19T08:50:22+03:00",
'callbackUrl' => 'https://callback_to_your_app.your_application.com/endpoint',
'accessToken' => 'myRand0mAcc3ssT0k3n',
]);
if($response['status'] == 'success')
{
echo "The resource location is:" . json_encode($response['location']);
// => 'https://sandbox.kopokopo.com/api/v2/polling/247b1bd8-f5a0-4b71-a898-f62f67b8ae1c'
}
// This feature is not currently available in the Flutter SDK.
// Please use one of the other SDKs (PHP, Ruby, Python, NodeJs) or the REST API.
HTTP Request
POST https://sandbox.kopokopo.com/api/v2/polling
Accept: application/json
Content-Type: application/json
Authorization: Bearer 0Sn0W6kzNicvoWhDbQcVSKLRUpGjIdlPSEYyrHqrDDoRnQwE7Q
User-Agent: < product >/< product-version > < comment >
Request Parameters (JSON)
| Parameter | Required | Type | Description |
|---|---|---|---|
| scope | yes | String | The scope of the polling request. Could be either company or till |
| scope_reference | yes | String | If the scope is till the scope reference is required and it should be your till number |
| from_time | Yes | String | A string containing a date in the iso8601 format |
| to_time | Yes | String | A string containing a date in the iso8601 format |
| _links | Yes | JSON | A JSON object containing the callback_url where the result of the Polling Query will be posted |
HTTP Response
Successful Response
Upon a successful request a HTTP Status 201 will be returned and the location HTTP Header will contain the URL of the newly created Polling API Request
HTTP/1.1 201 Created
Location: https://sandbox.kopokopo.com/api/v2/polling/247b1bd8-f5a0-4b71-a898-f62f67b8ae1c
Error Response
This will have a HTTP Status code indicating the error and it might have a json that contains the error code and an error message specifying the error that occured. Please note that the error response might not be present depending on the type of error that occured.
If the error json response is present, it will look as follows:
HTTP/1.1 400 Bad Request
{ "error_code": 400, "error_message": "Scope is invalid" }
Process Polling API Result
POST https://your-callback-url.com/api/v2/polling_result
Content-Type: application/json
X-KopoKopo-Signature: 0Sn0W6kzNicvoWhDbQcVSKLRUpGjIdlPSEYyrHqrDDoRnQwE7Q
User-Agent: < product >/< product-version > < comment >
- JSON
- Ruby
- Python
- JavaScript
- PHP
- Dart
{
"data": {
"id": "d4849121-d7d4-49f8-881f-b41601a7fe43",
"type": "polling",
"attributes": {
"status": "Success",
"created_at": "2021-04-28T11:25:53.497+03:00",
"from_time": "2021-04-12T08:50:22+03:00",
"to_time": "2021-04-19T08:50:22+03:00",
"transactions": [
{
"type": "Buygoods Transaction",
"resource": {
"id": "c4fbb520-9155-406e-aee8-661a07a49f86",
"amount": "500.0",
"status": "Received",
"system": "Lipa Na M-PESA",
"currency": "KES",
"reference": "APR202119",
"till_number": "000000",
"origination_time": "2021-04-19T08:19:00+03:00",
"sender_last_name": "Doe",
"sender_first_name": "Jane",
"sender_middle_name": "",
"sender_phone_number": "+254799999999"
}
},
{
"type": "Buygoods Transaction",
"resource": {
"id": "18f8da83-5d95-45f9-9670-1958a8fe1e30",
"amount": "500.0",
"status": "Received",
"system": "Lipa Na M-PESA",
"currency": "KES",
"reference": "APR202126",
"till_number": "K000000",
"origination_time": "2021-04-19T08:19:00+03:00",
"sender_last_name": "Doe",
"sender_first_name": "Jane",
"sender_middle_name": "",
"sender_phone_number": "+254799999999"
}
},
{
"type": "External Till to Till Transaction",
"resource": {
"id": "dfcfd000-3c43-4fff-beb3-c82718715f2e",
"amount": "1000.0",
"status": "Complete",
"system": "M-PESA",
"currency": "KES",
"reference": "JUL202410",
"till_number": "112233",
"sending_till": "John",
"origination_time": "2024-07-10T13:00:00+03:00"
}
}
],
"scope": "Company",
"scope_reference": null,
"_links": {
"callback_url": "https://webhook.site/a67f60b8-8c26-40a2-866c-99f5314a3e0e",
"self": "https://sandbox.kopokopo.com/api/v2/polling/d4849121-d7d4-49f8-881f-b41601a7fe43"
}
}
}
}
polling = K2Client.new("API_KEY")
polling.parse_request(request)
polling_object = K2ProcessResult.process(polling.hash_body, API_KEY, polling.k2_signature)
# Processed polling result in json format
{
"data": {
"id": "d4849121-d7d4-49f8-881f-b41601a7fe43",
"type": "polling",
"attributes": {
"status": "Success",
"created_at": "2021-04-28T11:25:53.497+03:00",
"from_time": "2021-04-12T08:50:22+03:00",
"to_time": "2021-04-19T08:50:22+03:00",
"transactions": [
{
"type": "Buygoods Transaction",
"resource": {
"id": "c4fbb520-9155-406e-aee8-661a07a49f86",
"amount": "500.0",
"status": "Received",
"system": "Lipa Na M-PESA",
"currency": "KES",
"reference": "APR202119",
"till_number": "000000",
"origination_time": "2021-04-19T08:19:00+03:00",
"sender_last_name": "Doe",
"sender_first_name": "Jane",
"sender_middle_name": "",
"sender_phone_number": "+254799999999"
}
},
{
"type": "Buygoods Transaction",
"resource": {
"id": "18f8da83-5d95-45f9-9670-1958a8fe1e30",
"amount": "500.0",
"status": "Received",
"system": "Lipa Na M-PESA",
"currency": "KES",
"reference": "APR202126",
"till_number": "K000000",
"origination_time": "2021-04-19T08:19:00+03:00",
"sender_last_name": "Doe",
"sender_first_name": "Jane",
"sender_middle_name": "",
"sender_phone_number": "+254799999999"
}
}
],
"scope": "Company",
"scope_reference": null,
"_links": {
"callback_url": "https://webhook.site/a67f60b8-8c26-40a2-866c-99f5314a3e0e",
"self": "https://sandbox.kopokopo.com/api/v2/polling/d4849121-d7d4-49f8-881f-b41601a7fe43"
}
}
}
}
k2connect.initialize(CLIENT_ID, CLIENT_SECRET, BASE_URL)
result_handler = k2connect.ResultHandler
processed_payload = result_handler.process(request)
decomposed_result = payload_decomposer.decompose(processed_payload)
# Processed polling result in json format
{
"data": {
"id": "d4849121-d7d4-49f8-881f-b41601a7fe43",
"type": "polling",
"attributes": {
"status": "Success",
"created_at": "2021-04-28T11:25:53.497+03:00",
"from_time": "2021-04-12T08:50:22+03:00",
"to_time": "2021-04-19T08:50:22+03:00",
"transactions": [
{
"type": "Buygoods Transaction",
"resource": {
"id": "c4fbb520-9155-406e-aee8-661a07a49f86",
"amount": "500.0",
"status": "Received",
"system": "Lipa Na M-PESA",
"currency": "KES",
"reference": "APR202119",
"till_number": "000000",
"origination_time": "2021-04-19T08:19:00+03:00",
"sender_last_name": "Doe",
"sender_first_name": "Jane",
"sender_middle_name": "",
"sender_phone_number": "+254799999999"
}
},
{
"type": "Buygoods Transaction",
"resource": {
"id": "18f8da83-5d95-45f9-9670-1958a8fe1e30",
"amount": "500.0",
"status": "Received",
"system": "Lipa Na M-PESA",
"currency": "KES",
"reference": "APR202126",
"till_number": "K000000",
"origination_time": "2021-04-19T08:19:00+03:00",
"sender_last_name": "Doe",
"sender_first_name": "Jane",
"sender_middle_name": "",
"sender_phone_number": "+254799999999"
}
}
],
"scope": "Company",
"scope_reference": null,
"_links": {
"callback_url": "https://webhook.site/a67f60b8-8c26-40a2-866c-99f5314a3e0e",
"self": "https://sandbox.kopokopo.com/api/v2/polling/d4849121-d7d4-49f8-881f-b41601a7fe43"
}
}
}
}
{
"data": {
"id": "d4849121-d7d4-49f8-881f-b41601a7fe43",
"type": "polling",
"attributes": {
"status": "Success",
"created_at": "2021-04-28T11:25:53.497+03:00",
"from_time": "2021-04-12T08:50:22+03:00",
"to_time": "2021-04-19T08:50:22+03:00",
"transactions": [
{
"type": "Buygoods Transaction",
"resource": {
"id": "c4fbb520-9155-406e-aee8-661a07a49f86",
"amount": "500.0",
"status": "Received",
"system": "Lipa Na M-PESA",
"currency": "KES",
"reference": "APR202119",
"till_number": "000000",
"origination_time": "2021-04-19T08:19:00+03:00",
"sender_last_name": "Doe",
"sender_first_name": "Jane",
"sender_middle_name": "",
"sender_phone_number": "+254799999999"
}
},
{
"type": "Buygoods Transaction",
"resource": {
"id": "18f8da83-5d95-45f9-9670-1958a8fe1e30",
"amount": "500.0",
"status": "Received",
"system": "Lipa Na M-PESA",
"currency": "KES",
"reference": "APR202126",
"till_number": "K000000",
"origination_time": "2021-04-19T08:19:00+03:00",
"sender_last_name": "Doe",
"sender_first_name": "Jane",
"sender_middle_name": "",
"sender_phone_number": "+254799999999"
}
}
],
"scope": "Company",
"scope_reference": null,
"_links": {
"callback_url": "https://webhook.site/a67f60b8-8c26-40a2-866c-99f5314a3e0e",
"self": "https://sandbox.kopokopo.com/api/v2/polling/d4849121-d7d4-49f8-881f-b41601a7fe43"
}
}
}
}
<?
// The payload from the k2-connect-php SDK will look like this.
[
"status" => "success",
"data" => [
"id" => "d4849121-d7d4-49f8-881f-b41601a7fe43",
"type" => "polling",
"status" => "Success",
"createdAt" => "2021-04-28T11:25:53.497+03:00",
"fromTime" => "2021-04-12T08:50:22+03:00",
"toTime" => "2021-04-19T08:50:22+03:00",
"scope" => "Company",
"scopeReference" => null,
"transactions" => [
[
"type" => "Buygoods Transaction",
"resource" => [
"id" => "c4fbb520-9155-406e-aee8-661a07a49f86",
"amount" => "500.0",
"status" => "Received",
"system" => "Lipa Na M-PESA",
"currency" => "KES",
"reference" => "APR202119",
"till_number" => "000000",
"origination_time" => "2021-04-19T08:19:00+03:00",
"sender_last_name" => "Doe",
"sender_first_name" => "Jane",
"sender_middle_name" => "",
"sender_phone_number" => "+254799999999"
]
],
[
"type" => "Buygoods Transaction",
"resource" => [
"id" => "18f8da83-5d95-45f9-9670-1958a8fe1e30",
"amount" => "500.0",
"status" => "Received",
"system" => "Lipa Na M-PESA",
"currency" => "KES",
"reference" => "APR202126",
"till_number" => "K000000",
"origination_time" => "2021-04-19T08:19:00+03:00",
"sender_last_name" => "Doe",
"sender_first_name" => "Jane",
"sender_middle_name" => "",
"sender_phone_number" => "+254799999999"
]
]
],
"linkSelf" => "https://sandbox.kopokopo.com/api/v2/polling/d4849121-d7d4-49f8-881f-b41601a7fe43",
"callbackUrl" => "https://webhook.site/a67f60b8-8c26-40a2-866c-99f5314a3e0e",
]
]
// This feature is not currently available in the Flutter SDK.
// Please use one of the other SDKs (PHP, Ruby, Python, NodeJs) or the REST API.
After the Polling query is performed, a Polling Result will be posted asynchronously to the call back URL specified in the Polling API Request.
Polling Result Parameters (JSON)
Parameters contained in a successful Polling result;
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The ID of the Polling API Request |
| type | Yes | String | The topic of the request. polling in this instance. |
| status | Yes | String | A status string denoting the status of the Polling Request |
| from_time | Yes | Date | The from date that was specified in the request |
| to_time | Yes | Date | The to date that was specified in the request |
| transactions | No | JSON | An JSON object containing the transactions from the query with the specified parameters |
| _links | Yes | JSON | A JSON object containing links to the Polling API request |
Transactions JSON(Could be multiple)
| Parameter | Type | Description |
|---|---|---|
| type | String | The type of transaction (Buygoods Transaction) |
| resource | JSON | The resource corresponding to the event. In this case this is a Buygoods Transaction |
Resource (Buygoods Transaction) JSON
| Parameter | Type | Description |
|---|---|---|
| id | String | The api reference of the transaction |
| reference | String | The mpesa reference |
| status | String | The status of the transaction |
| origination_time | String | The transaction timestamp |
| sender_phone_number | String | The phone number that sent the payment |
| amount | Float | The amount of the transaction |
| currency | String | Currency |
| till_number | String | The till number to which the payment was made |
| system | String | The mobile money system |
| sender_first_name | String | First name of payer |
| sender_middle_name | String | Middle name of payer |
| sender_last_name | String | Last name of payer |
Query Polling API Status
GET https://sandbox.kopokopo.com/api/v2/polling/d79995cd-0111-e511-80da-0aa34a9b2388
Accept: application/json
Authorization: Bearer 0Sn0W6kzNicvoWhDbQcVSKLRUpGjIdlPSEYyrHqrDDoRnQwE7Q
Content-Type: application/json
User-Agent: < product >/< product-version > < comment >
- Ruby
- Python
- JavaScript
- PHP
- Dart
polling_url = 'https://sandbox.kopokopo.com/api/v2/polling/d4849121-d7d4-49f8-881f-b41601a7fe43'
# Using K2 Connect - https://github.com/kopokopo/k2-connect-ruby (Recommended)
k2_polling = K2Polling.new("your_access_token")
k2_polling.polling(your_input)
# Query specific resource
k2_polling.query_resource(polling_url) or k2_polling.query_resource(k2_polling.location_url)
# Query recent transaction
k2_polling.query_status
pollingUrl = 'https://sandbox.kopokopo.com/api/v2/polling/d4849121-d7d4-49f8-881f-b41601a7fe43'
# Using K2 Connect - https://github.com/kopokopo/k2-connect-python (Recommended)
k2connect.initialize(environ.get('CLIENT_ID'), environ.get('CLIENT_SECRET'), 'sandbox.kopokopo.com')
polling_service = k2connect.Polling
polling_location = polling_service.polling_request_status(access_token, pollingUrl)
var PollingService = K2.PollingService
var pollingUrl = 'https://sandbox.kopokopo.com/api/v2/polling/d4849121-d7d4-49f8-881f-b41601a7fe43'
PollingService
.getStatus({accessToken: 'myRand0mAcc3ssT0k3n', location: pollingUrl})
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error)
})
<?
$polling = $K2->PollingService();
$options = [
'location' => 'https://sandbox.kopokopo.com/api/v2/polling/d4849121-d7d4-49f8-881f-b41601a7fe43',
'accessToken' => 'myRand0mAcc3ssT0k3n',
];
$response = $polling->getStatus($options);
echo $response
// This feature is not currently available in the Flutter SDK.
// Please use one of the other SDKs (PHP, Ruby, Python, NodeJs) or the REST API.
The request above results the following JSON payload when a Polling Result exists
- JSON
- Ruby
- Python
- JavaScript
- PHP
- Dart
{
"data": {
"id": "d4849121-d7d4-49f8-881f-b41601a7fe43",
"type": "polling",
"attributes": {
"status": "Success",
"created_at": "2021-04-28T11:25:53.497+03:00",
"from_time": "2021-04-12T08:50:22+03:00",
"to_time": "2021-04-19T08:50:22+03:00",
"transactions": [
{
"type": "Buygoods Transaction",
"resource": {
"id": "c4fbb520-9155-406e-aee8-661a07a49f86",
"amount": "500.0",
"status": "Received",
"system": "Lipa Na M-PESA",
"currency": "KES",
"reference": "APR202119",
"till_number": "000000",
"origination_time": "2021-04-19T08:19:00+03:00",
"sender_last_name": "Doe",
"sender_first_name": "Jane",
"sender_middle_name": "",
"sender_phone_number": "+254799999999"
}
},
{
"type": "Buygoods Transaction",
"resource": {
"id": "18f8da83-5d95-45f9-9670-1958a8fe1e30",
"amount": "500.0",
"status": "Received",
"system": "Lipa Na M-PESA",
"currency": "KES",
"reference": "APR202126",
"till_number": "K000000",
"origination_time": "2021-04-19T08:19:00+03:00",
"sender_last_name": "Doe",
"sender_first_name": "Jane",
"sender_middle_name": "",
"sender_phone_number": "+254799999999"
}
}
],
"scope": "Company",
"scope_reference": null,
"_links": {
"callback_url": "https://webhook.site/a67f60b8-8c26-40a2-866c-99f5314a3e0e",
"self": "https://sandbox.kopokopo.com/api/v2/polling/d4849121-d7d4-49f8-881f-b41601a7fe43"
}
}
}
}
{
"data": {
"id": "d4849121-d7d4-49f8-881f-b41601a7fe43",
"type": "polling",
"attributes": {
"status": "Success",
"created_at": "2021-04-28T11:25:53.497+03:00",
"from_time": "2021-04-12T08:50:22+03:00",
"to_time": "2021-04-19T08:50:22+03:00",
"transactions": [
{
"type": "Buygoods Transaction",
"resource": {
"id": "c4fbb520-9155-406e-aee8-661a07a49f86",
"amount": "500.0",
"status": "Received",
"system": "Lipa Na M-PESA",
"currency": "KES",
"reference": "APR202119",
"till_number": "000000",
"origination_time": "2021-04-19T08:19:00+03:00",
"sender_last_name": "Doe",
"sender_first_name": "Jane",
"sender_middle_name": "",
"sender_phone_number": "+254799999999"
}
},
{
"type": "Buygoods Transaction",
"resource": {
"id": "18f8da83-5d95-45f9-9670-1958a8fe1e30",
"amount": "500.0",
"status": "Received",
"system": "Lipa Na M-PESA",
"currency": "KES",
"reference": "APR202126",
"till_number": "K000000",
"origination_time": "2021-04-19T08:19:00+03:00",
"sender_last_name": "Doe",
"sender_first_name": "Jane",
"sender_middle_name": "",
"sender_phone_number": "+254799999999"
}
}
],
"scope": "Company",
"scope_reference": null,
"_links": {
"callback_url": "https://webhook.site/a67f60b8-8c26-40a2-866c-99f5314a3e0e",
"self": "https://sandbox.kopokopo.com/api/v2/polling/d4849121-d7d4-49f8-881f-b41601a7fe43"
}
}
}
}
{
"data": {
"id": "d4849121-d7d4-49f8-881f-b41601a7fe43",
"type": "polling",
"attributes": {
"status": "Success",
"created_at": "2021-04-28T11:25:53.497+03:00",
"from_time": "2021-04-12T08:50:22+03:00",
"to_time": "2021-04-19T08:50:22+03:00",
"transactions": [
{
"type": "Buygoods Transaction",
"resource": {
"id": "c4fbb520-9155-406e-aee8-661a07a49f86",
"amount": "500.0",
"status": "Received",
"system": "Lipa Na M-PESA",
"currency": "KES",
"reference": "APR202119",
"till_number": "000000",
"origination_time": "2021-04-19T08:19:00+03:00",
"sender_last_name": "Doe",
"sender_first_name": "Jane",
"sender_middle_name": "",
"sender_phone_number": "+254799999999"
}
},
{
"type": "Buygoods Transaction",
"resource": {
"id": "18f8da83-5d95-45f9-9670-1958a8fe1e30",
"amount": "500.0",
"status": "Received",
"system": "Lipa Na M-PESA",
"currency": "KES",
"reference": "APR202126",
"till_number": "K000000",
"origination_time": "2021-04-19T08:19:00+03:00",
"sender_last_name": "Doe",
"sender_first_name": "Jane",
"sender_middle_name": "",
"sender_phone_number": "+254799999999"
}
}
],
"scope": "Company",
"scope_reference": null,
"_links": {
"callback_url": "https://webhook.site/a67f60b8-8c26-40a2-866c-99f5314a3e0e",
"self": "https://sandbox.kopokopo.com/api/v2/polling/d4849121-d7d4-49f8-881f-b41601a7fe43"
}
}
}
}
{
"data": {
"id": "d4849121-d7d4-49f8-881f-b41601a7fe43",
"type": "polling",
"attributes": {
"status": "Success",
"created_at": "2021-04-28T11:25:53.497+03:00",
"from_time": "2021-04-12T08:50:22+03:00",
"to_time": "2021-04-19T08:50:22+03:00",
"transactions": [
{
"type": "Buygoods Transaction",
"resource": {
"id": "c4fbb520-9155-406e-aee8-661a07a49f86",
"amount": "500.0",
"status": "Received",
"system": "Lipa Na M-PESA",
"currency": "KES",
"reference": "APR202119",
"till_number": "000000",
"origination_time": "2021-04-19T08:19:00+03:00",
"sender_last_name": "Doe",
"sender_first_name": "Jane",
"sender_middle_name": "",
"sender_phone_number": "+254799999999"
}
},
{
"type": "Buygoods Transaction",
"resource": {
"id": "18f8da83-5d95-45f9-9670-1958a8fe1e30",
"amount": "500.0",
"status": "Received",
"system": "Lipa Na M-PESA",
"currency": "KES",
"reference": "APR202126",
"till_number": "K000000",
"origination_time": "2021-04-19T08:19:00+03:00",
"sender_last_name": "Doe",
"sender_first_name": "Jane",
"sender_middle_name": "",
"sender_phone_number": "+254799999999"
}
}
],
"scope": "Company",
"scope_reference": null,
"_links": {
"callback_url": "https://webhook.site/a67f60b8-8c26-40a2-866c-99f5314a3e0e",
"self": "https://sandbox.kopokopo.com/api/v2/polling/d4849121-d7d4-49f8-881f-b41601a7fe43"
}
}
}
}
<?
// The payload from the k2-connect-php SDK will look like this.
[
"status" => "success",
"data" => [
"id" => "d4849121-d7d4-49f8-881f-b41601a7fe43",
"type" => "polling",
"status" => "Success",
"createdAt" => "2021-04-28T11:25:53.497+03:00",
"fromTime" => "2021-04-12T08:50:22+03:00",
"toTime" => "2021-04-19T08:50:22+03:00",
"scope" => "Company",
"scopeReference" => null,
"transactions" => [
[
"type" => "Buygoods Transaction",
"resource" => [
"id" => "c4fbb520-9155-406e-aee8-661a07a49f86",
"amount" => "500.0",
"status" => "Received",
"system" => "Lipa Na M-PESA",
"currency" => "KES",
"reference" => "APR202119",
"till_number" => "000000",
"origination_time" => "2021-04-19T08:19:00+03:00",
"sender_last_name" => "Doe",
"sender_first_name" => "Jane",
"sender_middle_name" => "",
"sender_phone_number" => "+254799999999"
]
],
[
"type" => "Buygoods Transaction",
"resource" => [
"id" => "18f8da83-5d95-45f9-9670-1958a8fe1e30",
"amount" => "500.0",
"status" => "Received",
"system" => "Lipa Na M-PESA",
"currency" => "KES",
"reference" => "APR202126",
"till_number" => "K000000",
"origination_time" => "2021-04-19T08:19:00+03:00",
"sender_last_name" => "Doe",
"sender_first_name" => "Jane",
"sender_middle_name" => "",
"sender_phone_number" => "+254799999999"
]
]
],
"linkSelf" => "https://sandbox.kopokopo.com/api/v2/polling/d4849121-d7d4-49f8-881f-b41601a7fe43",
"callbackUrl" => "https://webhook.site/a67f60b8-8c26-40a2-866c-99f5314a3e0e",
]
]
// This feature is not currently available in the Flutter SDK.
// Please use one of the other SDKs (PHP, Ruby, Python, NodeJs) or the REST API.
With an Polling location url, you can query what the status of the Polling API is. If a corresponding Polling Result
exists, it will be bundled in the payload of the result.
HTTP Request
GET https://sandbox.kopokopo.com/api/v2/polling/
Accept: application/json
Content-Type: application/json
Authorization: Bearer 0Sn0W6kzNicvoWhDbQcVSKLRUpGjIdlPSEYyrHqrDDoRnQwE7Q
User-Agent: < product >/< product-version > < comment >
Query Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| ID | Yes | String | The reference / ID of the Polling to retrieve |
HTTP Response
Transactions JSON(Could be multiple)
| Parameter | Type | Description |
|---|---|---|
| type | String | The type of transaction (Buygoods Transaction) |
| resource | JSON | The resource corresponding to the event. In this case this is a Buygoods Transaction |
Resource (Buygoods Transaction) JSON
| Parameter | Type | Description |
|---|---|---|
| id | String | The api reference of the transaction |
| reference | String | The mpesa reference |
| status | String | The status of the transaction |
| origination_time | String | The transaction timestamp |
| sender_phone_number | String | The phone number that sent the payment |
| amount | Float | The amount of the transaction |
| currency | String | Currency |
| till_number | String | The till number to which the payment was made |
| system | String | The mobile money system |
| sender_first_name | String | First name of payer |
| sender_middle_name | String | Middle name of payer |
| sender_last_name | String | Last name of payer |