App Access Alipay process

Source: Internet
Author: User
Tags documentation
Recently in a shopping mall project, the project inside the payment of this piece I choose is to call Alipay interface, because the use of more people.

Search the following online, there are many tutorials in this area, but most of the tutorial is too old, and the description is too simple. And Alipay provides the interface has been updated, may pay treasure yonder is to make the interface easier to call it, some old tutorial slightly with the current interface some can not "seat", so, I decided to write an article about the call Alipay interface articles, share with you, Let everyone know how to call the Alipay interface at the fastest speed. If the writing is not good, please give us a lot of advice oh.

Not much to say, write.

1, to Alipay website, download Alipay integrated Development Kit, understand the key code inside

Because Android devices are generally used wireless payment, all we apply for is Alipay Wireless fast payment interface. Here is the address of the application, and the following is the place to download the interface Development Kit

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

If the link fails, you can find the Express payment (wireless) service in the Merchant Service module of Alipay website.

Download the integrated development package, decompression found inside the client's demo is the document, in the client's demo to find Android_sdk, this is the payment you want to use the interface and demo.


Import the demo (Alipay_sdk_demo) and (alipay_lib) into your eclipse, then you can try to run the demo (Alipay_sdk_demo), and as soon as you understand the demo, you will call this Alipay interface. As for how it will be integrated into your project, the documentation is detailed and you can follow the documentation step-by-step. My advice is to figure out how to design your project and see what data is needed to invoke the interface, so that you can design your data first.

The following is a simple introduction to the interface demo inside the structure.

You open the project and you'll find 5 classes inside.

Among them, Base64.java, Result.java, Rsa.java these 3 classes do not need to move, need to use, then put directly into your project on the line, if you want to know about them you can also see. The focus is on the two classes of Externalpartner.java and Keys.java. Let's talk about the Keys.java class first. Open you will find this class very simple, as follows:

[Java]  View plain copy package com.alipay.android.msp.demo;     //  //  please refer to & nbsp The Android Platform Secure Payment service (MSP) application development interface (4.2 RSA algorithm signature) section and uses the OPENSSL RSA key generation tool in the compact package to generate a set of RSA public private keys.   //  When signing here, you only need to use the generated RSA private key.   // note:  For security purposes, the use of RSA private key to sign the operation process, should try to put on the merchant server side to do.    public final class keys {          // Co-Identity ID, 16-bit pure number beginning with 2088, you will see        public static final after you apply for Alipay to sign up for success  String DEFAULT_PARTNER =  "";       //here to fill in the payment Alipay account, Alipay account        public static final string default_seller after you have paid to the account  =  "";       //merchant private key, self-generated, i.e. Rsa_private_ Key.pem the first line, the last line, the space and the end of the line to spell a string, Rsa_private_key.pem this file and so you apply for Alipay after signing the successful, according to the documentation you will be generated ..... If the Android version is too high, here to use the PKCS8 format user private key, otherwise the call will not succeed, the format you will generate, the table urgent.  &nbsP     public static final String PRIVATE =  "";       //Alipay (RSA) public key   ,demo is not changed, or signed into ms.alipay.com after signing up with Alipay account, on the Key Management page, or on the document.        public static final String PUBLIC =  " MIGFMA0GCSQGSIB3: ";     }        "----..... Key.java This class, such as you apply for Alipay signing successful after the configuration, first put in this no tube, how to configure my comments inside already very clear.

Then there is the Externalpartner.java class. This class is actually very simple, you run this demo will find is a ListView loaded with a lot of product information, click on a product to call the Alipay interface (because Key.java is not configured, so you now estimate the call is not successful). We find the access to Alipay by finding the method of the Click event of the ListView, the code for this class is as follows:

[Java] view plain copy package Com.alipay.android.msp.demo;   Import java.io.IOException;      .... import com.alipay.android.app.sdk.AliPay;;;;... public class Externalpartner extends Activity implements Onitemclicklistener, Onclicklistener {public STA Tic final String TAG = "ALIPAY-SDK";

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.