This time, the order function is to be implemented in the project, so online payment must be completed. Online payment generally has two methods: online banking payment and third-party payment (Alipay, paypal, etc.). For the sake of simplicity, first To complete the Alipay online payment function, since the project is based on the Yii framework and uses UTF-8 encoding, it is obviously necessary to use the PHPUTF-8 related API in the Alipay interface to implement it.
This time, the order function is to be implemented in the project, so online payment must be completed. Online payment generally has two methods: online banking payment and third-party payment (Alipay, Paypal, etc.). For the sake of simplicity, the Alipay online payment function is completed first. , since the project is based on the Yii framework and uses UTF-8 encoding, it obviously needs to be implemented using the PHP UTF-8 related API in the Alipay interface.
Before the formal test, prepare several fields: Alipay account number, partner ID bound to the Alipay account and security verification code key.
Before testing, you must first go to http://club.alipay.com/read.php?tid=9976972 to download the latest relevant interface. Because I use the instant payment function, I download the instant payment interface.
After downloading, unzip the document to the specified folder and enter the required interface directory create_direct_pay_by_user-PHP-UTF-8:
The directory structure under the create_direct_pay_by_user-PHP-UTF-8 folder is as follows:
There are two files that need to be modified here: alipay.config.php and alipayapi.php.
The main modifications in alipay.config.php are the partner ID and security verification code key:
The main modification in alipayapi.php is the path to the return URL and notification URL after successful payment:
Then we can enter the instant payment entrance page through index.php in the browser:
Fill in the relevant information (as a test, the general payment amount is set to 0.01), click Confirm to jump to the Alipay payment page. If an error is reported, check the three fields of Alipay account, partner ID and security verification code key Is the input correct (if an error is reported saying that the payment has expired, it may be because the order ID has already been paid, just change the order ID):
Enter your Alipay account and password and click Next to enter the payment interface. After entering the relevant information, click Confirm Payment. If the payment is completed, it will jump to the return_url defined in alipayapi.php above. If the payment is successful, it will be output
Verification successful
At this point, testing the Alipay instant payment function is completed.
In order to achieve seamless connection with our own website, we often create the submission form in index.php ourselves to unify it with our web application.