1
0
Fork 0

feat: webhook create for returning payment

fix: email is now correctly throws over
This commit is contained in:
Konrad Geletey 2024-02-23 23:19:27 +03:00
parent 7951058097
commit 1e95fd8bce
Signed by: kglt
GPG key ID: 386DEE24B60BD996
2 changed files with 19 additions and 1 deletions

View file

@ -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);
}
}
}

5
routes.php Normal file
View file

@ -0,0 +1,5 @@
<?php
use Illuminate\Support\Facades\Route;
Route::post('/bitcart/webhook', [App\Extensions\Gateways\BitCart\BitCart::class, 'webhook']);