mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Apple Pay
This commit is contained in:
parent
cde5f527e1
commit
7092d66ecd
@ -22,6 +22,7 @@ use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
use App\PaymentDrivers\Stripe\CreditCard;
|
||||
use App\Utils\Ninja;
|
||||
|
||||
class ApplePay
|
||||
{
|
||||
@ -35,6 +36,8 @@ class ApplePay
|
||||
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$this->registerDomain();
|
||||
|
||||
$data['gateway'] = $this->stripe_driver;
|
||||
$data['payment_hash'] = $this->stripe_driver->payment_hash->hash;
|
||||
$data['payment_method_id'] = GatewayType::APPLE_PAY;
|
||||
@ -75,7 +78,7 @@ class ApplePay
|
||||
$server_response = $this->stripe_driver->payment_hash->data->server_response;
|
||||
|
||||
$response_handler = new CreditCard($this->stripe_driver);
|
||||
|
||||
|
||||
if ($server_response->status == 'succeeded') {
|
||||
|
||||
$this->stripe_driver->logSuccessfulGatewayResponse(['response' => json_decode($request->gateway_response), 'data' => $this->stripe_driver->payment_hash], SystemLog::TYPE_STRIPE);
|
||||
@ -88,4 +91,27 @@ class ApplePay
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function registerDomain()
|
||||
{
|
||||
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();
|
||||
|
||||
\Stripe\ApplePayDomain::create([
|
||||
'domain_name' => $domain,
|
||||
], $this->stripe_driver->stripe_connect_auth);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
\Stripe\ApplePayDomain::create([
|
||||
'domain_name' => config('ninja.app_url'),
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'Alipay', 'card_title' => 'Alipay'])
|
||||
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'Apple Pay', 'card_title' => 'Apple Pay'])
|
||||
|
||||
@section('gateway_head')
|
||||
|
||||
@ -88,6 +88,7 @@
|
||||
stripe.confirmCardPayment(clientSecret).then(function(result) {
|
||||
if (result.error) {
|
||||
// The payment failed -- ask your customer for a new payment method.
|
||||
handleFailure(result.error)
|
||||
} else {
|
||||
// The payment has succeeded.
|
||||
handleSuccess(result);
|
||||
@ -108,5 +109,14 @@
|
||||
document.getElementById('server-response').submit();
|
||||
}
|
||||
|
||||
handleFailure(message) {
|
||||
let errors = document.getElementById('errors');
|
||||
|
||||
errors.textContent = '';
|
||||
errors.textContent = message;
|
||||
errors.hidden = false;
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
@endpush
|
Loading…
x
Reference in New Issue
Block a user