From 70bb2695d3b430ad56b546c6c6be64782d34a2d6 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Tue, 2 Jul 2024 11:09:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20PayPal:=20=E5=A4=84=E7=90=86webhook,=20?= =?UTF-8?q?=E6=8A=8APayPal=E8=B4=A6=E6=88=B7=E5=86=99=E5=85=A5=20GAI=20?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../third_party/paypal/controllers/index.php | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/webht/third_party/paypal/controllers/index.php b/webht/third_party/paypal/controllers/index.php index 36260b43..e35e43c8 100644 --- a/webht/third_party/paypal/controllers/index.php +++ b/webht/third_party/paypal/controllers/index.php @@ -743,10 +743,24 @@ class Index extends CI_Controller { $webhook_memo = json_decode($item->pn_memo); $res_links = null; $res_links = $webhook_memo->resource->links; - $res_links = json_encode($res_links, JSON_UNESCAPED_SLASHES); + // $res_links = json_encode($res_links, JSON_UNESCAPED_SLASHES); + + $default_payee = new stdClass; + $default_payee->email_address = "pays@chinahighlights.com"; + $default_payee->merchant_id = "JE4VX9SSVGTVN"; + $payee = isset($webhook_memo->resource->payee) ? $webhook_memo->resource->payee : $default_payee; + + $API = new stdClass; + $API->payee = $payee; + $API->res_links = $res_links; + + $API_str = json_encode($API, JSON_UNESCAPED_SLASHES); $pn_txn_id = $item->pn_txn_id; $orderid_info = $this->analysis_orderid($item->pn_invoice); + + $this->Note_model->update_send($item->pn_txn_id, 'sendfail', $item->pn_sn); + if (!empty($orderid_info)) { $orderid_info = json_decode($orderid_info); if ($orderid_info->ordertype === 'TP' || $orderid_info->ordertype === 'A') { @@ -756,19 +770,19 @@ class Index extends CI_Controller { if ($orderid_info->ordertype === 'T') { $data_gai = $this->Paypal_model->get_money_t($pn_txn_id); if ( ! empty($data_gai)) { - $this->Paypal_model->update_money_api_t($pn_txn_id, $res_links); + $this->Paypal_model->update_money_api_t($pn_txn_id, $API_str); $this->Note_model->update_send($item->pn_txn_id, 'send-wh-API', $item->pn_sn); } } elseif ($orderid_info->ordertype === 'B') { $data_gai = $this->Paypal_model->get_money_b($pn_txn_id, false); if ( ! empty($data_gai)) { - $this->Paypal_model->update_money_api_b($pn_txn_id, $res_links); + $this->Paypal_model->update_money_api_b($pn_txn_id, $API_str); $this->Note_model->update_send($item->pn_txn_id, 'send-wh-API', $item->pn_sn); } } } - return $res_links; + return $API_str; } public function handle_webhook_batch() {