Hi,
Repeated notifications still exist, even if I print out "success".
My modified code:
if((preg_match('/true$/i', $response) && $sign == $_POST['sign']) && ( /* $_POST['trade_status'] == 'TRADE_FINISHED' || */ $_POST['trade_status'] == 'TRADE_SUCCESS' || $_POST['trade_status'] == 'WAIT_SELLER_SEND_GOODS' /* || $_POST['trade_status']== 'WAIT_BUYER_PAY' */ )) {
$price_check = round($dbOrder->order_full_price, (int)$this->currency->currency_locale['int_frac_digits'] );
$history->notified=1;
$history->amount=$price_check;
$history->data = ob_get_clean();
$order_status = $this->payment_params->verified_status;
if($dbOrder->order_status == $order_status) echo "success"; //return true;
$mail_status=$statuses[$order_status];
$email->subject = JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER','Alipay',$_POST['trade_status'],$dbOrder->order_number);
$email->body = str_replace('<br/>',"\r\n",JText::sprintf('PAYMENT_NOTIFICATION_STATUS','Alipay',$_POST['trade_status'])).' '.JText::sprintf('ORDER_STATUS_CHANGED',$mail_status)."\r\n\r\n".$order_text;
$this->modifyOrder($order_id,$order_status,$history,$email);
echo "success";
// return true;
} else {
$email->subject = JText::sprintf('NOTIFICATION_REFUSED_FOR_THE_ORDER','Alipay').'invalid response';
$email->body = JText::sprintf("Hello,\r\n An Alipay notification was refused because the response from the Alipay server was invalid")."\r\n\r\n".$order_text;
$this->modifyOrder($order_id,null,false,$email);
if($this->payment_params->debug){
$this->writeToLog('invalid response'."\n\n\n");
}
echo "fail";
// return false;
}
'TRADE_FINISHED' means that,After the order is completed for three months, the refund will not be allowed and the alipay server will send the notification to hikashop three months later, allowing the merchant to perform a custom action based on the result of this notification.
更新分割线
Maybe echo "success" only works for the two gateway
mapi.alipay.com/gateway.do
and
openapi.alipay.com/gateway.do
.
I used return "success", Now it works fine. See screenshot 5.