Transaction SMS Notifications
Transaction SMS Notifications API Requests (Deprecated)
Send sms notifications to your customer after you have received a payment from them.
POST https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications
Content-Type: application/json
Accept: application/json
Authorization: Bearer < AccessToken >
User-Agent: "< product >/< product-version > < comment >"
- JSON
- Ruby
- Python
- JavaScript
- PHP
- Dart
{
"webhook_event_reference": "e51438e9-c42b-4bf2-a261-faeaf189e3ed",
"message": "Your message here",
"_links": {
"callback_url": "https://webhook.site/a67f60b8-8c26-40a2-866c-99f5314a3e0e"
}
}
# Using K2Connect - https://github.com/kopokopo/k2-connect-ruby (Recommended)
your_input =
{
webhook_event_reference: "e51438e9-c42b-4bf2-a261-faeaf189e3ed",
message: "Your message here",
callback_url: 'https://call_back_to_your_app.your_application.com'
}
k2_notification = k2Notification.new("your_access_token")
k2_notification.transaction_sms_notifications(your_input)
k2_notification.location_url # => "https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/247b1bd8-f5a0-4b71-a898-f62f67b8ae1c"
request_body =
{
"access_token": ACCESS_TOKEN,
"callback_url": "https://webhook.site/52fd1913-778e-4ee1-bdc4-74517abb758d",
"webhook_event_reference": "e51438e9-c42b-4bf2-a261-faeaf189e3ed",
"message": "Your message here"
}
# Using K2Connect - https://github.com/kopokopo/k2-connect-python (Recommended)
k2connect.initialize(environ.get('CLIENT_ID'), environ.get('CLIENT_SECRET'), 'sandbox.kopokopo.com')
notification_service = k2connect.SmsNotificationService
notification_location = notification_service.transaction_sms_notifications(request_body)
notification_location # => 'https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/247b1bd8-f5a0-4b71-a898-f62f67b8ae1c'
const SmsNotificationService = K2.SmsNotificationService
var notificationOptions = {
webhookEventReference: 'e51438e9-c42b-4bf2-a261-faeaf189e3ed',
message: 'Your message here',
callbackUrl: 'https://callback_to_your_app.your_application.com/endpoint',
accessToken: 'myRand0mAcc3ssT0k3n'
}
SmsNotificationService
.sendTransactionSmsNotification(notificationOptions)
.then( response => {
console.log(response)
// => 'https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/247b1bd8-f5a0-4b71-a898-f62f67b8ae1c'
})
.catch( error => {
console.log(error)
})
<?
$sms_notifications = $K2->SmsNotificationService();
$response = $sms_notifications->sendTransactionSmsNotification([
'webhookEventReference' => 'e51438e9-c42b-4bf2-a261-faeaf189e3ed',,
'message' => 'Your message here',
'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/v1/transaction_sms_notifications/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/v1/transaction_sms_notifications
Accept: application/json
Content-Type: application/json
Authorization: Bearer 0Sn0W6kzNicvoWhDbQcVSKLRUpGjIdlPSEYyrHqrDDoRnQwE7Q
User-Agent: < product >/< product-version > < comment >
Request Parameters (JSON)
| Parameter | Required | Type | Description |
|---|---|---|---|
| webhook_event_reference | yes | String | This is the id of the webhook payload you got |
| message | Yes | String | A string containing the message you want to send to the customer |
| _links | Yes | JSON | A JSON object containing the callback_url where the result of the Transaction Notification 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 Transaction Notification API Request
HTTP/1.1 201 Created
Location: https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/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": "Message can't be blank" }
Process Transaction Notification API Result
POST https://your-callback-url.com/api/v1/transaction_notification_result
Content-Type: application/json
X-KopoKopo-Signature: 0Sn0W6kzNicvoWhDbQcVSKLRUpGjIdlPSEYyrHqrDDoRnQwE7Q
User-Agent: < product >/< product-version > < comment >
- JSON
- Ruby
- Python
- JavaScript
- PHP
- Dart
{
"data": {
"id": "a48ad0a7-b43b-48c5-9ff8-509552d603af",
"type": "transaction_sms_notification",
"attributes": {
"status": "Success",
"message": "Your message here",
"webhook_event_reference": "4b46f88a-31f6-4af2-8795-b11ef1f3b846",
"_links": {
"callback_url": "https://webhook.site/a67f60b8-8c26-40a2-866c-99f5314a3e0e",
"self": "https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/a48ad0a7-b43b-48c5-9ff8-509552d603af"
}
}
}
}
transaction_sms_notifications = K2Client.new("API_KEY")
transaction_sms_notifications.parse_request(request)
transaction_notification_object = K2ProcessResult.process(transaction_sms_notifications.hash_body, API_KEY, transaction_sms_notifications.k2_signature)
# Processed transaction_sms_notifications result in json format
{
"data": {
"id": "a48ad0a7-b43b-48c5-9ff8-509552d603af",
"type": "transaction_sms_notification",
"attributes": {
"status": "Success",
"message": "Your message here",
"webhook_event_reference": "4b46f88a-31f6-4af2-8795-b11ef1f3b846",
"_links": {
"callback_url": "https://webhook.site/a67f60b8-8c26-40a2-866c-99f5314a3e0e",
"self": "https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/a48ad0a7-b43b-48c5-9ff8-509552d603af"
}
}
}
}
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 transaction_sms_notifications result in json format
{
"data": {
"id": "a48ad0a7-b43b-48c5-9ff8-509552d603af",
"type": "transaction_sms_notification",
"attributes": {
"status": "Success",
"message": "Your message here",
"webhook_event_reference": "4b46f88a-31f6-4af2-8795-b11ef1f3b846",
"_links": {
"callback_url": "https://webhook.site/a67f60b8-8c26-40a2-866c-99f5314a3e0e",
"self": "https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/a48ad0a7-b43b-48c5-9ff8-509552d603af"
}
}
}
}
{
"data": {
"id": "a48ad0a7-b43b-48c5-9ff8-509552d603af",
"type": "transaction_sms_notification",
"attributes": {
"status": "Success",
"message": "Your message here",
"webhook_event_reference": "4b46f88a-31f6-4af2-8795-b11ef1f3b846",
"_links": {
"callback_url": "https://webhook.site/a67f60b8-8c26-40a2-866c-99f5314a3e0e",
"self": "https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/a48ad0a7-b43b-48c5-9ff8-509552d603af"
}
}
}
}
<?
// The payload from the k2-connect-php SDK will look like this.
[
"status" => "success",
"data" => [
"id" => "a48ad0a7-b43b-48c5-9ff8-509552d603af",
"type" => "transaction_sms_notification",
"status" => "Success",
"message" =>"Your message here",
"webhookEventReference" => "4b46f88a-31f6-4af2-8795-b11ef1f3b846",
"linkSelf" => "https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/a48ad0a7-b43b-48c5-9ff8-509552d603af",
"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 transaction notification is sent, a Transaction Notification Result will be posted asynchronously to the call back URL specified in the Transaction Notification request.
Transaction Notification Result Parameters (JSON)
Parameters contained in a transaction notification result;
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The ID of the Transaction Notification API Request |
| type | Yes | String | The topic of the request. transaction_sms_notifications in this instance. |
| status | Yes | String | A status string denoting the status of the Transaction Notification Request |
| message | Yes | String | A string containing the message you sent |
| webhook_event_reference | No | String | An JSON object containing the transactions from the query with the specified parameters |
| _links | Yes | JSON | A JSON object containing links to the Transaction Notification API request |
Query Transaction Notification API Status
GET https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/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
notification_url = 'https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/a48ad0a7-b43b-48c5-9ff8-509552d603af'
# Using K2 Connect - https://github.com/kopokopo/k2-connect-ruby (Recommended)
k2_notification = k2Notification.new("your_access_token")
k2_notification.transaction_sms_notifications(your_input)
# Query specific resource
k2_notification.query_resource(notification_url) or k2_notification.query_resource(k2_notification.location_url)
# Query recent transaction
k2_notification.query_status
notificationUrl = 'https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/a48ad0a7-b43b-48c5-9ff8-509552d603af'
# Using K2 Connect - https://github.com/kopokopo/k2-connect-python (Recommended)
k2connect.initialize(environ.get('CLIENT_ID'), environ.get('CLIENT_SECRET'), 'sandbox.kopokopo.com')
notification_service = k2connect.SmsNotificationService
notification_location = notification_service.notification_status(access_token, notificationUrl)
var SmsNotificationService = K2.SmsNotificationService
var notificationUrl = 'https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/a48ad0a7-b43b-48c5-9ff8-509552d603af'
SmsNotificationService
.getStatus({accessToken: 'myRand0mAcc3ssT0k3n', location: notificationUrl})
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error)
})
<?
$sms_notifications = $K2->SmsNotificationService();
$options = [
'location' => 'https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/a48ad0a7-b43b-48c5-9ff8-509552d603af',
'accessToken' => 'myRand0mAcc3ssT0k3n',
];
$response = $transaction_sms_notifications->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 Transaction Notification Result exists
- JSON
- Ruby
- Python
- JavaScript
- PHP
- Dart
{
"data": {
"id": "a48ad0a7-b43b-48c5-9ff8-509552d603af",
"type": "transaction_sms_notification",
"attributes": {
"status": "Success",
"message": "Your message here",
"webhook_event_reference": "4b46f88a-31f6-4af2-8795-b11ef1f3b846",
"_links": {
"callback_url": "https://webhook.site/a67f60b8-8c26-40a2-866c-99f5314a3e0e",
"self": "https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/a48ad0a7-b43b-48c5-9ff8-509552d603af"
}
}
}
}
{
"data": {
"id": "a48ad0a7-b43b-48c5-9ff8-509552d603af",
"type": "transaction_sms_notification",
"attributes": {
"status": "Success",
"message": "Your message here",
"webhook_event_reference": "4b46f88a-31f6-4af2-8795-b11ef1f3b846",
"_links": {
"callback_url": "https://webhook.site/a67f60b8-8c26-40a2-866c-99f5314a3e0e",
"self": "https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/a48ad0a7-b43b-48c5-9ff8-509552d603af"
}
}
}
}
{
{
"data": {
"id": "a48ad0a7-b43b-48c5-9ff8-509552d603af",
"type": "transaction_sms_notification",
"attributes": {
"status": "Success",
"message": "Your message here",
"webhook_event_reference": "4b46f88a-31f6-4af2-8795-b11ef1f3b846",
"_links": {
"callback_url": "https://webhook.site/a67f60b8-8c26-40a2-866c-99f5314a3e0e",
"self": "https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/a48ad0a7-b43b-48c5-9ff8-509552d603af"
}
}
}
}
{
"data": {
"id": "a48ad0a7-b43b-48c5-9ff8-509552d603af",
"type": "transaction_sms_notification",
"attributes": {
"status": "Success",
"message": "Your message here",
"webhook_event_reference": "4b46f88a-31f6-4af2-8795-b11ef1f3b846",
"_links": {
"callback_url": "https://webhook.site/a67f60b8-8c26-40a2-866c-99f5314a3e0e",
"self": "https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/a48ad0a7-b43b-48c5-9ff8-509552d603af"
}
}
}
}
<?
// The payload from the k2-connect-php SDK will look like this.
[
"status" => "success",
"data" => [
"id" => "a48ad0a7-b43b-48c5-9ff8-509552d603af",
"type" => "transaction_sms_notification",
"status" => "Success",
"message" =>"Your message here",
"webhookEventReference" => "4b46f88a-31f6-4af2-8795-b11ef1f3b846",
"linkSelf" => "https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/a48ad0a7-b43b-48c5-9ff8-509552d603af",
"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 Transaction Sms Notification location url, you can query what the status of the Transaction Notification is. If a corresponding Transaction Sms Notification Result
exists, it will be bundled in the payload of the result.
HTTP Request
GET https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/
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 Transaction Sms Notification to retrieve |