Java how to integrate Alipay instant to account interface

Source: Internet
Author: User
Tags documentation java web

How Java integrates Alipay.

Need to pay treasure "partner ID and Security check code key"; If you can't make it, there's no need to keep looking down.

First we need to download the Alipay integrated instant to post interface file, as shown below.

What we're using is, of course,

Create_direct_pay_by_user-java-utf-8

Open Directory

The file inside is similar to our Java Web project. , in fact, it is a common Java project, we may want to first import it into the myeclipse.

The following figure:

There's no need to study what's in it first, we'll add it to the Tomcat container and let him run and let's see what's inside. Read the code through the page.

Open the browser, first access to the next index.jsp

Discover this is a PayPal offer for our integrated Alipay test page, so let's test it first.

configure some things first.

At this point, we need our partner ID and security key. Open the/alipay/src/com/alipay/config/alipayconfig.java class. Configure three information and how to configure it. The comment is clear enough.

After the configuration is complete, you can test it. Open the index.jsp page. The form of this page is to be submitted to alipayapi.jsp for processing. You can see from the code below the index.jsp.

<form name=alipayment action=alipayapi.jsp method=post target= "_blank" >

After we open the Index.jsp page, click OK to enter the information as required.

and start submitting.

, you can see the payment page, let's pay for it, 1 cents or some,

After payment.

, and then this is the page


, after a successful payment, a callback to the return_url.jsp,

This is the page.

Look at the code inside to

<% * * Function: Alipay page Jump Sync notification page version: 3.2 Date: 2011-03-17 Note: The following code is only for the convenience of merchant test sample code, merchants can according to their own website needs, according to technical documentation, not necessarily to use the code.

 The code is only for learning and research Alipay interface use, but provides a reference.
 Page function Description *********** This page can be in the local computer test can be placed in HTML and other landscaping page code, merchant business Logic program code trade_finished (said the transaction has been successfully concluded, and can no longer follow up the transaction);
 Trade_success (indicates that the transaction has been successfully completed, you can follow up on the transaction, such as: splitting, refund, etc.); * */%> <%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" UTF-8 "%> <%@ page import=" java.util.* "%> <%@ page import=" Java.util.Map "% > <%@ page import= "com.alipay.util.*"%> <%@ page import= "com.alipay.config.*"%>  

After reading, the inside is to accept some parameters, and then verify that the payment is successful, after success, we have to the database of their own website to operate.

This return_url.jsp is a page that synchronizes the callback.

We also saw the notify_url.jsp this page. This is an asynchronous callback. is paid after the success of Alipay to our website unsolicited request, all this can only be completed on the server-side debugging.
It has the same structure as return_url.jsp.

And then there's this alipayapi.jsp, when we index.jsp submit the request to alipayapi.jsp. Let's see what it does with those things.

<% * * * Function: Instant to account Transaction Interface Access page * Version: 3.3 * Date: 2012-08-14 * Description: * The following code is only for the convenience of merchant test sample code, merchants can according to their own website needs, according to technical documentation, not necessarily to use the code.

 * This code is only for learning and research Alipay interface use, just provide a reference. Note ***************** * If you encounter problems in the interface integration process, you can follow the following path to resolve * 1, Merchant Service Center (https://b.alipay.com/ support/helperapply.htm?action=consultationapply), submit application integration assistance, we will have professional technical engineers to contact you to help resolve * 2, merchant Help Center (http:// HELP.ALIPAY.COM/SUPPORT/232511-16307/0-16307.HTM?SH=Y&AMP;INFO_TYPE=9) * 3, Alipay forum (http://club.alipay.com/
 read-htm-tid-8681712.html) * If you do not want to use extended functionality, please assign null values to the extended function parameter. * *%> <%@ page language= "java" contenttype= "text/html;" Charset=utf-8 "pageencoding=" UTF-8 "%> <%@ page import=" com.alipay.config.* "%> <%@ page import=" com.alipay.util.* "%> <%@ page import=" java.util.HashMap "%> <%@ page import=" Java.util.Map "%> <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >  

I found out that he accepted the index.jsp data, then packaged the/alipay/src/com/alipay/config/alipayconfig.java configuration information into a map collection to create a request and returned a string. This return does not matter, the key is his request, and then we see the result, that is, to reach the payment page.

Integration is as simple as that. Of course the code does not need to use Alipay code, we can expand our thinking, put its key code, add to our business class. Make a call.

If you have any questions, you can exchange messages.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.