UnionPay payment and payment
UnionPay payment(1) UnionPay payment Flowchart
(2) download the development kit from the UnionPay developer Platform
(3)install “uppaydemo.apk ". The running effect after installation is as follows:
(4)open Chinese UnionPay Mobile Phone Payment Control File Access android.doc ", in this document there is a test account (account: 6226090000000048, verification code: 123456), use the test account for testing, the results are as follows:
(5) The source code corresponding to “UPPayDemo.apk is also in the Development Kit. This Demo can be fully paid, indicating that the current Demo has been fully configured with the development environment of UnionPay, we only need to refer to this Demo to configure our own project.
Note: compilation in the UnionPay development environment cannot be performed in a too old environment. Otherwise, an exception will be reported if the class cannot be found.
Create an Android project on the following page:
Activity_main.xml is as follows:
MainActivity. java is as follows:
(7) configure the UnionPay development environment:
A) copy the corresponding resources to the corresponding directory according to the prompt of the running apk. B) import the UnionPay Demo and copy the permissions in the list file in the UnionPay Demo to our project. c) copy the payment-related Activity statement stated in the UnionPay Demo to our project.
(8) According to the running apk prompt, call the UPPayAssistEx. startPay () method for payment. Why are the parameters in this method used? Search for "startPay" in the UnionPay Demo to view the code. Refer to APKActivity. The Code is as follows:
(9) A tn parameter is required in the previous step. This tn parameter is the transaction serial number. For how to obtain this value, see BaseActivity in UnionPay Demo. The Code is as follows:
(10) For the verification result, refer to the BaseActivity implementation in UnionPay Demo. The Code is as follows: