Alipay instant account interface development-DEMO explanation and source code sharing

Environmental requirements

PHP5.0 or above, and curl and openssl need to be turned on. 
Document address: 
https://doc.open.alipay.com/doc2/detail?treeId=62&articleId=103566&docType=1

E-commerce website payment flow chart

image

Select demo

即时到账交易接口(create_direct_pay_by_user) After the demo is downloaded and decompressed, the directory is as follows: 
image

select:MD5签名版本/create_direct_pay_by_user-PHP-UTF-8 
image

We put these files in the web directory pay, and then visit: http://localhost/pay/ and 
image
click "Confirm Payment", ^_^ 
image

1. Edit alipay.config.php

image

image

In the above configuration, we would just fill $alipay_config['partner'] and $alipay_config['key']after this two (note must be signed merchant configuration information) 
so that we "confirm payment" will jump to http://www.mydev.com/alipayapi.php, and then jump to Alipay's payment page.

When your payment is completed, a sync notification will be sent, skip back to

image

Unscheduled asynchronous notification (if the synchronous notification is successful, the asynchronous notification will not be sent)

image


2. Demo process summary 
Step 1: In index.php, build an order information form with the following fields

image


Step 2: Submit the form to alipayapi.php, and receive parameters in alipayapi.php

image


Then construct the parameters for requesting Alipay:

image


Then send a request (to Alipay), and you will be redirected to Alipay’s payment page

image


Step 3: Send a synchronous notification of payment completion (return_url.php) to the website, and send an asynchronous notification (notify_url.php) to the website from time to time.

return_url.php or notify_url.php, both of which process the verification result

image

image


Notify the customer that your order payment is successful/failed. End the entire payment process.


Guess you like

Origin blog.51cto.com/15127568/2667263