There is a need to make a payment module, using Alipay's SDK , the first time I use it, some things are still a bit ignorant, but fortunately I checked a lot of information, discussed with the boss, and finally have a clearer idea, here and with Let's share. Official reference documentation :
Environment :
Eclipse
Maven
The following is the understanding and experience of the official documents, please correct me if there are any deficiencies!
step one:
Create a Maven project. If anyone can't do Baidu by themselves, I won't say it anymore.
Step 2:
Add the Maven dependencies provided in the official documentation to the project's pom file.
Step 3:
To create your own page, you may refer to the official demo, or you can define it yourself. The specific parameters will be mentioned later.
Step 4: (Experience)
What I wrote here is Controller. When I referenced the SDK, I found that there is an official passage that is very interesting.
Determine the class corresponding to the
interface For example, the interface name: alipay.offline.material.image.upload
corresponds to the class in the SDK: capitalize the first letter of each word, remove the separator ("."), and add Request (or Response) at the end )
The class corresponding to the above interface name is:
AlipayOfflineMaterialImageUploadRequest (request class)
AlipayOfflineMaterialImageUploadResponse (response class)
This section is calling the core of the SDK, you must fully understand it! ! !
Let me list a common one, which most people can understand:
AlipayTradeWapPayModel ----- Mobile Website Payment Interface 2.0
AlipayTradeWapPayRequest ----- mobile website payment interface 2.0 request
AlipayTradeWapPayResponse ----- mobile website payment interface 2.0 response
Encapsulate the data passed from the foreground into the Model and create an AlipayClient client;
client.pageExecute(payRequest);
This is basically the end, you can get the information you need from the response.