Home>Article>Backend Development> How to implement PHP website access to Alipay
Some time ago, I developed a project to connect a PHP website to Alipay. Now I will sort out the process. Because the official website of Alipay provides many interfaces and documents, and it seems a bit cumbersome, so I will sort it out. This article mainly shares with you how to implement PHP website access to Alipay, hoping to help everyone.
1. Alipay accounts must be reviewed by the enterprise before they can make payments in a formal environment. However, you can develop it even if you are not an enterprise, because Alipay provides a sandbox testing environment for you to test and develop.
2. Alipay’s new development interface is different from the old one. In the past, as long as you had an account, you must now apply for an “application”. One account can apply for multiple applications, and one application can have multiple functions, such as “ "Computer website payment", "mobile website payment", etc.
1. Overview of the development process
1. Just read the official website documentation Ant Financial Open Platform
2. Download the PHP SDK&demo
3. Apply for an application or use sand Box environment
4. Generate application private key & application public key
5. Configure config.php
2.Specific operations
1. Enter the open platform
Baidu " Ant Financial Open Platform", now Alipay's development interfaces are all on this open platform! There are various documents here for you to search and study.
If you are using it for the first time, enter the "Document Center"-> "Development Documentation"
We choose the computer website here Payment:
As shown in the picture above, you can learn about the contents of the menu on the left one by one.
Download the sdk of php, click "SDK&Demo" on the left menu, and download the file corresponding to php. The demo after downloading cannot be used directly because the config.php file needs to be configured:
After logging in to the "Ant Financial Open Platform", click "Developer Center".
(1) Apply for an application
After logging in, click "Developer Center"->"Create Application". For specific steps, please refer to the Alipay official website documentation: Computer Website Payment Quick Access
(3) Generate key
After generation :
Configure the application public key to the application public key corresponding to the RSA2 of the sandbox application;
Configure the application private key to the "merchant private key" of config.php;
Copy the APPID of the sandbox application to config In the appid of .php;
The "Alipay public key" of the sandbox environment is configured into the "Alipay public key" of config.php;
The "Alipay gateway" of config.php needs to be changed to the "Alipay gateway" of the sandbox application. Alipay Gateway”.
2. After configuration, request Alipay1. Modify config.php, app_id, merchant_private_key, notify_url, return_url, gatewayUrl, alipay_public_key
# The payment interface must be passed through the product "sandbox wallet" provided by Alipay Scan to pay. The normal Alipay on our mobile phones cannot scan to pay, and only provides the Android version, as shown below. Then you can use the sandbox account provided by Alipay to test.
Related recommendations:
.net Detailed example of how to access Alipay’s payment interface
[PHP backend]Access Alipay
How to access Alipay function on the website
The above is the detailed content of How to implement PHP website access to Alipay. For more information, please follow other related articles on the PHP Chinese website!