Integration of projects with Alipay and access to public and private keys

Source: Internet
Author: User
Tags openssl

The project needs to integrate the Alipay interface on the client. The study: Because the use of Alipay interface, you need to pay Bao official website: registered account, and apply. The following is the operation after the application is good. After the login is successful, store my merchant service-found below the page--Sign up management, find mobile payment-–> Click Download Integration Document, skip to the new page, find the download development package below the page, download the mobile payment. After extracting it, you typically get three of folders.

This time to open the file named: Alipay Wallet Payment Interface Development Kit 2.0 Standard version of the file. After opening, there is a demo file. Open the demo file. There will be three folders: the first OpenSSL; The second service-side demo, the third client demo. This time, we need to be concerned about the OpenSSL file with the client demo file.

In the third demo file, there is a demo version of iOS and Android. But when you deploy the runtime, you will find that you cannot run successfully. In the project master file, such a piece of code:
Merchant PID

public static final String PARTNER = "";

Merchant Beneficiary Account

public static final String SELLER = "";

Merchant private key, PKCS8 format

public static final String rsa_private = "";

Alipay Public Key

public static final String rsa_public = "";

Merchant PID

public static final String PARTNER = "";

Merchant Beneficiary Account

public static final String SELLER = "";

Merchant private key, PKCS8 format

public static final String rsa_private = "";

Alipay Public Key

public static final String rsa_public = "";

Because of this, it is necessary to fill in according to the merchant registration information. So even if the download of the demo, it is no use. The following is how to get the private key and Alipay public key.

Remember the OpenSSL file just after we pressurized it. The method to get the private key and the public key is inside:

Open the OpenSSL file first: The following is the file open order: openssl–>bin–> Double-click the Openssl.exe file. A command box will appear at this time: (the first thing to say is that this file is open under Windows System) if the Apple system doesn't seem to work. Then continue to say:

After opening the Command box: Enter the first line command, generate the private key, as follows:

  Genrsa-out RSA_PRIVATE_KEY.PEM 1024

Press ENTER, then enter the second line of command to generate the public key:

Rsa-in Rsa_private_key.pem-pubout-out Rsa_public_key.pem

Press Enter and enter the third line to convert the RSA private key to PKCS8 format

Pkcs8-topk8-inform pem-in Rsa_private_key.pem-outform Pem-nocrypt

After executing these three lines, two files are generated that end with:. Pem. This is the public and private key that we generate. The file location is in the bin directory. Of course we can't open these two files. But we can make a copy to the desktop and change it to a TXT file to open it. Because all we need is the string inside, remember that when we refer to these two long strings, we need to be aware of the following: strings, cannot include, line breaks, spaces, and other mistakenly added characters. So be sure to be careful when copying.

Of course, the private key is the private key we need, how to get Alipay public key: Back to Alipay first, first login,

One: click "View pid| KEY ", in the newly opened page (https://b.alipay.com/order/pidAndKey.htm), you can see the signing Alipay account, the partner ID (PID).

Two: Enter the payment password, query key, Alipay public key.

Three: Upload the RSA public key, under "partner Key Management", click "RSA Encryption" after "Add encryption Key", the public key to copy into. Note that you cannot have spaces, line breaks, and so on.
Http://blog.it985.com/wp-content/uploads/2015/06/zhifub.png

Four: Click Confirm Upload, if prompted to upload successfully. is success.

This is the time to check the Alipay public key. As shown in figure:
Http://blog.it985.com/wp-content/uploads/2015/06/zhifua.png
At this point, the corresponding private key and public key are filled in the corresponding location our demo can be run. Then integrate into the project. You need to do it yourself. Encounter problems, Baidu a bit. Hope to bring you useful.

Reference URL: http://blog.it985.com/12276.html

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.