Instant to account transaction interface and have a secret refund interface

Source: Internet
Author: User

1. Alipay document link, very important, combined with document operation

https://doc.open.alipay.com/docs/doc.htm?spm=a219a.7629140.0.0.cc74t4&treeid=62&articleid=103566& Doctype=1

2. Sign Up

https://b.alipay.com/order/productDetail.htm?productId=2015110218012942

3. Get PID and generate secret key

Get PID, how to upload a secret key can refer to the document

Generate secret key need to download secret key generation tool Secret_key_tools_rsa_win.zip (Windows environment)

Execute generate public key private key conversion Pcks8.bat and private key conversion pcks8.bat, get PEM file

Upload the generated public key (RSA_PUBLIC_KEY.PEM) and get the Alipay public key

Https://b.alipay.com/order/pidAndKey.htm

The converted private key (RSA_PRIVATE_KEY_PKCS8.PEM) is the merchant's private key;

Under the Secret_key_tools_rsa_win\rsa\openssl path


3. Interface needs to modify the configuration

Partner ID, Alipay public key, merchant private key, log path (optional, Alipaycore. Logresult () logging),

Sync address (after payment to jump, the address bar has parameters to jump NULL link redirect once, request or Web page can be, get request),

Asynchronous address (invalid local test, need to deploy server, external accessible, note whether the request is logged in interceptor interception, request or Web page can, post request);

The configuration classes are as follows:

/* *
* Class Name: Alipayconfig
* Function: Basic Configuration Class
* Details: Set account information and return path
* Version: 3.4
* Date Modified: 2016-03-08
Description
* The following code is only for the convenience of merchant test sample code, the merchant 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.
*/


public class Alipayconfig {

↓↓↓↓↓↓↓↓↓↓ Please configure your basic information here ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


Partner ID, signing account, with a 2088-digit string consisting of 16 digits of pure digits, view address: https://b.alipay.com/order/pidAndKey.htm
public static String partner = "";

Collection Alipay account number, starting with 2088 16-digit pure digits of the string, in general, the billing account is the signing account
public static String seller_id = partner;


Merchant's private key, need PKCS8 format, RSA public key generation: Https://doc.open.alipay.com/doc2/detail.htm?spm=a219a.7629140.0.0.nBDxfy&treeId =58&articleid=103242&doctype=1
public static String Private_key = "";

Alipay's public key, view address: https://b.alipay.com/order/pidAndKey.htm
public static String Alipay_public_key = "migfma0gcsqgsib3dqebaquaa4gnadcbiqkbgqcnxj/9qwvfgouh/ y2w89l6bkrafljhnhgpdypubv64bfqnn1pjbczkim6qrdkbolpxmkkmifynkd6raoprih3/prqeb/vsw8oom8fxn67udyuybtqa23mml9q1+ Ilizwbc2aq2ubvorfxffl75p6/b5ksing9zpgmlcuyulkxplqidaqab ";


The Server Asynchronous notification page path needs to http://the full path of the format, can not add? id=123 this kind of custom parameter, must extranet can normal access
public static String Notify_url = "http://merchant url/create_direct_pay_by_user-java-utf-8/notify_url.jsp";


Page Jump sync notification page path needs to http://the full path of the format, can not add? id=123 this kind of custom parameter, must extranet can normal access
public static String Return_url = "http://merchant url/create_direct_pay_by_user-java-utf-8/return_url.jsp";


Signature method
public static String Sign_type = "RSA";

For debugging, create a TXT log folder path, see the Logresult (String Sword) printing method in the Alipaycore.java class.
public static String Log_path = "c:\\";

The character encoding format currently supports GBK or Utf-8
public static String Input_charset = "Utf-8";

Payment type, no modification required
public static String Payment_type = "1";

The interface name of the call, without modification
public static String service = "Create_direct_pay_by_user";




↑↑↑↑↑↑↑↑↑↑ Please configure your basic information here ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

↓↓↓↓↓↓↓↓↓↓ Please configure the anti-phishing information here, if the fishing function is not opened, it can be ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

Anti-phishing timestamp to use please call the Query_timestamp function in the class file submit
public static String Anti_phishing_key = "";

The IP address of the client is not a LAN IP address, such as: 221.0.0.1
public static String exter_invoke_ip = "";

↑↑↑↑↑↑↑↑↑↑ Please configure the anti-phishing information here, if the fishing function is not opened, it can be ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

}

4.AlipayNotify Validation Modifications

Currently signed domain name and Web site does not match, the result is false, online after the need to change to &&,**** important * * *
if (issign && responsetxt.equals ("true")

5. Payment and refund configurations are the same except for synchronous, asynchronous, log-path configurations;

6. Maven used

<!--httpclent start;
<dependency>
<groupid>org.apache.httpcomponents</groupid
<artifactid>httpclient</artifactid>
<version>4.3</version>
</ Dependency>
<dependency>
<groupid>org.apache.httpcomponents</groupid>
< Artifactid>httpclient-cache</artifactid>
<version>4.3</version>
</dependency>
<dependency>
<groupid>org.apache.httpcomponents</groupid>
<artifactId> Httpmime</artifactid>
<version>4.3</version>
</dependency>
<dependency>
<groupid>commons-httpclient</groupid>
<artifactid>commons-httpclient</artifactid
<version>3.0.1</version>
</dependency>
<!--httpclent end;

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.