This article mainly introduces the PHP back-end UnionPay payment and refund example code. The editor thinks it is quite good, so I will share it with you now and give it as a reference. Let’s follow the editor to take a look.
Statement: This article is based on the latest official UnionPay SDK (2016-08-09 version 5.1.0). If the packages are different, please check whether this is the case. Version
Recently encountered UnionPay payment and related refunds (this article only takes mobile control payment as a premise). The following will write down the problems encountered during the period and the basic process. Before that, go through the official This picture shows some things we need to do for back-end personnel in a payment process
As can be seen from this picture, the back-end is responsible for 1. Platform orders Generate; 2. Push orders to the UnionPay omni-channel platform; 3. Return the tn code to the front-end for payment; 4. Process front-end notifications and asynchronous notifications from the omni-channel platform.
There are three difficulties here, order push, asynchronous notification processing, and order status query.
Download the relevant packages through the official email instructions and put them into the back-end php code. (If you download the payment control, you will probably see only the IOS and Android versions of the SDK. For the back-end , just download any one, PHP code is placed in it); then carefully read the readme.txt file in the SDK, and then follow the following steps:
1. Related parameter configuration
During the docking process, use the test environment in the assets folder of sdk Configuration file and certificate, place them in the sdk folder, and configure the /sdk/SDKconfig.php file to be read correctly Get the acp_sdk.ini configuration file.
Configure the absolute addresses of the four files acpsdk.signCert.path, acpsdk.encryptCert.path, acpsdk.rootCert.path, acpsdk.middleCert.path in the acp_sdk.ini file (just customize the file path ).
During the project development process, errors such as certificate absolute addresses may occur due to different systems or different project addresses. Especially in actual production environments, it is very easy to have different project deployment file addresses, making it impossible to After each update, the certificate address must be changed. I have modified the SDKconfig.php in the SDK to be compatible with different file addresses. Please click to expand and view
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
2. Omni-channel products Order push
Please click to view the relevant code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
Please note that the txnTime format should not be transmitted incorrectly. There should be no problems in the test environment, and the obtained tn will be returned. APP can make payment
3. Asynchronous notification processing and order transaction status query
The main function of this step is to process UnionPay transaction success information, and try to Avoid problems caused by unhandled callbacks.
Let’s talk about asynchronous notification processing first. This step is the main basis for order status modification. There are no actual difficulties, just make sure there are no problems with the relevant parameters
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
Order transaction status query
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
That's it. If there is no order for the project, the online refund will be completed.
Order refund related
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
Just perform relevant operations based on the return status value. Please implement the actual logic code yourself
Switch production environment
The project relationship is temporarily unavailable - follow-up supplement
To be continued. . . .
The above is the detailed content of PHP backend UnionPay payment and refund examples. For more information, please follow other related articles on the PHP Chinese website!