Network application payment interface


Payment process description

1434706053921_a87ff679a2f3e71d9181a67b7542122c.jpg

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 payment
The 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 :

##TRADE_SUCCESS Payment successfulTRADE_CLOSED Transaction closed##buyer_logon_id

The server actively queries the order payment status

Interface description:

Merchant can use this The interface actively queries the order payment status. It is mainly used for the merchant to actively query once after the client has successfully paid the payment to verify whether the order has been paid successfully.

Access method: TOP

For the TOP access guide, see ://open.taobao.com/doc2/detail.htm?spm=a219a.7629140.0.0 .jlQptD&treeId=49&articleId=101617&docType=1

APItaobao.tvpay.partner.order.query

Request parameter 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:

##codemessagedata.data

##Return infrastructure sample:

{
   "tvpay_partner_order_query_response": {
       "result": {
           "code": "success",
           "data": {
               "data": "PG5Qgxp5C+Muqohd7s01IE9SK/VnYVSxsY7nPqHFR8d+tjx3qLBeTu8llVi0+yaQHdMl/ZMTXxhchl9FiruOkX+GL5aN4S+/C68Tq5Os5dT4iilwNaDT6gw2pBtMUR9maVfXukcvFMLSx7d9XsjebWpapqTMgjOkMQjOHUA0GtcdgfFPE4sFxwB0+8SdbOYF1qoEkBoU8o0brd6/tFTJkqn/uJUbHOoqqLXCB3LmxShRa4m8KRsVPfSavOEjcSO7yfNTu7cLhGoOCRL5ffwLWVxyPRpaLfm0O8CJi9Cllb5nndWzh1zoXUtyBdfw9iHzbE0C7WArO5+YLKVCzA5c4A=="
           },
           "message": "success",
           "success": true
       },
       "request_id": "118g71ywn59zf"
   }
}

data Decrypted data structure:

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)

##partner_order_noalipay_trade_noorder_statusWAIT_BUYER_PAYWaiting to buy Home paymentTRADE_SUCCESS Payment successful##TRADE_CLOSEDTransaction closedpricesubject
##Key name

(key)

Value

(value)

Merchant order number

Alipay transaction serial number

Order status

Order price, divided into units in RMB

## Product title

subject_id
Product id

buyer_logon_id
Payer Alipay account