From 689f6aa3b26320ba82cfbe02ab280cf60c82a0a1 Mon Sep 17 00:00:00 2001 From: lyt Date: Fri, 24 May 2019 09:58:16 +0800 Subject: [PATCH] =?UTF-8?q?PayPal=20webhook=E6=B2=A1=E6=9C=89=E4=BB=98?= =?UTF-8?q?=E6=AC=BE=E4=BA=BA=E4=BF=A1=E6=81=AF,=E5=85=88=E8=B7=B3?= =?UTF-8?q?=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../third_party/paypal/controllers/index.php | 22 ++++++++++++------- .../third_party/paypal/models/note_model.php | 5 +++-- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/webht/third_party/paypal/controllers/index.php b/webht/third_party/paypal/controllers/index.php index c2487dfc..c732415e 100644 --- a/webht/third_party/paypal/controllers/index.php +++ b/webht/third_party/paypal/controllers/index.php @@ -785,13 +785,13 @@ class Index extends CI_Controller { */ //找到没有发送的记录 - public function send_note($pn_txn_id = false, $old_ssje=NULL) { + public function send_note($pn_txn_id = false, $old_ssje=NULL, $pn_sn=NULL) { $data = array(); $handpick = empty($pn_txn_id) ? false : TRUE; //优先处理指定的交易号,用于修正交易号直接发送通知 if (!empty($pn_txn_id)) { - $data['unsend_list'] = array($this->Note_model->note($pn_txn_id)); + $data['unsend_list'] = array($this->Note_model->note($pn_txn_id, $pn_sn)); } //找到处理过的的记录 @@ -816,6 +816,18 @@ class Index extends CI_Controller { if (empty($pn_txn_id)) { echo ++$show_index . ' ' . $item->pn_txn_id . '
'; } + + // webhook的跳过 + $webhook_memo = json_decode($item->pn_memo); + $is_webhook = false; + if (isset($webhook_memo->id) && substr($webhook_memo->id, 0, 2)==="WH") { + $is_webhook = true; + } + if (true === $is_webhook) { + $this->Note_model->update_send($item->pn_txn_id, 'sendfail'); + continue; + } + //退款状态默认为已经处理,陆燕在退款前手动通知外联了,系统跳过处理 if (strtolower($item->pn_payment_status) == 'refunded') { $this->send_refund($item, $handpick, $old_ssje); @@ -960,13 +972,7 @@ class Index extends CI_Controller { continue; } - //添加邮件发送记录 - $webhook_memo = json_decode($item->pn_memo); - $is_webhook = false; - if (isset($webhook_memo->id) && substr($webhook_memo->id, 0, 2)==="WH") { - $is_webhook = true; - } if ($item->pn_send !== 'send' && false===$is_webhook) { //给外联发送通知邮件 $fromName = !empty($item->pn_payer) ? $item->pn_payer : ''; diff --git a/webht/third_party/paypal/models/note_model.php b/webht/third_party/paypal/models/note_model.php index de9448e3..78d7ad70 100644 --- a/webht/third_party/paypal/models/note_model.php +++ b/webht/third_party/paypal/models/note_model.php @@ -135,12 +135,13 @@ class Note_model extends CI_Model { } } - public function update_send($pn_txn_id, $pn_send) { + public function update_send($pn_txn_id, $pn_send, $pn_sn=NULL) { $sql = " UPDATE paypal_note SET pn_send = ? WHERE pn_txn_id = ? - "; + "; + $sql .= ($pn_sn===NULL) ? "" : " and pn_sn=$pn_sn "; return $this->HT->query($sql, array($pn_send, $pn_txn_id)); }