From ecaa2812141d98e7ab591eedc4cea339bf6500c9 Mon Sep 17 00:00:00 2001 From: lyt Date: Tue, 15 Oct 2019 15:19:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20PayPal=E5=A4=84=E7=90=86webhook?= =?UTF-8?q?=E6=8E=A8=E9=80=81,=20IPN=E6=9C=AA=E6=94=B6=E5=88=B0=E7=BB=93?= =?UTF-8?q?=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webht/third_party/paypal/controllers/index.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/webht/third_party/paypal/controllers/index.php b/webht/third_party/paypal/controllers/index.php index a8d36996..8336b238 100644 --- a/webht/third_party/paypal/controllers/index.php +++ b/webht/third_party/paypal/controllers/index.php @@ -626,7 +626,7 @@ class Index extends CI_Controller { return; } $post_data = json_decode($raw_post); - if ($post_data->event_type != 'PAYMENT.SALE.COMPLETED') { + if ($post_data->event_type != 'PAYMENT.SALE.COMPLETED' && $post_data->event_type != 'PAYMENT.SALE.REFUNDED') { log_message('error',"paypal_webhook" . var_export($raw_post, 1)); return; } @@ -650,10 +650,15 @@ class Index extends CI_Controller { $pn_mc_currency = $post_data->resource->amount->currency; $pn_payment_status = $post_data->resource->state; + if ($post_data->event_type == 'PAYMENT.SALE.REFUNDED') { + $pn_payment_status = 'Refunded'; + $pn_mc_gross = '-' . $post_data->resource->amount->total; + $post_data->parent_txn_id = $post_data->resource->sale_id; + } $pn_payment_date = $post_data->resource->update_time; // $pn_payer = $post_data->resource->amount->currency; // $pn_payer_email = $post_data->resource->amount->currency; - $pn_memo = $raw_post; + $pn_memo = json_encode($post_data); // $raw_post; if (!empty($pn_txn_id)) { //把PDT时间转成GMT时间 $pn_payment_date = gmdate('Y-m-d H:i:s', strtotime($pn_payment_date)); @@ -823,7 +828,7 @@ class Index extends CI_Controller { if (isset($webhook_memo->id) && substr($webhook_memo->id, 0, 2)==="WH") { $is_webhook = true; } - if (true === $is_webhook) { + if (empty($pn_txn_id) && true === $is_webhook) { $this->Note_model->update_send($item->pn_txn_id, 'send', $item->pn_sn); continue; }