首页
开发手册
应用中心
工具
用户中心
FoundPHP pay by AliPay
English
中文简体
English
上一篇
下一篇
#FoundPHP Alipay payment use ### PHP Alipay payment introduction Alipay payment can be applied to computer websites and mobile phones. If you need to make a computer website store, using Alipay is a good choice. #### 1.Instantiate ```php //Configuration information $config['pay']['type'] = 'alipay';//Alipay $config['pay']['charset'] = 'UTF-8';//Alipay $config['pay']['id'] = '';//Application APPID $config['pay']['key'] = '';//Merchant private key $config['pay']['log_file'] = $RAND_DIR."pay_logs/".dates(time(),"Y-m-d").".txt";//log file //Instantiated class $FoundPHP_pay = load('class/pay/pay','FoundPHP_pay',$config['pay']); ``` #### 2.Place an order and pay in the PC scenario ##### Call method alipay.trade.page.pay | parameter |types | required or not|description|example| |------|----|------|----|----| |method|String|yes| call method|alipay.trade.page.pay| |oid|String|yes| Unique order number|20200529| |body|String|yes| Order description|test order| |moneys|Int|yes| order amount, in cents|1| |notify_url|Int|no| The Alipay server proactively notifies the http/https path of the specified page in the merchant server.|http://foundphp.com/pay_callback.php | |return_url|Int|no|The address automatically returned after the payment is completed, the string starting with HTTP/HTTPS|http://foundphp.com/?m=pay_demo&t=alipay | ##### Sample code ```php //build incoming parameters $set = array( 'method' => 'alipay.trade.page.pay', 'oid' => '20200529', 'body' => 'test order', 'moneys' => '1', 'notify_url' => 'http://foundphp.com/pay_callback.php', 'return_url' => 'http://foundphp.com/?m=pay_demo&t=alipay', ); //create payment order $create_pay = $FoundPHP_pay->create_pay($set);//incoming array //Output Alipay QR code page print_r($create_pay); ``` #### output page ![](https://dev.foundphp.com/data/file/edit/20/05/29/200529_18297271.jpg) Use Alipay to scan the code and automatically redirect after payment```http://foundphp.com/?m=pay_demo&t=alipay address``` #### 3.Place an order and pay with a mobile browser ##### Call methodalipay.trade.wap.pay | parameter |style|required or not|description|example| |------|----|------|----|----| |method|String|yes| Call method|alipay.trade.wap.pay| |oid|String|yes| Unique order number|20200529| |body|String|yes| Order description|test order| |moneys|Int|yes| Order amount, in cents|1| |notify_url|Int|no| The Alipay server proactively notifies the http/https path of the specified page in the merchant server.|http://foundphp.com/pay_callback.php | |return_url|Int|no|The address automatically returned after the payment is completed, the string starting with HTTP/HTTPS|http://foundphp.com/?m=pay_demo&t=alipay | ##### Sample code ```php //build incoming parameters $set = array( 'method' => 'alipay.trade.wap.pay', 'oid' => '20200529', 'body' => 'test order', 'moneys' => '1', 'notify_url' => 'http://foundphp.com/pay_callback.php', 'return_url' => 'http://foundphp.com/?m=pay_demo&t=alipay', ); //Create payment order $create_pay = $FoundPHP_pay->create_pay($set);//incoming array //Output Alipay QR code page print_r($create_pay); ``` #### Use the browser to access the link and output the page ![](https://dev.foundphp.com/data/file/edit/20/06/16/200616_18049427.jpg) ![](https://dev.foundphp.com/data/file/edit/20/06/16/200616_18046307.jpg) #### 4.Order refund | parameter |style| required or not|description|example| |------|----|------|----|----| |oid|String|yes| Unique order number|20200529| |moneys|Int|yes| Order amount, in cents|1| #####Sample code ```php //build incoming parameters $set = array( 'oid' => '20200529', 'moneys' => '1', //refund order $refund_pay = $FoundPHP_pay->refund_pay($set);//execute refund ``` #### refund successfully