mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 10:44:29 -04:00
Apple Pay domain validation
This commit is contained in:
parent
6502ca0bf4
commit
6bfd4d34a6
@ -15,10 +15,25 @@ namespace App\PaymentDrivers\Stripe;
|
||||
use Illuminate\Http\Request;
|
||||
use App\PaymentDrivers\Common\MethodInterface;
|
||||
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
use App\Utils\Ninja;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Stripe\ApplePayDomain;
|
||||
use Stripe\Exception\ApiErrorException;
|
||||
|
||||
class BrowserPay implements MethodInterface
|
||||
{
|
||||
protected StripePaymentDriver $stripe;
|
||||
|
||||
public function __construct(StripePaymentDriver $stripe)
|
||||
{
|
||||
$this->stripe = $stripe;
|
||||
|
||||
$this->stripe->init();
|
||||
|
||||
$this->ensureApplePayDomainIsValidated();
|
||||
}
|
||||
|
||||
/**
|
||||
* Authorization page for browser pay.
|
||||
*
|
||||
@ -44,4 +59,37 @@ class BrowserPay implements MethodInterface
|
||||
public function paymentView(array $data) {}
|
||||
|
||||
public function paymentResponse(PaymentResponseRequest $request) { }
|
||||
|
||||
/**
|
||||
* Ensure Apple Pay domain is verified.
|
||||
*
|
||||
* @return void
|
||||
* @throws ApiErrorException
|
||||
*/
|
||||
protected function ensureApplePayDomainIsValidated()
|
||||
{
|
||||
$config = $this->stripe->company_gateway->getConfig();
|
||||
|
||||
if (property_exists($config, 'apple_pay_domain_id')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$domain = config('ninja.app_url');
|
||||
|
||||
if (Ninja::isHosted()) {
|
||||
$domain = isset($this->stripe_driver->company_gateway->company->portal_domain)
|
||||
? $this->stripe_driver->company_gateway->company->portal_domain
|
||||
: $this->stripe_driver->company_gateway->company->domain();
|
||||
}
|
||||
|
||||
$response = ApplePayDomain::create([
|
||||
'domain_name' => $domain,
|
||||
]);
|
||||
|
||||
$config->apple_pay_domain_id = $response->id;
|
||||
|
||||
$this->stripe->company_gateway->setConfig($config);
|
||||
|
||||
$this->stripe->company_gateway->save();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user