mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Apply Prettier & php-cs-fixer
This commit is contained in:
parent
e67da85136
commit
a569a2afad
@ -11,15 +11,15 @@
|
|||||||
|
|
||||||
namespace App\PaymentDrivers\Stripe;
|
namespace App\PaymentDrivers\Stripe;
|
||||||
|
|
||||||
|
use App\Exceptions\PaymentFailed;
|
||||||
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
||||||
use App\PaymentDrivers\StripePaymentDriver;
|
|
||||||
use App\Jobs\Mail\PaymentFailureMailer;
|
use App\Jobs\Mail\PaymentFailureMailer;
|
||||||
use App\Jobs\Util\SystemLogger;
|
use App\Jobs\Util\SystemLogger;
|
||||||
use App\Models\GatewayType;
|
use App\Models\GatewayType;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\PaymentType;
|
use App\Models\PaymentType;
|
||||||
use App\Models\SystemLog;
|
use App\Models\SystemLog;
|
||||||
use App\Exceptions\PaymentFailed;
|
use App\PaymentDrivers\StripePaymentDriver;
|
||||||
|
|
||||||
class SEPA
|
class SEPA
|
||||||
{
|
{
|
||||||
@ -38,7 +38,8 @@ class SEPA
|
|||||||
return render('gateways.stripe.sepa.authorize', $data);
|
return render('gateways.stripe.sepa.authorize', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function paymentView(array $data) {
|
public function paymentView(array $data)
|
||||||
|
{
|
||||||
$data['gateway'] = $this->stripe;
|
$data['gateway'] = $this->stripe;
|
||||||
$data['payment_method_id'] = GatewayType::SEPA;
|
$data['payment_method_id'] = GatewayType::SEPA;
|
||||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||||
@ -89,13 +90,10 @@ class SEPA
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $this->processUnsuccessfulPayment();
|
return $this->processUnsuccessfulPayment();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processSuccessfulPayment(string $payment_intent)
|
public function processSuccessfulPayment(string $payment_intent)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'payment_method' => $payment_intent,
|
'payment_method' => $payment_intent,
|
||||||
'payment_type' => PaymentType::SEPA,
|
'payment_type' => PaymentType::SEPA,
|
||||||
@ -150,7 +148,6 @@ class SEPA
|
|||||||
private function storePaymentMethod($intent)
|
private function storePaymentMethod($intent)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$method = $this->stripe->getStripePaymentMethod($intent->payment_method);
|
$method = $this->stripe->getStripePaymentMethod($intent->payment_method);
|
||||||
|
|
||||||
$payment_meta = new \stdClass;
|
$payment_meta = new \stdClass;
|
||||||
|
171
resources/js/clients/payments/stripe-sepa.js
vendored
171
resources/js/clients/payments/stripe-sepa.js
vendored
@ -18,75 +18,96 @@ class ProcessSEPA {
|
|||||||
setupStripe = () => {
|
setupStripe = () => {
|
||||||
this.stripe = Stripe(this.key);
|
this.stripe = Stripe(this.key);
|
||||||
|
|
||||||
if(this.stripeConnect)
|
if (this.stripeConnect) this.stripe.stripeAccount = stripeConnect;
|
||||||
this.stripe.stripeAccount = stripeConnect;
|
|
||||||
const elements = this.stripe.elements();
|
const elements = this.stripe.elements();
|
||||||
var style = {
|
var style = {
|
||||||
base: {
|
base: {
|
||||||
color: "#32325d",
|
color: '#32325d',
|
||||||
fontFamily:
|
fontFamily:
|
||||||
'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',
|
'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',
|
||||||
fontSmoothing: "antialiased",
|
fontSmoothing: 'antialiased',
|
||||||
fontSize: "16px",
|
fontSize: '16px',
|
||||||
"::placeholder": {
|
'::placeholder': {
|
||||||
color: "#aab7c4"
|
color: '#aab7c4',
|
||||||
|
},
|
||||||
|
':-webkit-autofill': {
|
||||||
|
color: '#32325d',
|
||||||
},
|
},
|
||||||
":-webkit-autofill": {
|
|
||||||
color: "#32325d"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
invalid: {
|
invalid: {
|
||||||
color: "#fa755a",
|
color: '#fa755a',
|
||||||
iconColor: "#fa755a",
|
iconColor: '#fa755a',
|
||||||
":-webkit-autofill": {
|
':-webkit-autofill': {
|
||||||
color: "#fa755a"
|
color: '#fa755a',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
var options = {
|
var options = {
|
||||||
style: style,
|
style: style,
|
||||||
supportedCountries: ["SEPA"],
|
supportedCountries: ['SEPA'],
|
||||||
// If you know the country of the customer, you can optionally pass it to
|
// If you know the country of the customer, you can optionally pass it to
|
||||||
// the Element as placeholderCountry. The example IBAN that is being used
|
// the Element as placeholderCountry. The example IBAN that is being used
|
||||||
// as placeholder reflects the IBAN format of that country.
|
// as placeholder reflects the IBAN format of that country.
|
||||||
placeholderCountry: document.querySelector('meta[name="country"]').content
|
placeholderCountry: document.querySelector('meta[name="country"]')
|
||||||
|
.content,
|
||||||
};
|
};
|
||||||
this.iban = elements.create("iban", options);
|
this.iban = elements.create('iban', options);
|
||||||
this.iban.mount("#sepa-iban");
|
this.iban.mount('#sepa-iban');
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
handle = () => {
|
handle = () => {
|
||||||
let errors = document.getElementById('errors');
|
let errors = document.getElementById('errors');
|
||||||
|
|
||||||
Array
|
Array.from(
|
||||||
.from(document.getElementsByClassName('toggle-payment-with-token'))
|
document.getElementsByClassName('toggle-payment-with-token')
|
||||||
.forEach((element) => element.addEventListener('click', (element) => {
|
).forEach((element) =>
|
||||||
document.getElementById('stripe--payment-container').classList.add('hidden');
|
element.addEventListener('click', (element) => {
|
||||||
document.getElementById('save-card--container').style.display = 'none';
|
document
|
||||||
document.querySelector('input[name=token]').value = element.target.dataset.token;
|
.getElementById('stripe--payment-container')
|
||||||
}));
|
.classList.add('hidden');
|
||||||
|
document.getElementById('save-card--container').style.display =
|
||||||
|
'none';
|
||||||
|
document.querySelector('input[name=token]').value =
|
||||||
|
element.target.dataset.token;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
document
|
document
|
||||||
.getElementById('toggle-payment-with-new-bank-account')
|
.getElementById('toggle-payment-with-new-bank-account')
|
||||||
.addEventListener('click', (element) => {
|
.addEventListener('click', (element) => {
|
||||||
document.getElementById('stripe--payment-container').classList.remove('hidden');
|
document
|
||||||
document.getElementById('save-card--container').style.display = 'grid';
|
.getElementById('stripe--payment-container')
|
||||||
document.querySelector('input[name=token]').value = "";
|
.classList.remove('hidden');
|
||||||
|
document.getElementById('save-card--container').style.display =
|
||||||
|
'grid';
|
||||||
|
document.querySelector('input[name=token]').value = '';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
document.getElementById('pay-now').addEventListener('click', (e) => {
|
document.getElementById('pay-now').addEventListener('click', (e) => {
|
||||||
if (document.querySelector('input[name=token]').value.length !== 0) {
|
if (
|
||||||
|
document.querySelector('input[name=token]').value.length !== 0
|
||||||
|
) {
|
||||||
document.querySelector('#errors').hidden = true;
|
document.querySelector('#errors').hidden = true;
|
||||||
|
|
||||||
document.getElementById('pay-now').disabled = true;
|
document.getElementById('pay-now').disabled = true;
|
||||||
document.querySelector('#pay-now > svg').classList.remove('hidden');
|
document
|
||||||
document.querySelector('#pay-now > span').classList.add('hidden');
|
.querySelector('#pay-now > svg')
|
||||||
|
.classList.remove('hidden');
|
||||||
|
document
|
||||||
|
.querySelector('#pay-now > span')
|
||||||
|
.classList.add('hidden');
|
||||||
|
|
||||||
this.stripe.confirmSepaDebitSetup(document.querySelector('meta[name=si-client-secret').content, {
|
this.stripe
|
||||||
payment_method: document.querySelector('input[name=token]').value
|
.confirmSepaDebitSetup(
|
||||||
})
|
document.querySelector('meta[name=si-client-secret')
|
||||||
|
.content,
|
||||||
|
{
|
||||||
|
payment_method: document.querySelector(
|
||||||
|
'input[name=token]'
|
||||||
|
).value,
|
||||||
|
}
|
||||||
|
)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@ -98,8 +119,11 @@ class ProcessSEPA {
|
|||||||
'input[name="gateway_response"]'
|
'input[name="gateway_response"]'
|
||||||
).value = JSON.stringify(result.setupIntent);
|
).value = JSON.stringify(result.setupIntent);
|
||||||
|
|
||||||
return document.querySelector('#server-response').submit();
|
return document
|
||||||
}).catch((error) => {
|
.querySelector('#server-response')
|
||||||
|
.submit();
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
errors.textContent = error;
|
errors.textContent = error;
|
||||||
errors.hidden = false;
|
errors.hidden = false;
|
||||||
});
|
});
|
||||||
@ -107,25 +131,30 @@ class ProcessSEPA {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (document.getElementById('sepa-name').value === "") {
|
if (document.getElementById('sepa-name').value === '') {
|
||||||
document.getElementById('sepa-name').focus();
|
document.getElementById('sepa-name').focus();
|
||||||
errors.textContent = document.querySelector('meta[name=translation-name-required]').content;
|
errors.textContent = document.querySelector(
|
||||||
|
'meta[name=translation-name-required]'
|
||||||
|
).content;
|
||||||
errors.hidden = false;
|
errors.hidden = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (document.getElementById('sepa-email-address').value === "") {
|
if (document.getElementById('sepa-email-address').value === '') {
|
||||||
document.getElementById('sepa-email-address').focus();
|
document.getElementById('sepa-email-address').focus();
|
||||||
errors.textContent = document.querySelector('meta[name=translation-email-required]').content;
|
errors.textContent = document.querySelector(
|
||||||
|
'meta[name=translation-email-required]'
|
||||||
|
).content;
|
||||||
errors.hidden = false;
|
errors.hidden = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!document.getElementById('sepa-mandate-acceptance').checked) {
|
if (!document.getElementById('sepa-mandate-acceptance').checked) {
|
||||||
errors.textContent = document.querySelector('meta[name=translation-terms-required]').content;
|
errors.textContent = document.querySelector(
|
||||||
|
'meta[name=translation-terms-required]'
|
||||||
|
).content;
|
||||||
errors.hidden = false;
|
errors.hidden = false;
|
||||||
console.log("Terms");
|
console.log('Terms');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,24 +162,30 @@ class ProcessSEPA {
|
|||||||
document.querySelector('#pay-now > svg').classList.remove('hidden');
|
document.querySelector('#pay-now > svg').classList.remove('hidden');
|
||||||
document.querySelector('#pay-now > span').classList.add('hidden');
|
document.querySelector('#pay-now > span').classList.add('hidden');
|
||||||
|
|
||||||
this.stripe.confirmSepaDebitPayment(
|
this.stripe
|
||||||
document.querySelector('meta[name=pi-client-secret').content,
|
.confirmSepaDebitPayment(
|
||||||
{
|
document.querySelector('meta[name=pi-client-secret')
|
||||||
payment_method: {
|
.content,
|
||||||
sepa_debit: this.iban,
|
{
|
||||||
billing_details: {
|
payment_method: {
|
||||||
name: document.getElementById("sepa-name").value,
|
sepa_debit: this.iban,
|
||||||
email: document.getElementById("sepa-email-address").value,
|
billing_details: {
|
||||||
|
name: document.getElementById('sepa-name')
|
||||||
|
.value,
|
||||||
|
email: document.getElementById(
|
||||||
|
'sepa-email-address'
|
||||||
|
).value,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
}
|
)
|
||||||
).then((result) => {
|
.then((result) => {
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
return this.handleFailure(result.error.message);
|
return this.handleFailure(result.error.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.handleSuccess(result);
|
return this.handleSuccess(result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -178,15 +213,15 @@ class ProcessSEPA {
|
|||||||
errors.textContent = message;
|
errors.textContent = message;
|
||||||
errors.hidden = false;
|
errors.hidden = false;
|
||||||
|
|
||||||
document.getElementById('pay-now').disabled = false;
|
document.getElementById('pay-now').disabled = false;
|
||||||
document.querySelector('#pay-now > svg').classList.add('hidden');
|
document.querySelector('#pay-now > svg').classList.add('hidden');
|
||||||
document.querySelector('#pay-now > span').classList.remove('hidden');
|
document.querySelector('#pay-now > span').classList.remove('hidden');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const publishableKey = document.querySelector(
|
const publishableKey =
|
||||||
'meta[name="stripe-publishable-key"]'
|
document.querySelector('meta[name="stripe-publishable-key"]')?.content ??
|
||||||
)?.content ?? '';
|
'';
|
||||||
|
|
||||||
const stripeConnect =
|
const stripeConnect =
|
||||||
document.querySelector('meta[name="stripe-account-id"]')?.content ?? '';
|
document.querySelector('meta[name="stripe-account-id"]')?.content ?? '';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user