|
|
来了。
把alipay_callback.php最后的改为这个就可以了。
- $gatewaymodule = "alipay"; # Enter your gateway module name here replacing template
- $GATEWAY = getGatewayVariables($gatewaymodule);
- if (!$GATEWAY["type"]) die("Module Not Activated"); # Checks gateway module is active before accepting callback
- $_input_charset = "utf-8"; //字符编码格式 目前支持 GBK 或 utf-8
- $sign_type = "MD5"; //加密方式 系统默认(不要修改)
- $transport = "https"; //访问模式,你可以根据自己的服务器是否支持ssl访问而选择http以及https访问模式(系统默认,不要修改)
- $gatewayPID = $GATEWAY['partnerID'];
- $gatewaySELLER_EMAIL = $GATEWAY['seller_email'];
- $gatewaySECURITY_CODE = $GATEWAY['security_code'];
- $alipay = new alipay_notify($gatewayPID,$gatewaySECURITY_CODE,$sign_type,$_input_charset,$transport);
- $verify_result = $alipay->notify_verify();
- if(!$verify_result) {
- logTransaction($GATEWAY["name"],$_POST,"Unsuccessful");
- exit;
- }
- # Get Returned Variables
- $status = $_POST['trade_status']; //获取支付宝传递过来的交易状态
- $invoiceid = $_POST['out_trade_no']; //获取支付宝传递过来的订单号
- $transid = $_POST['trade_no']; //获取支付宝传递过来的交易号
- $amount = $_POST['total_fee']; //获取支付宝传递过来的总价格
- $fee = 0;
- if($status == 'TRADE_FINISHED' || $status == 'TRADE_SUCCESS') {
-
- $paidcurrency = "CNY";
- $result = select_query( 'tblcurrencies', '', array( 'code' => $paidcurrency ));
- $data = mysql_fetch_array($result);
- $paidcurrencyid = $data['id'];
-
- $result = select_query( 'tblinvoices', '', array( 'id' => $invoiceid ) );
- $data = mysql_fetch_array( $result );
- $userid = $data['userid'];
- $currency = getCurrency( $userid );
-
- if ($paidcurrencyid != $currency['id']) {
- $amount = convertCurrency( $amount, $paidcurrencyid, $currency['id'] );
- $fee = convertCurrency( $fee, $paidcurrencyid, $currency['id'] );
- }
-
- $invoiceid = checkCbInvoiceID($invoiceid,$GATEWAY["name"]); # Checks invoice ID is a valid invoice number or ends processing
- checkCbTransID($transid); # Checks transaction number isn't already in the database and ends processing if it does
- addInvoicePayment($invoiceid,$transid,$amount,$fee,$gatewaymodule);
- logTransaction($GATEWAY["name"],$_POST,"Successful");
- echo "success";
- }
- else
- echo "fail";
复制代码 |
|