Skip to main content

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.

Alt test Endpoint: https://sandbox.sasapay.app/api/v1/payments/request-payment/

Request Parameters

FieldTypeDescriptionExample
MerchantCodeStringA unique number assigned to an organization/merchant registered with ViewTech, through which payment is received (can be Paybill or Till number)2****8
NetworkCodeStringA unique five digit code used for identifying the various mobile money providers.0
PhoneNumberStringThis is the phone number identifying a customer who is making the payment.07********8
TransactionDescStringAdditional information/comment that can be sent along with the request from your systemPayment for shopping
AccountReferenceStringThis is an identifier of the payment request transaction.07*******23452
CurrencyStringStandardization that defines alpha codes and numeric codes for the representation of currenciesKES
AmountStringThe amount of money to be requested from the customer.50.00
CallBackURLURLThis is the URL where SasaPay will send the transaction status information i.e. Failed or Successfu.https://pos******f7-b813
Request sample
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

FieldTypeDescriptionExample
statusBoolThis 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
detailStringA description of the response status sent by SasaPay API."OTP sent. Share the code to complete transaction"
PaymentGatewayStringService provider that authorizes payments processing“SasaPay”
MerchantRequestIDStringA unique identifier for a transaction between Merchant and SasaPay API."763df0f8-a815-40f5-b13f-cdb4632793e6"
CheckoutRequestIDStringA unique identifier of the transaction request"763df0f8-a815-40f5-b13f-cdb4632793e6"
ResponseCodeStringA code identifying the type of response sent. 0 eans success and any other code means the transaction failed.“0”
ResponseDescriptionStringDetails describing the response sent"Payment Request staged for processing successfully"
CustomerMessageStringThe message to show how the payment can be done manuallyGo to SasaPay App/USSD \n Select Paybill...
Response Sample
{
"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.

Alt test Endpoint: https://sandbox.sasapay.app/api/v1/payments/process-payment/

FieldTypeDescriptionExample
MerchantCodeStringA unique number assigned to an organization/merchant registered with ViewTech, through which payment is received (can be Paybill or Till number)60**80
CheckoutRequestIDStringA unique identifier of the transaction request generated by SasaPay API.763df0f8-a815-40f5-b13f-cdb4632793e6
VerificationCodeStringThis is a 6 digit code sent to a mobile number making payment. This is the code the authorizes processing of the transaction.123456
Sample Request
Headers
Key: Authorization
Value: Bearer Q1k2RW5SOGlsYUZnRzNGMk1DNlE1T1gzemFtY
Body:
{
"CheckoutRequestID": "5fb0db20-2550-4612-bb7d-71bf0a4e25f6",
"MerchantCode": "600980",
"VerificationCode": "525474"
}

Response Parameters

FieldTypeDescriptionExample
statusBoolThis 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
detailStringThis is the message from the API describing the status of the transaction."Transaction submitted for processing"
Response Sample
{
"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.

Alt test Endpoint: https://sandbox.sasapay.app/api/v1/payments/request-payment/

Request Parameters

FieldTypeDescriptionExample
MerchantCodeStringA unique number assigned to an organization/merchant registered with ViewTech, through which payment is received (can be Paybill or Till number)2****8
NetworkCodeStringA unique five digit code used for identifying the various mobile money providers.63902(MPesa) 63903(AirtelMoney) 63907(T-Kash)
PhoneNumberStringThis is the phone number identifying a customer who is making the payment.07********8
TransactionDescStringAdditional information/comment that can be sent along with the request from your system“Payment for shopping”
AccountReferenceStringThis is an identifier of the payment request transaction.07*******23452
CurrencyStringStandardization that defines alpha codes and numeric codes for the representation of currenciesKES
AmountStringThe amount of money to be requested from the customer.50.00
Transaction FeeStringAmount charged when processing0
CallBackURLURLThis 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
Request sample
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

FieldTypeDescriptionExample
statusBoolThis 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
detailStringA description of the response status sent by SasaPay API."OTP sent. Share the code to complete transaction"
PaymentGatewayStringService provider that authorizes payments processing“SasaPay”
MerchantRequestIDStringA unique identifier for a transaction between Merchant and SasaPay API."763df0f8-a815-40f5-b13f-cdb4632793e6"
CheckoutRequestIDStringA unique identifier of the transaction request"763df0f8-a815-40f5-b13f-cdb4632793e6"
ResponseCodeStringA code identifying the type of response sent. 0 eans success and any other code means the transaction failed.“0”
ResponseDescriptionStringDetails describing the response sent"Payment Request staged for processing successfully"
CustomerMessagestringThe message to show how the payment can be done manuallyGo to SasaPay App/USSD \n Select Paybill...
Response Sample
{
"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

FieldTypeDescriptionExample
MerchantRequestIDStringThe unique id sent with the transaction request from the Merchant system"25*******77"
CustomerMobileStringThis mobile number from where the funds are requested"2547*******7"
ResultCodeStringThe numeric status of the results, sent to the callback url0 means success, while any other code indicates that an error occurred. The specific error is describe in the ResultDesc field
ResultDescStringThis 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."
CheckoutRequestIDStringThis 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"
BillRefNumberStringThis 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
TransAmountStringThis is the amount that was transacted. It is usually returned under the ResultParameter array."10.00"
TransactionDateStringThis is the date and time that the transaction completed SasaPay."20220305103101"
ThirdPartyTransIDStringThis is the transaction refrence from third party systems SasaPay.
Result sample
{
"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

FieldTypeDescriptionExample
InvoiceNumberStringAn identifier of the transaction, usually sent to the customer’s mobile number."INV278RID6754"
PaymentMethodStringThe channel through which the payment was made.SasaPay
TransIDStringThis is an object containing the details of the transaction.CDVISAIHD
ThirdPartyTransIDString7***2
FullNameStringThis is the Full Name of the customer making the payment, as per the SasaPay registration."John Kym Doe"
FirstNameStringThis is the First Name of the customer making the payment, as per the SasaPay registration“John”
MiddleNameStringThis is the Middle Name of the customer making the payment, as per the SasaPay registration"Kym"
LastNameStringThis is the Last Name of the customer making the payment, as per the SasaPay registration.“Doe”
MSISDNStringThis is the mobile number of the customer who was involved in the payment transaction.2547****1235
OrgAccountBalanceStringThe Amount of money available on the wallet for a specific MerchantCode176.00
TransAmountStringThe amount of money transacted.350.00
TransactionTypeStringAn identifier of the type of transaction. It can be with C2B, B2B, B2C, or SasaPay Payment RequestC2B
TransTimeStringThis is the Timestamp of the transaction.20240703062353
BillRefNumberStringThis is a unique transaction identifier which is sent with the request from the Merchant’s system.12345
Sample
{
"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"
}