perf: PayPal退款: 优先处理IPN

webht/payment
Lei OT 9 months ago
parent 18bb1e1e84
commit 028f48d069

@ -1251,6 +1251,16 @@ class Index extends CI_Controller {
public function send_refund($item, $handpick, $old_ssje=NULL)
{
$payment_memo = json_decode($item->pn_memo);
// 查询IPN通知, 优先按IPN处理
$notes = $this->Note_model->search_note($item->pn_txn_id);
if ( ! empty($notes) ) { // && strpos($notes[0]->pn_custom, 'GPA_') === false
$memo0 = json_decode($notes[0]->pn_memo);
if ( ! (isset($memo0->id) && substr($memo0->id, 0, 2)==="WH")) {
$IPN_note = $notes[0]; // 存在IPN, 本条忽略
$this->Note_model->update_send($item->pn_txn_id, 'send-', $item->pn_sn);
return false;
}
}
// 找到原始收款交易的订单
$parent_txn_id = $payment_memo->parent_txn_id;
$parent_note = $this->Note_model->note($parent_txn_id);
@ -1263,6 +1273,7 @@ class Index extends CI_Controller {
} else {
//订单号
$orderid_info = $this->analysis_orderid($parent_note->pn_invoice);
$orderid_info = empty($orderid_info) ? $this->analysis_orderid($item->pn_invoice) : $orderid_info;
}
//找不到订单号,设置为发送失败标示
@ -1358,6 +1369,7 @@ class Index extends CI_Controller {
}
}
$this->Note_model->update_send($item->pn_txn_id, 'send-', $item->pn_sn);
$opi_email = !empty($advisor_info->OPI_Email) ? $advisor_info->OPI_Email : ''; //lussie@chinahighlights.net
$opi_firstname = !empty($advisor_info->OPI_FirstName) ? $advisor_info->OPI_FirstName : !empty($advisor_info->OPI_Name) ? $advisor_info->OPI_Name : ''; //lussie
@ -1368,7 +1380,6 @@ class Index extends CI_Controller {
return false;
}
$this->Note_model->update_send($item->pn_txn_id, 'send-', $item->pn_sn);
//添加邮件发送记录; webhook不发送邮件, 避免重复
if ($is_webhook === false) {
if ($item->pn_send !== 'send' && substr($item->pn_send, 0, 5) !== 'send-'

Loading…
Cancel
Save