feat: webhook create for returning payment
fix: email is now correctly throws over
This commit is contained in:
parent
7951058097
commit
1e95fd8bce
2 changed files with 19 additions and 1 deletions
15
BitCart.php
15
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
5
routes.php
Normal file
5
routes.php
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::post('/bitcart/webhook', [App\Extensions\Gateways\BitCart\BitCart::class, 'webhook']);
|
Reference in a new issue