mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #7489 from turbo124/v5-develop
Adjustments for Stripe Webhooks
This commit is contained in:
commit
978884f2ee
@ -23,6 +23,7 @@ use App\Http\Requests\CompanyGateway\UpdateCompanyGatewayRequest;
|
|||||||
use App\Jobs\Util\ApplePayDomain;
|
use App\Jobs\Util\ApplePayDomain;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\CompanyGateway;
|
use App\Models\CompanyGateway;
|
||||||
|
use App\PaymentDrivers\Stripe\Jobs\StripeWebhook;
|
||||||
use App\Repositories\CompanyRepository;
|
use App\Repositories\CompanyRepository;
|
||||||
use App\Transformers\CompanyGatewayTransformer;
|
use App\Transformers\CompanyGatewayTransformer;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
@ -212,6 +213,11 @@ class CompanyGatewayController extends BaseController
|
|||||||
|
|
||||||
ApplePayDomain::dispatch($company_gateway, $company_gateway->company->db);
|
ApplePayDomain::dispatch($company_gateway, $company_gateway->company->db);
|
||||||
|
|
||||||
|
if(in_array($company_gateway->gateway_key, $this->stripe_keys))
|
||||||
|
{
|
||||||
|
StripeWebhook::dispatch($company_gateway->company->company_key, $company_gateway->id);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->itemResponse($company_gateway);
|
return $this->itemResponse($company_gateway);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,8 @@ class StripeWebhook implements ShouldQueue
|
|||||||
|
|
||||||
public string $company_key;
|
public string $company_key;
|
||||||
|
|
||||||
|
private bool $url_found = false;
|
||||||
|
|
||||||
private array $events = [
|
private array $events = [
|
||||||
'source.chargeable',
|
'source.chargeable',
|
||||||
'charge.succeeded',
|
'charge.succeeded',
|
||||||
@ -64,9 +66,7 @@ class StripeWebhook implements ShouldQueue
|
|||||||
|
|
||||||
$company_gateway = CompanyGateway::find($this->company_gateway_id);
|
$company_gateway = CompanyGateway::find($this->company_gateway_id);
|
||||||
|
|
||||||
$driver = $company_gateway->driver();
|
$stripe = $company_gateway->driver()->init();
|
||||||
|
|
||||||
$stripe = $driver->init();
|
|
||||||
|
|
||||||
$endpoints = \Stripe\WebhookEndpoint::all([], $stripe->stripe_connect_auth);
|
$endpoints = \Stripe\WebhookEndpoint::all([], $stripe->stripe_connect_auth);
|
||||||
|
|
||||||
@ -77,19 +77,23 @@ class StripeWebhook implements ShouldQueue
|
|||||||
|
|
||||||
if($endpoint->url === $webhook_url)
|
if($endpoint->url === $webhook_url)
|
||||||
{
|
{
|
||||||
\Stripe\WebhookEndpoint::update($endpoint->id, $this->events, $stripe->stripe_connect_auth);
|
|
||||||
|
\Stripe\WebhookEndpoint::update($endpoint->id, ['enabled_events' => $this->events], $stripe->stripe_connect_auth);
|
||||||
|
|
||||||
|
$this->url_found = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add new webhook */
|
/* Add new webhook */
|
||||||
if(count($endpoints['data'] == 0)
|
if(!$this->url_found)
|
||||||
{
|
{
|
||||||
|
|
||||||
\Stripe\WebhookEndpoint::create([
|
\Stripe\WebhookEndpoint::create([
|
||||||
'url' => $webhook_url,
|
'url' => $webhook_url,
|
||||||
'enabled_events' => $this->events,
|
'enabled_events' => $this->events,
|
||||||
], $stripe->stripe_connect_auth)
|
], $stripe->stripe_connect_auth);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user