# LipaPay Transaction API
## Overview
This describes the resource that make up the LipaPay Transaction API v1.2
The API access is over HTTPS, and accessed from the `https://www.lipapay.com/api/excashier.htm`
## Interface content
### Send Message Endpoint
#### Product ENV
https://www.lipapay.com/api/excashier.htm
#### Sandbox ENV
payment transaction api url: http://sandbox.lipapay.com/api/excashier.htm
merchant url: http://sandbox.lipapay.com
merchant id: test
password:1234567890
key: Gw416RCMO8tD5MSUg5dok5uQGvR3rPpx
### Request Method
POST
### Request Parameters
| Field Name | Type | Required | Default | Description |
| --------------- | ------ | -------- | ------- | ---------------------------------------- |
| version | string | Y | 1.2 | Interface version |
| merchantId | string | Y | | It create by LipaPay,Please contact LipaPay. |
| signType | string | Y | | Sign type. (e.g. MD5) |
| sign | string | Y | | The signed content obtained by signing algorithm |
| notifyUrl | string | Y | | Merchant platform accepts LipaPay payment service notification URL |
| returnUrl | string | N | | Jump address of payment result |
| merchantOrderNo | string | N | | The merchant platform order Id,It must be unique. |
| amount | string | N | | The transcation order amount. It must is cent. e.g. the amount is 100KES,your must fill 10000. |
| sellerId | string | N | | Seller User ID |
| sellerAccount | string | N | | Seller User Name |
| buyerId | string | N | | Buyer User ID |
| buyerAccount | string | N | | Buyer User Name |
| goodsName | string | N | | goods name |
| goodsInfo | string | Y | | goods info |
| goodsType | string | N | | goods type |
| goodsUrl | string | N | | goods info url |
| customerIP | string | N | | customer ip |
| expirationTime | string | N | | Expiration Time |
| sourceType | string | N | B | Terminal source,APP:A ,Browser:B |
| countryCode | string | Y | | country code, E.g. KE |
| channels | string | N | | Reserved field |
| paymentMethod | string | N | OL | OL: online payment, OF: offline payment |
| email | string | Y | | buyer's email |
| mobile | string | Y | | buyer's mobile phone number |
## Synchro Response
If paymentMethod is 'OF', LipaPay transcation api will return the payment code related information synchronously.
### Response Data Type
application/json
### Response Parameters
| Field Name | Type | IsNull | Description |
| --------------- | ------------ | ------ | ------------------------- |
| bizContent | string | N | |
| channels | list | N | payment channels |
| orgCode | string | N | payment organization code |
| payBill | string | N | pay bill number |
| paySN | string | N | payment account number |
| errorCode | string | Y | |
| merchantId | string | Y | |
| merchantOrderNo | string | Y | |
| orderId | string | Y | LipaPay sn number |
| paymentMethod | string | Y | payment method |
| sign | string | Y | sign content |
| signType | string | Y | sign type |
| status | string | Y | |
Examples:
{
"bizContent":
{"channels":
[
{"orgCode":"MPESA","payBill":"XXX","paySN":"643BUQKK"},
{"orgCode":"MTN","payBill":"XXX","paySN":"643BUQKK"},
{"orgCode":"Airtel","payBill":"XXX","paySN":"643BUQKK"},
{"orgCode":"Diamond","payBill":"XXX","paySN":"643BUQKK"}
]
},
"errorCode":"00000",
"merchantId":"XXXXX",
"merchantOrderNo":"XXXXX",
"orderId":"XXXXX",
"paymentMethod":"OF",
"sign":"XXXXXXX",
"signType":"MD5",
"status":"SUCCESS"
}
## Page Callback Endpoint
After the user clicks the Lipapay page button, the parameters returned by the page callback address.
| Field Name | Type | IsNull | Description |
| --------------- | ------ | ------ | -------------------------------------- |
| merchantId | string | N | Merchant identity.It create by LipaPay |
| merchantOrderNo | string | N | Merchant order No. |
| orderId | string | N | LipaPay sn |
| sign | string | N | sign content |
| signType | string | N | sign type |
| status | string | N | SUCCESS,UNKNOWN |
## Service Callback Endpoint
If buyer paid successful, LipaPay service will notify the 'notifyUrl' of the payment results
The message of callback is a post response message, showing the details of the parameters:
| Field Name | Type | IsNull | Description |
| --------------- | ------ | ------ | -------------------------------------- |
| amount | string | N | order amount |
| merchantId | string | N | Merchant identity.It create by LipaPay |
| merchantOrderNo | string | N | Merchant order No. |
| orderId | string | N | LipaPay sn |
| orgTransId | string | N | bank transcation id |
| paymentChannel | string | N | payment channel info |
| paymentMethod | string | N | payment method |
| sign | string | N | sign content |
| signType | string | N | sign type |
| status | string | N | |
Examples:
```
amount=1000000&merchantId=20160511120&merchantOrderNo=PQOISCBGZBD864KO&orderId=K1705031200440789013&orgTransId=1493784054&paymentChannel=MPESA&paymentMethod=OL&sign=d8b53e07a184f3968110de63f747f48f&signType=MD5&status=SUCCESS
```
## Signature rule
1.In accordance with the ASCII sort. add the encrypted key after the sorted content.
Examples:
```
amount=100&buyerAccount=254796362662&buyerId=254796362662&countryCode=KE&customerIP=10.0.0.140&email=george.mo@killmall.com&expirationTime=1000000&goodsInfo=test&goodsName=goodsname&goodsType=1&goodsUrl=http://www.baidu.com&sellerId=254796362662&signType=MD5&sourceType=B1234567887654321
```
signed content is:
```
ec33eed433e570c11fc19e9a07c8f1eb
```
## Error code
| Code | Description |
| ----- | ----------- |
| 00000 | success |