Customer to Business (C2B) API
C2B API enables SasaPay merchants to perform fund collection from diferent channels such as SasaPay,M-PESA,Airtel-Money,T-Kash and Banks.
❗ Note: All collected funds settle to Working Account Label.
1. C2B Payment Request from SasaPay User
As a merchant you can request or recieve funds from SasaPay registered users.This request transaction occurs from the user's SasaPay wallet account to the merchant's account.
When requesting payment from a SasaPay user, following steps are involved:
1. Enter SasaPay registered mobile number with network code as 0
.
2. Owner of the mobile number recieves One Time Password(OTP) to authorize the transaction.
3. Enter the OTP to process payment on the Process Payment
endpoint discussed below.
Endpoint: https://sandbox.sasapay.app/api/v1/payments/request-payment/
Request Parameters
Field | Type | Description | Example |
---|---|---|---|
MerchantCode | String | A unique number assigned to an organization/merchant registered with ViewTech, through which payment is received (can be Paybill or Till number) | 2****8 |
NetworkCode | String | A unique five digit code used for identifying the various mobile money providers. | 0 |
PhoneNumber | String | This is the phone number identifying a customer who is making the payment. | 07********8 |
TransactionDesc | String | Additional information/comment that can be sent along with the request from your system | Payment for shopping |
AccountReference | String | This is an identifier of the payment request transaction. | 07*******23452 |
Currency | String | Standardization that defines alpha codes and numeric codes for the representation of currencies | KES |
Amount | String | The amount of money to be requested from the customer. | 50.00 |
CallBackURL | URL | This is the URL where SasaPay will send the transaction status information i.e. Failed or Successfu. | https://pos******f7-b813 |
Headers
Key: Authorization
Value: Bearer Q1k2RW5SOGlsYUZnRzNGMk1DNlE1T1gzemFtY
Body :
{
"MerchantCode": "60***0",
"NetworkCode": "0",
"Transaction Fee": 0,
"Currency": "KES",
"Amount": "1.00",
"CallBackURL": "https://******1",
"PhoneNumber": "25470*****80",
"TransactionDesc": "Request Payment",
"AccountReference": "12345678"
}
Response Parameters
Field | Type | Description | Example |
---|---|---|---|
status | Bool | This is a true or false status that indicates the status of the response. true means success and false means an error occurred or the request failed.Please refer to the response codes table above. | true |
detail | String | A description of the response status sent by SasaPay API. | "OTP sent. Share the code to complete transaction" |
PaymentGateway | String | Service provider that authorizes payments processing | “SasaPay” |
MerchantRequestID | String | A unique identifier for a transaction between Merchant and SasaPay API. | "763df0f8-a815-40f5-b13f-cdb4632793e6" |
CheckoutRequestID | String | A unique identifier of the transaction request | "763df0f8-a815-40f5-b13f-cdb4632793e6" |
ResponseCode | String | A code identifying the type of response sent. 0 eans success and any other code means the transaction failed. | “0” |
ResponseDescription | String | Details describing the response sent | "Payment Request staged for processing successfully" |
CustomerMessage | String | The message to show how the payment can be done manually | Go to SasaPay App/USSD \n Select Paybill ... |
{
"status": true,
"detail": "OTP sent. Share the code to complete transaction",
"PaymentGateway": "SasaPay",
"MerchantRequestID": "07102440280",
"CheckoutRequestID": "b6cb451a-ef9f-443d-8e64-045c210131df",
"TransactionReference": "PR52****11",
"ResponseCode": "0",
"ResponseDescription": "Success. Request accepted for processing",
"CustomerMessage": " 1.GO TO SASAPAY APP OR DIAL *626# 2. SELECT 'PAY' 3. SELECT 'LIPA BILL' 4. ENTER BILLER NUMBER: '413554' 5. ENTER ACCOUNT REFERENCE: 'PR1686' 6. ENTER AMOUNT:KSH '1' 7. ENTER YOUR SASAPAY PIN"
}
2. Process Payment
Use this endpoint if you made a C2B payment request from a SasaPay registered mobile number.This endpoint requires and OTP received when you initiated the request in order to process the transaction.
Endpoint: https://sandbox.sasapay.app/api/v1/payments/process-payment/
Field | Type | Description | Example |
---|---|---|---|
MerchantCode | String | A unique number assigned to an organization/merchant registered with ViewTech, through which payment is received (can be Paybill or Till number) | 60**80 |
CheckoutRequestID | String | A unique identifier of the transaction request generated by SasaPay API. | 763df0f8-a815-40f5-b13f-cdb4632793e6 |
VerificationCode | String | This is a 6 digit code sent to a mobile number making payment. This is the code the authorizes processing of the transaction. | 123456 |
Headers
Key: Authorization
Value: Bearer Q1k2RW5SOGlsYUZnRzNGMk1DNlE1T1gzemFtY
Body:
{
"CheckoutRequestID": "5fb0db20-2550-4612-bb7d-71bf0a4e25f6",
"MerchantCode": "600980",
"VerificationCode": "525474"
}
Response Parameters
Field | Type | Description | Example |
---|---|---|---|
status | Bool | This is a true or false status that indicates the status of the response. true means success and false means an error occurred or the request failed.Please refer to the response codes table above. | true |
detail | String | This is the message from the API describing the status of the transaction. | "Transaction submitted for processing" |
{
"status": true,
"detail": "Transaction is being processed"
}
C2B Payment Request from Mobile Money
As as SasaPay merchant, you also able to request payments from Non- SasaPay registered users through M-PESA,Airtel Money, T-kash and Bank.
Kindly note, when using this endpoint OTP is not sent instead, the owner of the mobile receives an STK prompt depending on the network code you entered.Fro bank requests, a transaction reference is given on the API response and the customer must use this reference as Narration
during pesalink payment on the Bank app or direct walk-in.
Endpoint: https://sandbox.sasapay.app/api/v1/payments/request-payment/
Request Parameters
Field | Type | Description | Example |
---|---|---|---|
MerchantCode | String | A unique number assigned to an organization/merchant registered with ViewTech, through which payment is received (can be Paybill or Till number) | 2****8 |
NetworkCode | String | A unique five digit code used for identifying the various mobile money providers. | 63902(MPesa) 63903(AirtelMoney) 63907(T-Kash) |
PhoneNumber | String | This is the phone number identifying a customer who is making the payment. | 07********8 |
TransactionDesc | String | Additional information/comment that can be sent along with the request from your system | “Payment for shopping” |
AccountReference | String | This is an identifier of the payment request transaction. | 07*******23452 |
Currency | String | Standardization that defines alpha codes and numeric codes for the representation of currencies | KES |
Amount | String | The amount of money to be requested from the customer. | 50.00 |
Transaction Fee | String | Amount charged when processing | 0 |
CallBackURL | URL | This is the URL where SasaPay will send the results after the payment process is completed. This is provided when creating the application. | https://pos******f7-b813 |
Headers
Key: Authorization
Value: Bearer Q1k2RW5SOGlsYUZnRzNGMk1DNlE1T1gzemFtY
Body :
{
"MerchantCode": "60***0",
"NetworkCode": "63902",
"Transaction Fee":"0",
"Currency": "KES",
"Amount": "1.00",
"CallBackURL": "https://******1",
"PhoneNumber": "25470*****80",
"TransactionDesc": "Request Payment",
"AccountReference": "12345678"
}
Response Parameters
Field | Type | Description | Example |
---|---|---|---|
status | Bool | This is a true or false status that indicates the status of the response. true means success and false means an error occurred or the request failed.Please refer to the response codes table above. | true |
detail | String | A description of the response status sent by SasaPay API. | "OTP sent. Share the code to complete transaction" |
PaymentGateway | String | Service provider that authorizes payments processing | “SasaPay” |
MerchantRequestID | String | A unique identifier for a transaction between Merchant and SasaPay API. | "763df0f8-a815-40f5-b13f-cdb4632793e6" |
CheckoutRequestID | String | A unique identifier of the transaction request | "763df0f8-a815-40f5-b13f-cdb4632793e6" |
ResponseCode | String | A code identifying the type of response sent. 0 eans success and any other code means the transaction failed. | “0” |
ResponseDescription | String | Details describing the response sent | "Payment Request staged for processing successfully" |
CustomerMessage | string | The message to show how the payment can be done manually | Go to SasaPay App/USSD \n Select Paybill ... |
{
"status": true,
"detail": "STK Push sent. Enter your PIN to complete transaction",
"PaymentGateway": "M-PESA",
"MerchantRequestID": "0***0280",
"CheckoutRequestID": "1251ce9d-8afc-4b41-a47b-a86e39ef1fa7",
"TransactionReference": "PR52****11",
"ResponseCode": "0",
"ResponseDescription": "Success. STK PUSH SENT",
"CustomerMessage": "1. GO TO 'M-PESA' 2. SELECT 'PAY BILL' 3. ENTER BUSINESS NUMBER: 756756 4. ENTER ACCOUNT NUMBER: PR1718 5. ENTER AMOUNT:1 6. ENTER YOUR M-PESA PIN AND PRESS OK"
}
C2B Callback Results
After the payment request is processed, the RESULTS are sent to the API which forwards these results to your system through the callback URL sent with the initial request.
Results Parameters
Field | Type | Description | Example |
---|---|---|---|
MerchantRequestID | String | The unique id sent with the transaction request from the Merchant system | "25*******77" |
CustomerMobile | String | This mobile number from where the funds are requested | "2547*******7" |
ResultCode | String | The numeric status of the results, sent to the callback url | 0 means success, while any other code indicates that an error occurred. The specific error is describe in the ResultDesc field |
ResultDesc | String | This is a message from the API that gives the status of the request processing and usually maps to a specific result code value. | "Transaction processed successfully." |
CheckoutRequestID | String | This is a unique SasaPay transaction ID for every payment request. Same value is sent to the customer over SMS upon successful processing. | "6f3ebd0d-b892-4c4e-952a-f3eea030af85" |
BillRefNumber | String | This is a unique SasaPay transaction ID for every payment request. Same value is sent to the customer over SMS upon successful processing. It is usually returned under the ResultParameter array. | PR52 |
TransAmount | String | This is the amount that was transacted. It is usually returned under the ResultParameter array. | "10.00" |
TransactionDate | String | This is the date and time that the transaction completed SasaPay. | "20220305103101" |
ThirdPartyTransID | String | This is the transaction refrence from third party systems SasaPay. |
{
"MerchantRequestID": "Test callbacks",
"CheckoutRequestID": "542011ce-24a8-****-b0e7-c4df09e18d74",
"PaymentRequestID": "PR6**3",
"ResultCode": "0",
"ResultDesc": "Transaction processed successfully.",
"SourceChannel": "M-PESA",
"TransAmount": "1.00",
"BillRefNumber": "Test callbacks",
"TransactionDate": "20240701105155",
"CustomerMobile": "25470******0",
"TransactionCode": "SPEJ***0O78GY2T",
"ThirdPartyTransID": "SG1****1T5G"
}
Instant Payment Notification (IPN)
Instant Payment Notification (IPN) is a service that automatically notifies merchants when a transaction is resolved/processed by SasaPay. As a merchant, you can use IPN to automate back-office and administrative functions, including automatically fulfilling orders and providing customers with order status. SasaPay’s IPN is sent to the callback url you supplied when creating the application (either WaaS, or C2B, B2C, and B2B).
IPN Parameters
Field | Type | Description | Example |
---|---|---|---|
InvoiceNumber | String | An identifier of the transaction, usually sent to the customer’s mobile number. | "INV278RID6754" |
PaymentMethod | String | The channel through which the payment was made. | SasaPay |
TransID | String | This is an object containing the details of the transaction. | CDVISAIHD |
ThirdPartyTransID | String | 7***2 | |
FullName | String | This is the Full Name of the customer making the payment, as per the SasaPay registration. | "John Kym Doe" |
FirstName | String | This is the First Name of the customer making the payment, as per the SasaPay registration | “John” |
MiddleName | String | This is the Middle Name of the customer making the payment, as per the SasaPay registration | "Kym" |
LastName | String | This is the Last Name of the customer making the payment, as per the SasaPay registration. | “Doe” |
MSISDN | String | This is the mobile number of the customer who was involved in the payment transaction. | 2547****1235 |
OrgAccountBalance | String | The Amount of money available on the wallet for a specific MerchantCode | 176.00 |
TransAmount | String | The amount of money transacted. | 350.00 |
TransactionType | String | An identifier of the type of transaction. It can be with C2B, B2B, B2C, or SasaPay Payment Request | C2B |
TransTime | String | This is the Timestamp of the transaction. | 20240703062353 |
BillRefNumber | String | This is a unique transaction identifier which is sent with the request from the Merchant’s system. | 12345 |
{
"MerchantCode": "6****8",
"BusinessShortCode": "6****8",
"InvoiceNumber": "INV-278-RID-6754",
"PaymentMethod": "SasaPay",
"TransID": "CDVISAIHD",
"ThirdPartyTransID": "7***2",
"FullName": "John kym Doe",
"FirstName": "John",
"MiddleName": "kym",
"LastName": "Doe",
"TransactionType": "C2B",
"MSISDN": "2547*****5",
"OrgAccountBalance": "10.00",
"TransAmount": "10.00",
"TransTime": "20240703062353",
"BillRefNumber": "12345"
}