(1) Offline Payment
Offline Payment is a group of payment solutions that Alipay designed for payment scenarios for the offline merchants, which include Barcode Payment, QR Code Payment, and Sound Wave Payment.
(2) Barcode Payment
The merchant scans the bar code / QR code generated in Alipay Wallet, to charge the buyer and complete the payment.
(3) QR Code Payment
The merchant generates the QR code according to the checkout process. The buyer will scan the QR code with Alipay Wallet and complete the payment process.
(4) Sound Wave Payment
The merchant processes the sound wave generated by Alipay Wallet, which identifies the buyer’s Alipay account, then charges the buyer and complete the payment.
(5) Digital Signature
It refers to the digital signatures generated in the communication between the merchant servers and the Alipay servers. The signatures are of the same algorithm and could be verified by both parties, which are used to confirm the no content has been changed in the information exchange.
(6) App ID
Application ID number issued by Alipay. It is a 16-bit digital number to the developer to uniquely identify one application.
Items | Requirements |
---|---|
Alipay Gateway | All API calls will need to visit Alipay Gateway https://openapi.alipay.com/gateway.do before being directed to the corresponding service. |
HTTP protocol | HTTPS must be used for the security of the information exchange. |
HTTP method | We must use POST to submit. |
Data Format | The return parameters will be in JSON or XML format. |
Encoding | GBK, GB2312 and UTF-8 are supported. |
Digital Signature | The data in the communication must be digital-signed. We support RSA and RSA2. |
Requirements for Digital Signature | All the requests and responses must be signed and the signature should be verified on the receiving side. |
The common parameters are those parameters shared by all API calls and processed by Alipay Gateway, in the POST payload. The following example is the payload of the post with the query API:
REQUEST URL: https://openapi.alipay.com/gateway.do REQUEST METHOD: POST CONTENT: app_id=2014072300007148 method=alipay.trade.query charset=utf-8 sign_type=RSA2 timestamp=2014-07-24 03:07:50 biz_content={"out_trade_no": "201503022001"} sign=e9zEAe4TTQ4LPLQvETPoLGXTiURcxiAKfMVQ6Hrrsx2hmyIEGvSfAQzbLxHrhyZ48wOJXTsD4FPnt+YGdK57+fP1BCbf9rIVycfjhYCqlFhbTu9pFnZgT55W+xbAFb9y7vL0MyAxwXUXvZtQVqEwW7pURtKilbcBTEW7TAxzgro= version=1.0
Notes:
All the paramters must be url encoded. The above example is not url encoded for readability.
Parameter | Type | Mandatory | Description | Sample |
---|---|---|---|---|
app_id | String(32) | Y | The unique APP id that Alipay assigned to each application | 2014072300007148 |
method | String(128) | Y | The name of the API service | alipay.trade.pay |
charset | String(10) | Y | The coding used in the request,such as utf-8, gbk, gb2312. | utf-8 |
sign_type | String(10) | Y | The algorithm used for digital signature. Currently RSA and RSA2 are supported. | RSA2 |
Sign | String(256) | Y | The signature generated for the data,please refer to “1.3.1 Digital Signature” | |
timestamp | String | Y | The time when the data is generated,in “yyyy-MM-dd HH:mm:ss” format. | 2014-07-24 03:07:50 |
version | String | Y | The version of API | 1.0 |
notify_url | String(190) | N | The specified url provided by the merchant for Alipay to send the notifications to. | http://api.test.alipay.net/atinterface/receive_notify.htm |
biz_content | String | Y | JSON format. For more details, please refer to the document of the individual API. |
The above common parameters are fixed and commonly shared by all the API calls. For individual API document, we will discuss only the “method” and “biz_context” parameters, and skip those listed under common parameters.
After processing the merchant’s request, Alipay will return the response of either success or failure.
{ "alipay_trade_query_response": { "code": "10000", "msg": "处理成功", "trade_no": "2013112011001004330000121536", "out_trade_no": "6823789339978248", "trade_status": "TRADE_SUCCESS", "buyer_user_id": "2088102122524333", "buyer_logon_id": "159****5620", "total_fee": "88.88", "receipt_amount": "8.88", "send_pay_date": "2014-11-27 15:45:57", "store_id":"NJ_S_001", "store_name":"证大五道口店", "terminal_id":"NJ_T_001", "fund_bill_list": [ { "fund_channel": "ALIPAYACCOUNT", "amount": "80.00" }, { "fund_channel": "DISCOUNT", "amount": "8.88" } ] }, "sign": "jfAz0Yi0OUvAPqYTzA0DLysx0ri++yf7o/lkHOHaG1Zy2fHBf3j4WM+sJWHZUuyInt6V+wn+6IP9AmwRTKi+GGdWjPrsfBjXqR7H5aBnLhMsAltV7v4cYjhuguAqh4WkaJO6v6CfdybDpzHlxE6Thoucnad+OsjdCXkNd1g3UuU=" }
{ "alipay_trade_query_response": { "code": "40004", "msg": "处理失败", "sub_code": "ACQ.TRADE_NOT_EXIST", "sub_desc": "交易不存在" }, "sign": "jfAz0Yi0OUvAPqYTzA0DLysx0ri++yf7o/lkHOHaG1Zy2fHBf3j4WM+sJWHZUuyInt6V+wn+6IP9AmwRTKi+GGdWjPrsfBjXqR7H5aBnLhMsAltV7v4cYjhuguAqh4WkaJO6v6CfdybDpzHlxE6Thoucnad+OsjdCXkNd1g3UuU=" }
Parameter | Type | Mandatory | Description | Samples |
---|---|---|---|---|
code | Number(8) | Y | Return code of the operation to indicate success or failure | 10000 |
msg | String(128) | Y | Detail message about the result | 处理成功 |
sub_code | String(64) | Y | The sub-code for error case, it appears only when it has a confirmed failure. | ACQ.TRADE_NOT_EXIST |
sub_msg | String(256) | Y | Detailed error message | 交易不存在 |
sign | String(256) | Y | The signature generated for the data,please refer to “1.3.2 Digital Signature verification” |