From 1e95fd8bce1aa9ef4f25348842eb309d6caba425 Mon Sep 17 00:00:00 2001 From: kogeletey Date: Fri, 23 Feb 2024 23:19:27 +0300 Subject: [PATCH] feat: webhook create for returning payment fix: email is now correctly throws over --- BitCart.php | 15 ++++++++++++++- routes.php | 5 +++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 routes.php diff --git a/BitCart.php b/BitCart.php index f6d496e..e719049 100644 --- a/BitCart.php +++ b/BitCart.php @@ -7,6 +7,7 @@ namespace App\Extensions\Gateways\BitCart; use App\Classes\Extensions\Gateway; use App\Helpers\ExtensionHelper; use Illuminate\Support\Facades\Http; +use Illuminate\Http\Request; class BitCart extends Gateway { @@ -74,8 +75,9 @@ class BitCart extends Gateway 'price' => number_format($amount, 2, '.', ''), 'store_id' => ExtensionHelper::getConfig('Bitcart','store_id'), 'currency' => ExtensionHelper::getCurrency(), - 'email' => auth()->user()->email, + 'buyer_email' => auth()->user()->email, 'redirect_url' => route('clients.invoice.show', $invoiceId), + 'notification_url' => url('/extensions/bitcart/webhook'), 'order_id' => $invoiceId, ); $invoice = $this->send_request(sprintf('%s/%s', $api_domain, 'invoices/order_id/' . urlencode($invoiceId)), $params); @@ -103,4 +105,15 @@ class BitCart extends Gateway return json_decode($result); } + + public function webhook(Request $request) + { + $body = $request->getContent(); + $data = json_decode($body, true); + $invoiceId = $data['id']; + $status = $data['status']; + if ($status == 'complete') { + ExtensionHelper::paymentDone($invoiceId,'BitCart',null); + } + } } diff --git a/routes.php b/routes.php new file mode 100644 index 0000000..28acaf9 --- /dev/null +++ b/routes.php @@ -0,0 +1,5 @@ +