mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -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 Illuminate\Http\Request;
|
||||||
use App\PaymentDrivers\Common\MethodInterface;
|
use App\PaymentDrivers\Common\MethodInterface;
|
||||||
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
||||||
|
use App\PaymentDrivers\StripePaymentDriver;
|
||||||
|
use App\Utils\Ninja;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Stripe\ApplePayDomain;
|
||||||
|
use Stripe\Exception\ApiErrorException;
|
||||||
|
|
||||||
class BrowserPay implements MethodInterface
|
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.
|
* Authorization page for browser pay.
|
||||||
*
|
*
|
||||||
@ -41,7 +56,40 @@ class BrowserPay implements MethodInterface
|
|||||||
return redirect()->route('client.payment_methods.index');
|
return redirect()->route('client.payment_methods.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function paymentView(array $data) { }
|
public function paymentView(array $data) {}
|
||||||
|
|
||||||
public function paymentResponse(PaymentResponseRequest $request) { }
|
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