PHP Alipay payment interface development (tutorial notes)


1. Enter the open platform of ant financial services

Select Developer Center > Web & mobile app > app list


2. Check the required function in the basic information



3. Generate RSA2 key

Enter the open platform document center, search: generate RSA


Download build tool



Open the tool and generate the key


View generated public key and private key



4. Upload app public key

View your own app



Interface signing method – set application public key


Copy in the application public key generated in the previous step



It is recommended to download and save it locally, and store it together with the generated public key and key



5. Verify the correctness of public key

Enter the management center



View app public key


Click to verify the correctness of the public key



Download signature tool



Run the tool, fill in the application private key on the left, and click generate signature



Copy the result, paste it into the debugging tool, and verify it


6. How to use tools to generate signatures

Download tools



Take computer website payment as an example, open the development document



Enter API list



You can view the request parameters. If they are required, fill in them; If it is not required, it will not be filled in;

Copy request parameters




Use the URL encoding and decoding tool of webmaster tool to encode the generated signature





Copy the generated signature and add: & sign = URL encoded value after the content



Gateway splicing (sandbox environment gateway, please remove the dev after alipaydev for formal environment)

The splicing values are as follows


Use the splice value to access directly in the browser, if it appears code:10000 It indicates that the request is successful and QR is generated_ Value of code

Enter the management center, select the sandbox account, and use the buyer’s account to pay





7. Using the method of SDK signature






8. Sandbox instructions

Select Developer Center R & D service sandbox



8. Use tools to check and sign

Download the signature verification tool



Format the parameters



View Alipay public key



Click Start signature verification



9. Computer website test — PHP version




Put the downloaded directory into the PHP environment and open config. PHP


Asynchronous notification address_ url.php


Open the project and access it directly



Select payment test




The above is the result of synchronous signature verification. In return_ URL. PHP

If you want to view the asynchronous signature verification results, open log.txt



According to the result returned by the signature verification, the logical processing is performed in the asynchronous file (do not process in the synchronous file, because if the synchronous file is closed in the jump, the program cannot continue to execute, so the payment result is subject to the asynchronous notification)

Please refer to the official documents for details




What to do if the verification fails: use cloud to check


(external order number can be found in log.txt)

View request result

Recommended Today

Implementation example of go operation etcd

etcdIt is an open-source, distributed key value pair data storage system, which provides shared configuration, service registration and discovery. This paper mainly introduces the installation and use of etcd. Etcdetcd introduction etcdIt is an open source and highly available distributed key value storage system developed with go language, which can be used to configure sharing […]