Network application payment interface
Payment process description
Consumption process:
1) The user initiates payment in the App, and the App calls the SDK payment interface payFromServer
2) After the SDK confirms the payment with the Ali server, the payment page is displayed to the user
3) After the user confirms the payment, the SDK initiates and completes the payment to the Ali server
4) The Ali server feeds back the payment result to the SDK and notifies the App server
5) The App server decides whether to issue props to App users through the callback order information
Network application payment interface
Interface description:
App server Pass the payment parameters to the App, and the App calls the payment interface payFromServer to complete the paymentThe Alibaba server notifies the SDK and App server of the payment results, and the App server decides whether the props are issued
Prerequisites: None
Function prototype:
public static void payFromServer(String title, String amount, String orderId, String notifyUrl,String subjectId, IPayListener payListener)Parameter description:
title: Name of payment item, such as "gem"
amount: RMB "points" (For example, amount = 100, representing 1 yuan)
subjectId product ID (used to mark products participating in incentive activities, customized by CP) Optional
orderId: order number, CP’s service End-generated
notifyUrl: After the payment is completed, the Alibaba server calls back the callback address of the CP server
payListener: A callback function that notifies the App client of success or failure after the payment is completed.
Request example:
Stringamount = “2”; String title ="支付人民币0.02元"; finalString orderId = System.currentTimeMillis() +""; // App服务端提供回调接口,用于接收支付成功的消息 String notifyUrl ="http://xxxx.com/callback/notify"; AliTvSdk.payFromServer(title, amount,orderId, notifyUrl,subjectId, newIPayListener() { @Override publicvoidonSuccess(String title,intamount) { TestToast.show("二维码扫码支付成功"); } @Override publicvoidonError(String title,intamount, String errMsg) { TestToast.show("二维码扫码支付失败,原因:"+ errMsg); } @Override publicvoidonCancel(String title,intamount) { TestToast.show("二维码扫码支付取消"); } });
Callback notification after successful payment on the server side
Interface description:
Third-party applications need to develop an HTTP service and provide a server interface address, such as: http://third-party application server address/XXX. The digital entertainment server uses the public key (public_key) provided by the merchant to encrypt the parameters to generate an encrypted string encryptString ( Decrypt it into json format), and add the successful order information encrypted string (the format is: notify_url?data=encryptString) to the URL provided by the app request (the parameter is: notify_url). The digital entertainment server will serve the above information to the APP The client sends an http request. If the response information received is "success", the sending is successful. If the return information is other, the time interval is increased and the request is resent.
Data decrypted data structure :
Key name(key) | ##Value(value) | |||||||||||||||||||||||||||||||||||
partner_order_no | Merchant order number | |||||||||||||||||||||||||||||||||||
alipay_trade_no | Alipay transaction serial number | |||||||||||||||||||||||||||||||||||
order_status | Order Status | |||||||||||||||||||||||||||||||||||
WAIT_BUYER_PAYWaiting for buyer to pay | ||||||||||||||||||||||||||||||||||||
Payer Alipay account |
Parameter name | Parameter description | Is it required? | Details |
order_no | Merchant order number | is | Merchant’s own order number |
##Return infrastructure description:
Field | Description | |||||||||||||||||||
##success: Success | ||||||||||||||||||||
Prompt message or error message | ||||||||||||||||||||
Return business parameters (requires RSA method to use private key to decrypt, get json string and parse it into structured data parameters) |
##Key name (key) | Value (value) |
Merchant order number | |
Alipay transaction serial number | |
Order status | |
##TRADE_CLOSEDTransaction closed | |
price | |
Order price, divided into units in RMB | subject |
## Product title | subject_id |
Product id | buyer_logon_id |
Payer Alipay account |