Development example of PHP UnionPay online payment interface
小云云
Release: 2023-03-20 15:44:01
Original
12164 people have browsed it
This article mainly shares with you the development examples of PHP UnionPay online payment interface, hoping to help everyone.
1. Log in to the UnionPay self-service test platform (login address: open.unionpay.com). After logging in, click on My Products, as follows: Click on the interface to be tested on the right. In this example, mobile web payment is used ( WAP payment) as an example.
2. Click on the test parameters on the left menu to see the parameters required for the test process, as shown below: Click on the test certificate to download two certificates. One is a private key certificate with the suffix .pfx, and the other is a public key certificate with the suffix .cer. After downloading them, the name of the private key certificate file is changed to acp_test_sign.pfx. Or if you don’t download it, you can just use this example directly. In the TP3.2 example, Public/cer already contains all certificate files.
3. There is relevant code in the TP3.2 example that can be used for testing. Please use the parameters of the test environment when testing. There are comments in the code. Before you start, make sure that your environment's PHP version is based on 5.3. You need to enable the curl and openssl functions, and the test must be done online. Local virtual domain names will not work. If you encounter any problems, you can refer to the official instructions. There is a PHP Version SDK in this folder, which is an official document. Just refer to the instructions inside. Their example couldn't run when I tested it. I don't know what happened. reason. 4. Switch to the production environment and pay attention to the following issues: 4.1 First, according to the instructions in the merchant activation email you received, visit the website http://cs.cfca.com.cn/ Download the production Certificate file:
After clicking download, after the download operation is completed, a successful download prompt will appear on the page. The downloaded certificate is automatically stored in IE. The next step is to export the certificate.
4.2 Export the certificate file: Open the IE browser, click the gear in the upper right corner, open Tools=》Internet Options=》Content=》Certificate, as shown in the picture:
After clicking on the certificate, find the certificate you just downloaded. You can identify it by its name. It is marked in the merchant’s email:
The name marked in red in the picture above should be the same as the name you downloaded. Same.
Find it and click Export: The next step along the way, you need to pay attention to the following steps
##The above password is the password to be set in the production environment in config.php. Please set it to six digits (numbers only, please do not set letters and symbols)Specify Set the file name of the exported certificate to: acp_prod_sign, and select a directory to store the certificate. Click Next to export to the desktop. After completion, you will see a file acp_prod_sign.pfx on the desktop. This is the private key file to be used in the production environment. Copy it to the certificate directory /Public/cer. The next step is to upload this certificate to the merchant service website. 4.2 Upload the certificate to the merchant service website. Log in https://merchant.unionpay.com/portal/login.jsp
Upload the acp_prod_sign.pfx file you just exported and click Upload.
Next step, enable the certificate, click Security Certificate Management, and enable it.
Next step, download the UnionPay public key
Unzip the file and put the two certificates inside also into /Public/cer. Then go to config.php and switch to the production environment according to the file comments.
The following is the code information of TP3.2: /App/Home/Conf/config.php
The above is the detailed content of Development example of PHP UnionPay online payment interface. For more information, please follow other related articles on the PHP Chinese website!
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn