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;
|
||||
|
||||
use App\Exceptions\PaymentFailed;
|
||||
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
use App\Jobs\Mail\PaymentFailureMailer;
|
||||
use App\Jobs\Util\SystemLogger;
|
||||
use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\Exceptions\PaymentFailed;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
|
||||
class SEPA
|
||||
{
|
||||
@ -38,7 +38,8 @@ class SEPA
|
||||
return render('gateways.stripe.sepa.authorize', $data);
|
||||
}
|
||||
|
||||
public function paymentView(array $data) {
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$data['gateway'] = $this->stripe;
|
||||
$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());
|
||||
@ -89,13 +90,10 @@ class SEPA
|
||||
}
|
||||
|
||||
return $this->processUnsuccessfulPayment();
|
||||
|
||||
}
|
||||
|
||||
public function processSuccessfulPayment(string $payment_intent)
|
||||
{
|
||||
|
||||
|
||||
$data = [
|
||||
'payment_method' => $payment_intent,
|
||||
'payment_type' => PaymentType::SEPA,
|
||||
@ -150,7 +148,6 @@ class SEPA
|
||||
private function storePaymentMethod($intent)
|
||||
{
|
||||
try {
|
||||
|
||||
$method = $this->stripe->getStripePaymentMethod($intent->payment_method);
|
||||
|
||||
$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 = () => {
|
||||
this.stripe = Stripe(this.key);
|
||||
|
||||
if(this.stripeConnect)
|
||||
this.stripe.stripeAccount = stripeConnect;
|
||||
if (this.stripeConnect) this.stripe.stripeAccount = stripeConnect;
|
||||
const elements = this.stripe.elements();
|
||||
var style = {
|
||||
base: {
|
||||
color: "#32325d",
|
||||
color: '#32325d',
|
||||
fontFamily:
|
||||
'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',
|
||||
fontSmoothing: "antialiased",
|
||||
fontSize: "16px",
|
||||
"::placeholder": {
|
||||
color: "#aab7c4"
|
||||
fontSmoothing: 'antialiased',
|
||||
fontSize: '16px',
|
||||
'::placeholder': {
|
||||
color: '#aab7c4',
|
||||
},
|
||||
':-webkit-autofill': {
|
||||
color: '#32325d',
|
||||
},
|
||||
":-webkit-autofill": {
|
||||
color: "#32325d"
|
||||
}
|
||||
},
|
||||
invalid: {
|
||||
color: "#fa755a",
|
||||
iconColor: "#fa755a",
|
||||
":-webkit-autofill": {
|
||||
color: "#fa755a"
|
||||
}
|
||||
}
|
||||
color: '#fa755a',
|
||||
iconColor: '#fa755a',
|
||||
':-webkit-autofill': {
|
||||
color: '#fa755a',
|
||||
},
|
||||
},
|
||||
};
|
||||
var options = {
|
||||
style: style,
|
||||
supportedCountries: ["SEPA"],
|
||||
supportedCountries: ['SEPA'],
|
||||
// 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
|
||||
// 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.mount("#sepa-iban");
|
||||
this.iban = elements.create('iban', options);
|
||||
this.iban.mount('#sepa-iban');
|
||||
return this;
|
||||
};
|
||||
|
||||
handle = () => {
|
||||
let errors = document.getElementById('errors');
|
||||
|
||||
Array
|
||||
.from(document.getElementsByClassName('toggle-payment-with-token'))
|
||||
.forEach((element) => element.addEventListener('click', (element) => {
|
||||
document.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;
|
||||
}));
|
||||
Array.from(
|
||||
document.getElementsByClassName('toggle-payment-with-token')
|
||||
).forEach((element) =>
|
||||
element.addEventListener('click', (element) => {
|
||||
document
|
||||
.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
|
||||
.getElementById('toggle-payment-with-new-bank-account')
|
||||
.addEventListener('click', (element) => {
|
||||
document.getElementById('stripe--payment-container').classList.remove('hidden');
|
||||
document.getElementById('save-card--container').style.display = 'grid';
|
||||
document.querySelector('input[name=token]').value = "";
|
||||
document
|
||||
.getElementById('stripe--payment-container')
|
||||
.classList.remove('hidden');
|
||||
document.getElementById('save-card--container').style.display =
|
||||
'grid';
|
||||
document.querySelector('input[name=token]').value = '';
|
||||
});
|
||||
|
||||
|
||||
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.getElementById('pay-now').disabled = true;
|
||||
document.querySelector('#pay-now > svg').classList.remove('hidden');
|
||||
document.querySelector('#pay-now > span').classList.add('hidden');
|
||||
document
|
||||
.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, {
|
||||
payment_method: document.querySelector('input[name=token]').value
|
||||
})
|
||||
this.stripe
|
||||
.confirmSepaDebitSetup(
|
||||
document.querySelector('meta[name=si-client-secret')
|
||||
.content,
|
||||
{
|
||||
payment_method: document.querySelector(
|
||||
'input[name=token]'
|
||||
).value,
|
||||
}
|
||||
)
|
||||
.then((result) => {
|
||||
if (result.error) {
|
||||
console.error(error);
|
||||
@ -98,8 +119,11 @@ class ProcessSEPA {
|
||||
'input[name="gateway_response"]'
|
||||
).value = JSON.stringify(result.setupIntent);
|
||||
|
||||
return document.querySelector('#server-response').submit();
|
||||
}).catch((error) => {
|
||||
return document
|
||||
.querySelector('#server-response')
|
||||
.submit();
|
||||
})
|
||||
.catch((error) => {
|
||||
errors.textContent = error;
|
||||
errors.hidden = false;
|
||||
});
|
||||
@ -107,25 +131,30 @@ class ProcessSEPA {
|
||||
return;
|
||||
}
|
||||
|
||||
if (document.getElementById('sepa-name').value === "") {
|
||||
if (document.getElementById('sepa-name').value === '') {
|
||||
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;
|
||||
return;
|
||||
}
|
||||
|
||||
if (document.getElementById('sepa-email-address').value === "") {
|
||||
if (document.getElementById('sepa-email-address').value === '') {
|
||||
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;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
console.log("Terms");
|
||||
console.log('Terms');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -133,24 +162,30 @@ class ProcessSEPA {
|
||||
document.querySelector('#pay-now > svg').classList.remove('hidden');
|
||||
document.querySelector('#pay-now > span').classList.add('hidden');
|
||||
|
||||
this.stripe.confirmSepaDebitPayment(
|
||||
document.querySelector('meta[name=pi-client-secret').content,
|
||||
{
|
||||
payment_method: {
|
||||
sepa_debit: this.iban,
|
||||
billing_details: {
|
||||
name: document.getElementById("sepa-name").value,
|
||||
email: document.getElementById("sepa-email-address").value,
|
||||
this.stripe
|
||||
.confirmSepaDebitPayment(
|
||||
document.querySelector('meta[name=pi-client-secret')
|
||||
.content,
|
||||
{
|
||||
payment_method: {
|
||||
sepa_debit: this.iban,
|
||||
billing_details: {
|
||||
name: document.getElementById('sepa-name')
|
||||
.value,
|
||||
email: document.getElementById(
|
||||
'sepa-email-address'
|
||||
).value,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
).then((result) => {
|
||||
if (result.error) {
|
||||
return this.handleFailure(result.error.message);
|
||||
}
|
||||
}
|
||||
)
|
||||
.then((result) => {
|
||||
if (result.error) {
|
||||
return this.handleFailure(result.error.message);
|
||||
}
|
||||
|
||||
return this.handleSuccess(result);
|
||||
});
|
||||
return this.handleSuccess(result);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@ -178,15 +213,15 @@ class ProcessSEPA {
|
||||
errors.textContent = message;
|
||||
errors.hidden = false;
|
||||
|
||||
document.getElementById('pay-now').disabled = false;
|
||||
document.querySelector('#pay-now > svg').classList.add('hidden');
|
||||
document.querySelector('#pay-now > span').classList.remove('hidden');
|
||||
document.getElementById('pay-now').disabled = false;
|
||||
document.querySelector('#pay-now > svg').classList.add('hidden');
|
||||
document.querySelector('#pay-now > span').classList.remove('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
const publishableKey = document.querySelector(
|
||||
'meta[name="stripe-publishable-key"]'
|
||||
)?.content ?? '';
|
||||
const publishableKey =
|
||||
document.querySelector('meta[name="stripe-publishable-key"]')?.content ??
|
||||
'';
|
||||
|
||||
const stripeConnect =
|
||||
document.querySelector('meta[name="stripe-account-id"]')?.content ?? '';
|
||||
|
Loading…
x
Reference in New Issue
Block a user