Quantcast
Channel: WHMCS Community Forums
Viewing all articles
Browse latest Browse all 13458

[Urgent]AliPay Payment Gateway Cannot Update Invoice Status

$
0
0
Hi All

I am experiencing a strange thing that after customers paid their invoices, my Alipay gateway cannot automatic update invoice status from Unpaid to Paid.

I am using WHMCS 5.1.5 and this is my callback code:

Normally, the trade status should be WAIT_SELLER_SEND_GOODS and at this time, this invoice should be set to Paid.

PHP Code:

<?php

# Required File Includes
include("../../../dbconnect.php");
include(
"../../../includes/functions.php");
include(
"../../../includes/gatewayfunctions.php");
include(
"../../../includes/invoicefunctions.php");
require_once(
"../lib/alipay_service.class.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
$need_confirm=$GATEWAY['need_confirm'];
$auto_send=$GATEWAY['auto_send'];
$debug=$GATEWAY['debug'];
$alipay_config['input_charset'] = "utf-8";
$alipay_config['sign_type']      = "MD5";
$alipay_config['transport']      = "http";
$alipay_config['partner']      = $GATEWAY['partnerID'];
$alipay_config['key']          = $GATEWAY['security_code'];
$alipay_config['seller_email'] = $GATEWAY['seller_email'];
//logTransaction($GATEWAY["name"],$_POST,"info");
$alipayNotify = new AlipayNotify($alipay_config);
$verify_result $alipayNotify->verifyNotify();
if(!
$verify_result) { 
    
logTransaction($GATEWAY["name"],$_POST,"Unsuccessful1");
    exit;
}
# Get Returned Variables
$status    $_POST['trade_status'];    // Get Trade Status
$invoiceid $_POST['out_trade_no']; // Get Invoice Number
$transid   $_POST['trade_no'];       // Get Transcation Number
$amount    $_POST['total_fee'];       // Get Total Fee
$fee       0;

if(
$status == 'TRADE_FINISHED' || $status == 'TRADE_SUCCESS') { // Trade OK
    
$invoiceid checkCbInvoiceID($invoiceid,$GATEWAY["name"]); # Checks invoice ID is a valid invoice number or ends processing
    
checkCbTransID($transid);
    
addInvoicePayment($invoiceid,$transid,$amount,$fee,$gatewaymodule);
    
logTransaction($GATEWAY["name"],$_POST,"Successful-A");
}
elseif(
$status == 'WAIT_BUYER_CONFIRM_GOODS' ){  // THIS SHOULD BE CURRENT STATUS FOR ME
    
if (!$need_confirm){
        
$invoiceid checkCbInvoiceID($invoiceid,$GATEWAY["name"]); # Checks invoice ID is a valid invoice number or ends processing
        
checkCbTransID($transid);
        
addInvoicePayment($invoiceid,$transid,$amount,$fee,$gatewaymodule);
        
logTransaction($GATEWAY["name"],$_POST,"Successful-B");
    }
}
elseif(
$status == 'WAIT_SELLER_SEND_GOODS' ){
    if (
$auto_send){
        
$parameter = array(
            
"service"            => "send_goods_confirm_by_platform",
            
"partner"            => $GATEWAY['partnerID'],
            
"_input_charset"    => trim(strtolower($alipay_config['input_charset'])),
            
"trade_no"            => $transid,
            
"logistics_name"    => "AUTO_WHMCS",
            
"invoice_no"        => $invoiceid,
            
"transport_type"    => $_POST['logistics_type']
        );

        
$alipayService = new AlipayService($alipay_config);
        
$doc $alipayService->send_goods_confirm_by_platform($parameter);
    }
    if (!
$need_confirm){
        
addInvoicePayment($invoiceid,$transid,$amount,$fee,$gatewaymodule);
        
logTransaction($GATEWAY["name"],$_POST,"Successful");
    }
    else{
        
logTransaction($GATEWAY["name"],$_POST,"Unsuccessful-2");
    }
}
?>


Viewing all articles
Browse latest Browse all 13458

Trending Articles