时间:2021-07-01 10:21:17 帮助过:10人阅读
function get_code($order, $payment)
{
if (!defined('EC_CHARSET'))
{
$charset = 'utf-8';
}
else
{
$charset = EC_CHARSET;
}
$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;
}
$parameter = array(
'agent' => $payment['alipay_agent'],
'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'],
'extra_common_param'=> !empty($order['all_pay'])?$order['all_pay']:0, //判断是不是合并付款 add by ouzhiming
'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;
}
用的是ECSHOP商城框架,在本地测试(windows系统)的时候,正常交易。但到了生产环境(Centos系统)后,支付宝就会报ILLEGAL_SIGN(签名验证错误)错误。网上看过一些解决方法,但都没作用。下面是生成支付宝支付代码的代码:
function get_code($order, $payment)
{
if (!defined('EC_CHARSET'))
{
$charset = 'utf-8';
}
else
{
$charset = EC_CHARSET;
}
$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;
}
$parameter = array(
'agent' => $payment['alipay_agent'],
'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'],
'extra_common_param'=> !empty($order['all_pay'])?$order['all_pay']:0, //判断是不是合并付款 add by ouzhiming
'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;
}
建议你看看是不是大小写的问题。方法的大小写。类的大小写。参数的大小写。