Recently, the company's project has used the function of calling Alipay interface. In the business scenario

Recently, the company's project has used the function of calling Alipay interface. In the business scenario

1 User pays money to merchant through web payment  https://doc.open.alipay.com/doc2/detail?treeId=60&articleId=103564&docType=1

2. User withdrawal function (merchant pays money to user) https://doc.open.alipay.com/doc2/detail?treeId=64&articleId=103569&docType=1


These two interfaces must be signed with Ali before they can be called. The following summarizes the problems encountered in development:


1. Web page payment interface, custom links are not allowed in the official java version demo project. Now I want to call the Alipay interface and then execute the business code in my project and jump to my own project project, check The official API can pass the business link and callback url of your own project in the product description body field, but this returns false in AlipayNotify.verify(params) of the signature return_url..jsp, because the getSignVeryfy signature verification The body field has passed special symbols such as &. After reading the code, I can only change the if (isSign && responseTxt.equals("true")) in AlipayNotify.java to if (i responseTxt.equals("true")) Then AlipayNotify.verify(params) can return true.


In return_url.jsp, after the transaction is completed, we will jump to this jsp synchronously for our own back-end business processing, so there is a problem that if the user manually closes the transaction completion interface in advance, the Alipay payment will be successful, but the background is not deducted . , The solution is to write the simulated http request for business processing on the notify_url.jsp asynchronous notification page, so that the user does not need to wait for the user to press the finish or wait for a period of time to automatically jump to return_url.jsp, but jump to notify_url immediately after entering the payment password. jsp


The following is a description of the description of the asynchronous notification page in the official Alipay documentation:


One thing to note is that the url that jumps to notify_url.jsp must be the domain name or ip accessed by public Internet users, otherwise the Alipay server cannot jump, and the third-party domain name proxy tool natapp ( https://natapp.cn/ )


2. Merchant calls the batch transfer interface when making money from users. This interface needs to install a security certificate in its own browser before calling it.



Two demos are attached below

http://download.csdn.net/detail/jishuisanqianli/9574237

http://download.csdn.net/detail/jishuisanqianli/9574243

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326219597&siteId=291194637