文件名称:ecshop 支付宝网银直连
文件大小:39KB
文件格式:ZIP
更新时间:2017-10-29 08:58:07
支付宝 ecshop 网银
'alipay_account', 'type' => 'text', 'value' => ''), array('name' => 'alipay_key', 'type' => 'text', 'value' => ''), array('name' => 'alipay_partner', 'type' => 'text', 'value' => ''), // array('name' => 'alipay_real_method', 'type' => 'select', 'value' => '0'), // array('name' => 'alipay_virtual_method', 'type' => 'select', 'value' => '0'), // array('name' => 'is_instant', 'type' => 'select', 'value' => '0') array('name' => 'alipay_pay_method', 'type' => 'select', 'value' => '') ); return; } /** * 类 */ class alipay { /** * 构造函数 * * @access public * @param * * @return void */ function alipay() { } function __construct() { $this->alipay(); } /** * 生成支付代码 * @param array $order 订单信息 * @param array $payment 支付方式信息 */ function get_code($order, $payment) { if (!defined('EC_CHARSET')) { $charset = 'utf-8'; } else { $charset = EC_CHARSET; } // if (empty($payment['is_instant'])) // { // /* 未开通即时到帐 */ // $service = 'trade_create_by_buyer'; // } // else // { // if (!empty($order['order_id'])) // { // /* 检查订单是否全部为虚拟商品 */ // $sql = "SELECT COUNT(*) FROM " .$GLOBALS['ecs']->table('order_goods'). // " WHERE is_real=1 AND order_id='$order[order_id]'"; // // if ($GLOBALS['db']->getOne($sql) > 0) // { // /* 订单中存在实体商品 */ // $service = (!empty($payment['alipay_real_method']) && $payment['alipay_real_method'] == 1) ? // 'create_direct_pay_by_user' : 'trade_create_by_buyer'; // } // else // { // /* 订单中全部为虚拟商品 */ // $service = (!empty($payment['alipay_virtual_method']) && $payment['alipay_virtual_method'] == 1) ? // 'create_direct_pay_by_user' : 'create_digital_goods_trade_p'; // } // } // else // { // /* 非订单方式,按照虚拟商品处理 */ // $service = (!empty($payment['alipay_virtual_method']) && $payment['alipay_virtual_method'] == 1) ? // 'create_direct_pay_by_user' : 'create_digital_goods_trade_p'; // } // } $real_method = $payment['alipay_pay_method']; switch ($real_method){ case '0': $service = 'trade_create_by_buyer'; break; case '1': $service = 'create_partner_trade_by_buyer'; break; case '2': $service = 'create_direct_pay_by_user'; break; } $extend_param = 'isv^sh22'; $parameter = array( 'extend_param' => $extend_param, 'service' => $service, 'partner' => $payment['alipay_partner'], //'partner' => ALIPAY_ID, '_input_charset' => $charset, 'notify_url' => return_url(basename(__FILE__, '.php')), 'return_url' => return_url(basename(__FILE__, '.php')), /* 业务参数 */ 'subject' => $order['order_sn'], 'out_trade_no' => $order['order_sn'] . $order['log_id'], 'price' => $order['order_amount'], 'quantity' => 1, 'payment_type' => 1, /* 物流参数 */ 'logistics_type' => 'EXPRESS', 'logistics_fee' => 0, 'logistics_payment' => 'BUYER_PAY_AFTER_RECEIVE', /* 买卖双方信息 */ 'seller_email' => $payment['alipay_account'] ); ksort($parameter); reset($parameter); $param = ''; $sign = ''; foreach ($parameter AS $key => $val) { $param .= "$key=" .urlencode($val). "&"; $sign .= "$key=$val&"; } $param = substr($param, 0, -1); $sign = substr($sign, 0, -1). $payment['alipay_key']; //$sign = substr($sign, 0, -1). ALIPAY_AUTH; $button = '
'; return $button; } /** * 响应操作 */ function respond() { if (!empty($_POST)) { foreach($_POST as $key => $data) { $_GET[$key] = $data; } } $payment = get_payment($_GET['code']); $seller_email = rawurldecode($_GET['seller_email']); $order_sn = str_replace($_GET['subject'], '', $_GET['out_trade_no']); $order_sn = trim($order_sn); /* 检查支付的金额是否相符 */ if (!check_money($order_sn, $_GET['total_fee'])) { return false; } /* 检查数字签名是否正确 */ ksort($_GET); reset($_GET); $sign = ''; foreach ($_GET AS $key=>$val) { if ($key != 'sign' && $key != 'sign_type' && $key != 'code') { $sign .= "$key=$val&"; } } $sign = substr($sign, 0, -1) . $payment['alipay_key']; //$sign = substr($sign, 0, -1) . ALIPAY_AUTH; if (md5($sign) != $_GET['sign']) { return false; } if ($_GET['trade_status'] == 'WAIT_SELLER_SEND_GOODS') { /* 改变订单状态 */ order_paid($order_sn, 2); return true; } elseif ($_GET['trade_status'] == 'TRADE_FINISHED') { /* 改变订单状态 */ order_paid($order_sn); return true; } elseif ($_GET['trade_status'] == 'TRADE_SUCCESS') { /* 改变订单状态 */ order_paid($order_sn, 2); return true; } else { return false; } } } ?>【文件预览】:
payment
----alipay_comm.php(5KB)
----alipay_citic.php(5KB)
----alipay_nbbank.php(5KB)
----alipay_sdb.php(5KB)
----alipay_cmb.php(6KB)
----alipay.php(8KB)
----alipay_cebbank.php(6KB)
----alipay_spabank.php(6KB)
----alipay_hzcbb2c.php(5KB)
----alipay_cib.php(5KB)
----alipay_cmbc.php(5KB)
----alipay_ccb.php(5KB)
----alipay_gdb.php(5KB)
----alipay_shbank.php(5KB)
----alipay_spdb.php(5KB)
----alipay_abc.php(5KB)
----alipay_icbcb2c.php(6KB)
----alipay_bocb2c.php(5KB)