Mobile App integrates UnionPay payment control

Source: Internet
Author: User

To make a long story short, this article is based on the official documents of UnionPay, briefly summarizing and explaining how to solve the problem in the middle.

I. Pre-development preparatory work
1. Open https://open.unionpay.com/, follow up the document download, FAQ query and so on this platform operation.
2. Download the specification and development package. Help Center-Download-product Interface Specification-Mobile control Payment Product Interface Specification, help Center-download-product Interface Specification-Mobile phone control payment product technology Development kit.
3. Developers should first look at 6.2 of the consumption of the trading process.

Flowchart Description:
(1) The user clicks on the purchase item in the client, the client initiates the order generation request to the merchant backstage;
(2) After receiving the order generation request from the merchant backstage, organize and push the order information to UnionPay backstage according to the mobile Control Payment product Interface specification.
(3) After receiving the order information and checking the pass, the UnionPay will generate the corresponding transaction serial number (TN), and reply the transaction serial number to the merchant backstage (reply element: Transaction serial number, etc.);
(4) The merchant backstage receives the transaction serial number, returns the transaction serial number to the client;
(5) The client invokes the payment control via the transaction serial number (TN);
(6) After the user enters the relevant payment information in the payment control, the payment control initiates the payment request to the UnionPay background;
(7) After successful payment, UnionPay backstage will pay the result notice to the merchant backstage;
(8) UnionPay will inform the payment control of the payment result;
(9) The payment control displays the payment result and returns the payment result to the client;
Note: This document focuses on the implementation of part (5) and (9) of the above process
The current supported devices for each platform are as follows:
Android Platform SDK is mainly used for Android version 2.1 and above terminal equipment;
iOS version payment controls are available for iOS 6.0 and later end devices.


4. Relevant test parameters:
If you have signed up and have your own test merchant, you can test it directly with your merchant number, which is in the test certificate development package. * Try to use the real merchant number test, to prevent sometimes the parameter mismatch can be found early.
If you do not have a contract, or the merchant number has not been assigned, please obtain the merchant in the platform and open the transaction permission by:
A) registration in the upper left corner;
b) in the upper right corner after landing my test-test parameters
c) My test-product-Choose your own integrated.

Test Card number information: (This information is for testing only, no formal transaction occurs)
Debit card: 6226090000000048
Phone Number: 18100000000
Password: 111101
SMS Verification Code: 123456
(SMS Verification code remember to get the verification code and then input)--If prompted SMS code error [8100201], to see whether the test environment or production environment, and the control version is the latest

Debit card: 6226388000000095;
Phone number: 18100000000;
cvn2:248;
Validity: 1219;
SMS Verification Code: 123456
(SMS Verification code Remember to click to get the verification code and then input)


II. Client Development Steps
1. Reference document "China Silver Joint Machine Payment Control User Guide" (this document is located in the doc directory of the foreground development package), set up the project.
2. Before the development of the consumer (get TN) request in the background, app development can see how the demo code controls the control, the demo will be the default by one of UnionPay's merchant simulation to obtain TN (HTTP://202.101.25.178:8080/SIM/GETTN or http:// 101.231.204.84:8091/SIM/GETACPTN), then need to change from the merchant's own backstage to get TN.
3. Background development to complete the consumption request, and background development to discuss the background and the way to transfer tn between apps.
4. Instead, do a test from your own background tn.
5. Add additional business logic on your own.

Here is a description of how the client consolidates the jar package, such as, at a glance

Control's invocation (Bybrid plug-in mode):

 Public classPaypluginextendsCordovaplugin {@Override Public BooleanExecute (String action, Jsonarray args, Callbackcontext callbackcontext)throwsjsonexception {String tn= args.getstring (0); if(Action.equals ("UnionPay") {Uppayassistex.startpaybyjar (cordova.getactivity (), payactivity.class,NULL,NULL, TN, "00"); }                return Super. Execute (Action, args, Callbackcontext); }}
View Code

return result processing (processed in mainactivity):

@Override Public voidOnactivityresult (intRequestcode,intResultCode, Intent data) {         /************************************************* * Step 3: Handle the payment results returned by the Silver Teaming machine payment control ****************************** ******************/        if(Data = =NULL) {            return; } String msg= ""; /** Payment Control return String: Success, fail, cancel respectively on behalf of payment success, payment failure, payment cancellation*/String str= Data.getextras (). getString ("Pay_result"); if(Str.equalsignorecase ("Success") ) {msg= "Payment succeeded!" "; } Else if(Str.equalsignorecase ("fail") ) {msg= "Payment failed!" "; } Else if(Str.equalsignorecase ("Cancel") ) {msg= "User Canceled payment";    } toast.maketext (Getapplicationcontext (), MSG, Toast.length_long). Show (); }
View Code

Integration Method Description:

Android is divided into static library integration and APK access two ways: apk access mode, static library integration.
APK access mode: Call the Startpay method to set up a separate control on the phone.
Static Library Integration: Call the Startpaybyjar method and adjust the controls built into the merchant app.

2 different ways to compare:

APK access mode: The control is a standalone installation. Modify the code in the demo code when the control is not installed to download the control apk from UnionPay official website, the merchant can not care about the version of the control. Control Apk:http://mobile.unionpay.com/getclient?platform=android&type=securepayplugin.

Static Library Integration: You do not need to install the control once you have finished installing the Merchant app, but the merchant is concerned about whether the control version is upgraded. In addition iOS is also a static library integration, and it is recommended to integrate iOS with this method, with 2 sides consistent.

* If you have a problem, you can go to https://open.unionpay.com/to see if you can solve it: 1) If it is a code exception: Help Center-faq copy a small search in the exception, or you can search for "Android" or "IOS" under the FAQ's Development question category can search for the corresponding full-scale development problem. 2) If there is a control error, the error message has 7 digits: Technical Integration-answer code, enter a 7-digit search. 3) If the control is wrong, there is no error message or No 7 digits: Help Center-faq-test the problem, search "app" can search the control of the full amount of testing problems. * For pro and non-pro development packages, use a development kit without pro, and the Pro Development package contains special features that are not used by the general provider, and some code needs special handling. * For Android use Startpay or Startpaybyjar questions refer to the FAQ "apk mode and Jar method is different".

Third, the background development steps
1. Open the background development package, find the corresponding language \ Sample code folder, see Readme.txt, follow the steps to deploy, modify the configuration file, etc.
2. Where the Form_6_2_appconsume interface can obtain TN, please follow the client development to determine the way to pass TN between the backstage and the app, the simplest way is to print TN directly on the page, but some languages directly print TN only when the line breaks. Mobile phone development is recommended to trim when TN is received.
3. Follow-up reference readme completed.

A brief introduction to the method of obtaining TN in the background:

/*** Assembly Request message*/Map<string, string> data =NewHashmap<string, string>(); //Version numberData.put ("Version", "5.0.0"); //Character Set encoding default "UTF-8"Data.put ("Encoding", "UTF-8"); //Signature method for RSAData.put ("Signmethod", "01"); //transaction Type 01-consumptionData.put ("Txntype", "01"); //Trade Subtype 01: Self-Service consumption 02: Order 03: InstallmentData.put ("Txnsubtype", "01"); //type of BusinessData.put ("BizType", "000201"); //channel type, 07-pc,08-phoneData.put ("Channeltype", "08"); //foreground notification address, control access mode no effectData.put ("Fronturl", "http://localhost:8080/ACPTest/acp_front_url.do"); //Background Notification AddressData.put ("Backurl", "http://222.222.222.222:8080/ACPTest/acp_back_url.do"); //access type, merchant Access 0 0-merchant, 1: Receipt, 2: Platform merchantData.put ("AccessType", "0"); //Merchant number, please change to your merchant numberData.put ("Merid", "888888888888888"); //Merchant Order number, 8-40-digit letterData.put ("OrderId",NewSimpleDateFormat ("Yyyymmddhhmmss"). Format (NewDate ())); //order delivery time, system time takenData.put ("Txntime",NewSimpleDateFormat ("Yyyymmddhhmmss"). Format (NewDate ())); //Transaction Amount, Unit DivisionData.put ("Txnamt", "1"); //Currency of transactionData.put ("CurrencyCode", "156"); //requester reserved domain, pass through field, query, notification, reconciliation file will appear as is//data.put ("reqreserved", "transmitting information"); //The order description can not be sent on, and the message will be displayed in the control when it is sent.//data.put ("Orderdesc", "Order description");Data=signdata (data); //Transaction Request URL read from configuration fileString Requestappurl =sdkconfig.getconfig (). Getapprequesturl (); Map<string, string> resmap =submiturl (data, requestappurl); System.out.println ("Request Message =[" +data.tostring () + "]"); System.out.println ("Response message =[" +resmap.tostring () + "]");

As in resmap.get ("tn"), is the trade number we need.

* If you have a problem, you can go to https://open.unionpay.com/to see if you can solve it: 1) If it is a code exception: Help Center-faq to copy the exception of a small search, or you can go to the FAQ's development problem category, search "Java", "C #", "PHP" can search for the corresponding full-scale development problem. 2) If it is normal to receive the answer Respcode non 00, you can look at respmsg, inside the 7-digit number on the platform technology integration-answer code search. 3) If there are other errors, see if you have any problems with the FAQ's test question category.

The most important point:

In the development process inevitably encountered some difficulties can not be resolved independently, then contact UnionPay customer Service:

https://open.unionpay.com/ajweb/help?id=291

Problems with the network process

Business application and consultation, can send mail to [email protected] or phone 021-50362428, UnionPay has special personnel to handle. Other special services: Please see the Business Operation Service Guide (merchant) daily business Operation service.

Network test problem
You can send mail to [email protected] mailbox, (mail title: Merchant number + merchant name + Contact QQ), provide merchant number and contact QQ, The UnionPay Test Service specialist will add the contact QQ of the Merchant interface to the UnionPay Unified Service QQ to provide support services (merchants can also provide their own merchant number and contact QQ via the service phone 021-38929999-2049)

Collect, order, no jump payment products do not support self-test, please forgive me.

Labor Service Hours: Weekdays 9:00-11:30,13:00-17:00

Mobile App integrates UnionPay payment control

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.