Kenya🇰🇪
Interface Description
Access flow chart

X-API-KEY
carries your public key, and we use this public key to verify that the message is signed by your private key.X-RESP-SIGNATURE
in the request header. You can use it. The system publicKey verification message is sent by us.common problem
1.
2.
3.
Signature algorithm

Tarspay's API requests, except for public APIs, need to carry API key and signature.
HTTP_METHOD + | + HTTP_REQUEST_PATH + | + TIMESTAMP + | + PARAMS
HTTP_HOST
HTTP_METHOD
HTTP_REQUEST_PATH
NONCE
PARAMS
Complete example
Method | URL | Nonce |
---|---|---|
POST | https://payment.tarspay.pro/api/v1/test | 1537498830736 |
Parameter | value |
---|---|
amount | 100 |
price | 100 |
1.
Tip: content does not require URLEncode
2.
3.
The LarkPay signature verification public key can be obtained from the "Web Management Interface - Account Management - apikey" page
Return description
Return results
Name | Type | Description |
---|---|---|
code | integer | Response code 0 indicates success, otherwise failure |
data | object | response data |
msg | string | Response message |
Return to example
{
"code": 0,
"data": {},
"msg": "SUCCESS"
}
Collection
Collection type
Payment method code
Encoding | Description |
---|---|
bank | bank_account |
store | store payment |
va | VA payment |
POST collection and unified order placement
Body request parameters
{
"amount": "100",
"body": "your productinfo",
"currency": "KES",
"mchNo": "80002",
"mchOrderNo": "M202207131958",
"notifyUrl": "https://www.yourcompany.com/notify",
"returnUrl": "https://www.yourcompany.com/return",
"subject": "your subject",
"wayCode": "CASHIER",
"customerName":" your name",
"customerEmail":"xxxxx@xx.com"
}
Request parameters
Name | Location | Type | Required | Description |
---|---|---|---|---|
X-API-KEY | header | string | Y | public key |
X-API-NONCE | header | string | Y | request time (timestamp, accurate to milliseconds) |
X-API-SIGNATURE | header | string | Y | signature (refer to signature algorithm) |
mchNo | body | string | Y | merchant number |
mchOrderNo | body | string | Y | merchant order number (customized by merchant, cannot be repeated) |
wayCode | body | string | Y | payment method code - Cashier: CASHIER (use the cashier of this system) - Non-cashier: refer to [Payment method code] (#Payment method code) (The merchant maintains the checkout counter himself) |
amount | body | string | Y | the amount (no decimals. It cannot be zero and must meet the amount standard.) |
body | body | string | Y | product Description Information |
currency | body | string | Y | currency(KES) |
notifyUrl | body | string | Y | notification address |
returnUrl | body | string | Y | return address |
customerName | body | string | N | username |
customerEmail | body | string | N | user Email |
customerContact | body | string | N | user phone |
Return to example
{
"code": 0,
"data": {
"amount": "5000",
"countryCode": "ke",
"currency": "KES",
"customerContact": "662201111111",
"mchOrderNo": "202207161603q01",
"orderState": 0,
"payOrderId": "P1551396771600912385",
"payUrl": "https://example.com/#/order/th/P1551396771600912385",
"payWays": {
"ewallet":[{"countryCode":"ke","createdAt":0,"id":143,"payWay":"EWALLET_MPESA","payWayLogo":"https://defipay.oss-ap-southeast-1.aliyuncs.com/SEA.png","payWayType":"ewallet","skipMode":2,"state":1,"updatedAt":0}]
}
},
"msg": "SUCCESS",
"sign": "3045022100f32d38d4457295f0ce70376845458ec55a9fad34cce39ae11cd0cdbadd90639e02207d23e33f9b95944fb32923707c30b913063b082995b7e5fb9d8d2369f1ab4e53"
}
Return results
Name | Type | Description |
---|---|---|
amount | string | Bill amount |
countryCode | string | Country code |
currency | string | currency number |
customerContact | string | User contact information |
mchOrderNo | string | Merchant order number |
orderState | integer | Order status 0: order generated, 1: payment in progress, 2: payment successful, 3: payment failed, 6: timeout cancellation, 9: partial payment |
payOrderId | string | Payment order number |
accountName | string | User name, non-cashier mode, only returned when the payment method is online banking, e-wallet and scan code |
typeBank | string | Bank name, non-cashier mode, only returned when the payment method is online banking and scanning QR code |
accountNumber | string | User name, non-cashier mode, only returned when the payment method is online banking, scan code and electronic wallet |
payUrl | string | -When in cashier mode, return the cashier address; -When in non-cashier mode, return the transfer required content |
payData | string | QR code (returned only when not at the cashier, only returned when the payment method is scan code and electronic wallet) |
payWays | array | Payment methods |
Name | Type | Description |
---|---|---|
countryCode | string | Country code |
payWay | string | Payment method code (refer to [Payment method code](#Payment method code)) |
payWayLogo | string | Payment method logo |
payWayType | string | Payment method type (refer to [Collection Type](#Collection Type)) |
payCode | string | QR code/QR code image (returned only when not at the cashier). When the payment type is qr, the QR code image link is returned. When the payment type is ewallet, the QR code data is returned. ) |
POST payment for unified order placement
Body request parameters
{
"amount": "40",
"customerAccountNumber": "922010002523675",
"customerContact": "xxxx",
"mchNo": "80001",
"mchOrderNo": "2022071201011",
"notifyUrl": "http://www.yourcompany.com/notify",
"wayCode": "BANXICO",
"currency": "KES",
"body":"your productinfo"
}
Request parameters
Name | Location | Type | Required | Description |
---|---|---|---|---|
X-API-KEY | header | string | Y | public key |
X-API-NONCE | header | string | Y | Request time (timestamp, accurate to milliseconds) |
X-API-SIGNATURE | header | string | Y | signature (refer to signature algorithm) |
mchNo | body | string | Y | merchant number |
mchOrderNo | body | string | Y | Merchant order number (customized by merchant, cannot be repeated) |
wayCode | body | string | Y | payment code (refer to [payment code](#payment code)) |
amount | body | string | Y | the amount (no decimals. It cannot be zero and must meet the amount standard.) |
currency | body | string | Y | currency(KES) |
notifyUrl | body | string | Y | notification address |
customerName | body | string | Y | username |
customerContact | body | string | Y | Mobile phone number |
customerAccountNumber | body | string | Y | user accountNumber |
customerEmail | body | string | Y | user email |
{
"code": 0,
"data": {
"mchOrderNo": "M1655535407",
"payOrderId": "P1551409540398772225"
},
"msg": "SUCCESS",
"sign": "3045022100c3998421fd646521777d0c736753704931f801331dec55f109258dd8a93083c402207c11e37d70477b30ad9e0c42072a3fb5af1a78809ca7f 8023672451e62e8f69f"
}
Return results
Name | Type | Description |
---|---|---|
mchOrderNo | string | Merchant order number (returned after successful request) |
payOrderId | string | Platform order number (returned after successful request) |
Collection order inquiry
POST to obtain collection order information
Body request parameters
{
"mchNo": "M1655535407",
"mchOrderNo": "lin1231241241414"
}
Request parameters
Name | Location | Type | Required | Description |
---|---|---|---|---|
X-API-KEY | header | string | Y | public key |
X-API-NONCE | header | string | Y | Request time (timestamp, accurate to milliseconds) |
X-API-SIGNATURE | header | string | Y | signature (refer to signature algorithm) |
mchNo | body | string | Y | merchant number |
payOrderId | body | string | N | Platform order number (choose one of platform order number and merchant order number) |
mchOrderNo | body | string | N | Merchant order number (choose one of platform order number and merchant order number) |
Return to example
{
"code": 0,
"data": {
"currency": "KES"
"fee": "0",
"mchNo": "M1655535407",
"mchOrderNo": "",
"orderAmount": "10000",
"payAmount": "10000",
"payOrderId": "P1547429458697129178",
"state": 2
},
"msg": "SUCCESS"
}
Return results
Name | Type | Description |
---|---|---|
payOrderId | string | Payment order number |
mchNo | string | Merchant number |
mchOrderNo | string | Merchant order number |
orderAmount | string | original transaction amount of bill |
payAmount | string | Payment amount |
currency | string | three-digit currency code |
state | string | Payment status: 0-Order generated, 1-Payment in progress, 2-Payment successful, 3-Payment failed, 4-Cancelled, 5-Refunded, 6-Order closed, 7-Queue, 8 -We reject, 9-Partial payment |
fee | string | Merchant fee |
Payment order inquiry
POST Get payment order information
Body request parameters
{
"mchNo": "M1655535407",
"mchOrderNo": "lin1231241241414"
}
Request parameters
Name | Location | Type | Required | Description |
---|---|---|---|---|
X-API-KEY | header | string | Y | public key |
X-API-NONCE | header | string | Y | Request time (timestamp, accurate to milliseconds) |
X-API-SIGNATURE | header | string | Y | signature (refer to signature algorithm) |
mchNo | body | string | Y | merchant number |
payOrderId | body | string | N | Platform order number (choose one of platform order number and merchant order number) |
mchOrderNo | body | string | N | Merchant order number (choose one of platform order number and merchant order number) |
Return to example
{
"code": 0,
"data": {
"currency": "KES
"fee": "0",
"mchNo": "M1655535407",
"mchOrderNo": "",
"orderAmount": "10000",
"payAmount": "10000",
"payOrderId": "P1547429458697138178",
"state": 2
},
"msg": "SUCCESS"
}
Return results
Name | Type | Description |
---|---|---|
payOrderId | string | Payment order number |
mchNo | string | Merchant number |
mchOrderNo | string | Merchant order number |
orderAmount | string | original transaction amount of bill |
payAmount | string | Payment amount |
currency | string | three-digit currency code |
state | string | Payment status: 0-order generated, 1-payment in progress, 2-payment successful, 3-payment failed, 8-rejected |
fee | string | Merchant fee |
Transaction history
POST Get transaction history (final data-success/failure)
Body request parameters
{
"mchNo": "M1658240182",
"bizType": 1,
"startTime": 1656604800,
"endTime": 1667145600,
"pageNumber": 1,
"pageSize": 20
}
Request parameters
Name | Location | Type | Required | Description |
---|---|---|---|---|
X-API-KEY | header | string | Y | public key |
X-API-NONCE | header | string | Y | Request time (timestamp, accurate to milliseconds) |
X-API-SIGNATURE | header | string | Y | signature (refer to signature algorithm) |
mchNo | body | string | Y | merchant number |
bizType | body | number | N | Business type: 1-Collection on behalf of others 2-Payment on behalf of others 3-USDT withdrawal 4-Withdrawal |
startTime | body | number | N | Start time (server 0 time zone timestamp, accurate to seconds) |
endTime | body | number | N | End time (server 0 time zone timestamp, accurate to seconds) |
pageNumber | body | number | Y | page number |
pageSize | body | number | Y | page size (max 50) |
Return to example
{
"code": 0,
"data": {
"current": 1,
"hitCount": false,
"optimizeCountSql": true,
"orders": [],
"pages": 1,
"records": [{
"address": "",
"amount": "30880",
"bankCard": "123456789",
"bankCode": "",
"bankName": "",
"bizType": 1,
"body": "Test",
"createdAt": 1658714327,
"currency": "KES
"email": "g762646676@126.com",
"mchFeeAmount": "1120",
"mchName": "DW",
"mchNo": "M1658240182",
"mchOrderNo": "YN20220725000003",
"mobilePhone": "13116709877",
"orderAmount": "32000",
"payOrderId": "P1551386450310656001",
"payWay": "BANK",
"payerName": "DW",
"state": 2,
"subject": "buycar",
"successTime": 1658715821
}],
"searchCount": true,
"size": 20,
"total": 2
},
"msg": "SUCCESS",
"sign": "3045022100e659480ea76d87c26e0054bda5a788737d41f26d4dec365fba936028248785140220540c9bb2b9fe6fc928dc2ae4c531ee00a82615bc37b77b02ca41cffeeaddc627"
}
Return results
Name | Type | Description |
---|---|---|
amount | string | Settlement quantity (when collection is made, it is the upper-point quantity (handling fee is deducted), when payment/withdrawal is made, it is the bill quantity (handling fee is not deducted)) |
bankCard | string | Bank card number |
bankName | string | Bank name |
bizType | number | Business type: 1-Collection on behalf of others 2-Payment on behalf of others 3-USDT withdrawal 4-Withdrawal |
createdAt | number | Order creation time (0 time zone timestamp, accurate to seconds) |
currency | string | Currency |
mchFeeAmount | string | handling fee |
mchName | string | Merchant name |
mchNo | string | Merchant number |
mchOrderNo | string | Merchant order number |
mobilePhone | string | Mobile phone number |
orderAmount | string | Order amount |
payOrderId | string | Payment serial number |
payWay | string | Payment method name |
payWayType | string | Payment method |
payerName | string | User name |
state | number | Order status: 2-successful 3-failed 8-(payment) rejected 9-partial payment (payment amount is less than the order amount) |
successTime | number | is |
Merchant balance information query
POST to obtain merchant balance information
Body request parameters
{
"mchNo": "M1655535407"
}
Request parameters
Name | Location | Type | Required | Description |
---|---|---|---|---|
X-API-KEY | header | string | Y | public key |
X-API-NONCE | header | string | Y | Request time (timestamp, accurate to milliseconds) |
X-API-SIGNATURE | header | string | Y | signature (refer to signature algorithm) |
mchNo | body | string | Y | merchant number |
Return to example
{
"code": 0,
"data": {
"availableAmount": "294876",
"frozenAmount": "1986",
"mchNo": "M1658240182"
},
"msg": "SUCCESS",
"sign": "3045022100e659480ea76d87c26e0054bda5a788737d41f26d4dec365fba936028248785140220540c9bb2b9fe6fc928dc2ae4c531ee00a82615bc37b77b02 ca41cffeeaddc627"
}
Return results
Name | Type | Description |
---|---|---|
availableAmount | string | Available balance |
frozenAmount | string | frozen balance |
mchNo | string | Merchant number |
Callback notification
Submission method: POST
OK
Content-Type
Verify signature
Request parameters
Name | Type | Required | Description |
---|---|---|---|
bizType | number | Y | Business type: 1-Collection 2-Payment |
payOrderId | string | Y | payment order number |
mchNo | string | Y | merchant number |
mchOrderNo | string | Y | Merchant order number (customized by merchant, cannot be repeated) |
orderAmount | string | Y | original transaction amount of bill |
payAmount | string | Y | payment amount |
currency | string | Y | three-digit currency code |
state | number | Y | payment status: 2-payment successful, 3-payment failed, 9-partial payment (collection) |
fee | string | Y | merchant fee |
failReason | string | N | Failure reason |
Signature rules: After JSONizing the request parameters, put the obtained signature in the header, and obtain the signature directly from the response header. To verify the signature, use verifyEcdsaSignature() in the ECSDAKit tool class below.
Signature tool class
Maven dependencies
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.64</version>
<scope>compile</scope>
</dependency>
ECSDAKit
Utils
java demo
Error coding table
Error code | Error description |
---|---|
-1 | System error |
5003001 | Missing parameter |
5003002 | Merchant or APIKey does not exist |
5003003 | Merchant disabled |
5003004 | Merchant not certified |
5003005 | Merchant api key does not exist |
5003005 | Merchant or api key does not exist |
5003006 | api key expired |
5003007 | ip error |
5003008 | Signature error |
5003009 | Payment method not supported |
5003010 | Order status error |
5003011 | Merchant order number already exists |
5003012 | URL format error |
5003013 | Channel error |
5003014 | Merchant rate configuration is not initialized |
5003015 | Channel does not exist |
5003017 | Failed to create collection order |
5003018 | Failed to check collection order |
5003010 | Failed to create payment order |
5003020 | Failed to query payment |
5004006 | Insufficient merchant balance |
500321 | Amount format is incorrect |
500322 | URL not supported |
500323 | Remote client error |
500324 | Order expired |
500326 | Error in querying channel balance |
500327 | Wrong payment method |