給支付寶接口增加收貨地址等參數,跳轉到支付頁不需再次填寫地址 ...

17jiaoliu 2018-06-07 1330瀏覽
適用范圍:適用于中介擔保支付(2.7版本)

官方的支付寶接口里沒有掛地址,收貨人,郵編等參數,從而到了支付頁面還要填寫一遍地址,收貨人,比較的麻煩

增加地址,收貨人參數后就不再重復勞動了。

修改以下地方:

1.flow.php

找到

[代碼]php代碼:

$order['log_id'] = insert_pay_log($new_order_id, $order['order_amount'], PAY_ORDER);

在其后加入:

[代碼]php代碼:

$order['buyer_region'] = get_buyer_region($new_order_id);

在flow.php文件底部加入如下函數:

[代碼]php代碼:

function get_buyer_region($order_id){        $sql = "SELECt concat(IFNULL(c.region_name, ''),IFNULL(p.region_name, ''), " .                    " IFNULL(t.region_name, ''), IFNULL(d.region_name, '')) AS region " .                "FROM " . $GLOBALS['ecs']->table('order_info') . " AS o " .                    "LEFT JOIN " . $GLOBALS['ecs']->table('region') . " AS c ON o.country = c.region_id " .                    "LEFT JOIN " . $GLOBALS['ecs']->table('region') . " AS p ON o.province = p.region_id " .                    "LEFT JOIN " . $GLOBALS['ecs']->table('region') . " AS t ON o.city = t.region_id " .                    "LEFT JOIN " . $GLOBALS['ecs']->table('region') . " AS d ON o.district = d.region_id " .                "WHERe o.order_id = '$order_id'";    return $GLOBALS['db']->getOne($sql);}

2.includesmodulespaymentalipy.php

找到

[代碼]php代碼:

'seller_email'      => $payment['alipay_account'],

在其后增加如下配置:

[代碼]php代碼:

'receive_name'         => $order['consignee'],'receive_address'    => $order['buyer_region'].$order['address'],'receive_zip'    => $order['zipcode'],

ps:地址是urldecode過的

官方原版的支付寶地址如下:

https://www.alipay.com/cooperate/gateway.do?_input_charset=utf-8&agent=C4335319945672464113&logistics_fee=0&logistics_payment=BUYER_PAY&logistics_type=EXPRESS¬ify_url=http://127.0.0.1/Ecshop/respond.php?code=alipay&out_trade_no=200911105213010&partner=2088002692045431&payment_type=1&price=16.00&quantity=1&return_url=http://127.0.0.1/ecshop/[email protected]&service=trade_create_by_buyer&subject=2009111052130&sign=8894ebd13e248d043f90a6e0c41b6a68&sign_type=MD5

支付寶的地址就變成如下:

https://www.alipay.com/cooperate/gateway.do?_input_charset=utf-8&agent=C4335319945672464113&logistics_fee=0&logistics_payment=BUYER_PAY&logistics_type=EXPRESS¬ify_url=http://127.0.0.1/ecshop/respond.php?code=alipay&out_trade_no=200911105213010&partner=2088002692045431&payment_type=1&price=16.00&quantity=1&receive_address=中國廣東深圳南山區竹子林1050號&receive_name=侯琳琳&receive_zip=8126743&return_url=http://127.0.0.1/ecshop/[email protected]&service=trade_create_by_buyer&subject=2009111052130&sign=8894ebd13e248d043f90a6e0c41b6a68&sign_type=MD5




竞彩足球比分直播