mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 05:04:30 -04:00
Update Stripe's amount with fee:
- Update Sofort to support latest architecture for payments
This commit is contained in:
parent
4b55a69cd2
commit
7764833037
@ -22,6 +22,8 @@ use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
use Exception;
|
||||
use Stripe\Customer;
|
||||
use Stripe\Exception\CardException;
|
||||
use Stripe\Exception\InvalidRequestException;
|
||||
|
||||
@ -68,10 +70,10 @@ class ACH
|
||||
{
|
||||
$this->stripe->init();
|
||||
|
||||
$bank_account = \Stripe\Customer::retrieveSource($request->customer, $request->source);
|
||||
$bank_account = Customer::retrieveSource($request->customer, $request->source);
|
||||
|
||||
try {
|
||||
$status = $bank_account->verify(['amounts' => request()->transactions]);
|
||||
$bank_account->verify(['amounts' => request()->transactions]);
|
||||
|
||||
$token->meta->verified_at = now();
|
||||
$token->save();
|
||||
@ -90,7 +92,7 @@ class ACH
|
||||
$data['currency'] = $this->stripe->client->getCurrencyCode();
|
||||
$data['payment_method_id'] = GatewayType::BANK_TRANSFER;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer();
|
||||
$data['amount'] = $this->stripe->convertToStripeAmount($data['amount_with_fee'], $this->stripe->client->currency()->precision);
|
||||
$data['amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision);
|
||||
|
||||
return render('gateways.stripe.ach.pay', $data);
|
||||
}
|
||||
@ -205,7 +207,7 @@ class ACH
|
||||
];
|
||||
|
||||
return $this->stripe->storeGatewayToken($data, ['gateway_customer_reference' => $customer->id]);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
return $this->stripe->processInternallyFailedPayment($this->stripe, $e);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
||||
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\PaymentDrivers\StripePaymentDriver;
|
||||
@ -36,7 +37,7 @@ class Alipay
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['return_url'] = $this->buildReturnUrl();
|
||||
$data['currency'] = $this->stripe->client->getCurrencyCode();
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['amount_with_fee'], $this->stripe->client->currency()->precision);
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision);
|
||||
$data['invoices'] = $this->stripe->payment_hash->invoices();
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
@ -77,7 +78,7 @@ class Alipay
|
||||
'transaction_reference' => $source,
|
||||
];
|
||||
|
||||
$payment = $this->stripe->createPayment($data, \App\Models\Payment::STATUS_PENDING);
|
||||
$payment = $this->stripe->createPayment($data, Payment::STATUS_PENDING);
|
||||
|
||||
SystemLogger::dispatch(
|
||||
['response' => $this->stripe->payment_hash->data, 'data' => $data],
|
||||
|
@ -22,6 +22,8 @@ use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
use Stripe\PaymentIntent;
|
||||
use Stripe\PaymentMethod;
|
||||
|
||||
class CreditCard
|
||||
{
|
||||
@ -59,7 +61,7 @@ class CreditCard
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$payment_intent_data = [
|
||||
'amount' => $this->stripe->convertToStripeAmount($data['amount_with_fee'], $this->stripe->client->currency()->precision),
|
||||
'amount' => $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision),
|
||||
'currency' => $this->stripe->client->getCurrencyCode(),
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => collect($data['invoices'])->pluck('id'), // TODO: More meaningful description.
|
||||
@ -91,7 +93,7 @@ class CreditCard
|
||||
$state = array_merge($state, $request->all());
|
||||
$state['store_card'] = boolval($state['store_card']);
|
||||
|
||||
$state['payment_intent'] = \Stripe\PaymentIntent::retrieve($state['server_response']->id);
|
||||
$state['payment_intent'] = PaymentIntent::retrieve($state['server_response']->id);
|
||||
$state['customer'] = $state['payment_intent']->customer;
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, $state);
|
||||
@ -134,7 +136,7 @@ class CreditCard
|
||||
$this->storePaymentMethod($stripe_method, $this->stripe->payment_hash->data->payment_method_id, $customer);
|
||||
}
|
||||
|
||||
$payment = $this->stripe->createPayment($data, \App\Models\Payment::STATUS_COMPLETED);
|
||||
$payment = $this->stripe->createPayment($data, Payment::STATUS_COMPLETED);
|
||||
|
||||
SystemLogger::dispatch(
|
||||
['response' => $this->stripe->payment_hash->data->server_response, 'data' => $data],
|
||||
@ -174,7 +176,7 @@ class CreditCard
|
||||
throw new PaymentFailed('Failed to process the payment.', 500);
|
||||
}
|
||||
|
||||
private function storePaymentMethod(\Stripe\PaymentMethod $method, $payment_method_id, $customer)
|
||||
private function storePaymentMethod(PaymentMethod $method, $payment_method_id, $customer)
|
||||
{
|
||||
try {
|
||||
$payment_meta = new \stdClass;
|
||||
@ -195,26 +197,4 @@ class CreditCard
|
||||
return $this->stripe->processInternallyFailedPayment($this->stripe, $e);
|
||||
}
|
||||
}
|
||||
|
||||
private function saveCard($state)
|
||||
{
|
||||
$state['payment_method']->attach(['customer' => $state['customer']]);
|
||||
|
||||
$company_gateway_token = new ClientGatewayToken();
|
||||
$company_gateway_token->company_id = $this->stripe->client->company->id;
|
||||
$company_gateway_token->client_id = $this->stripe->client->id;
|
||||
$company_gateway_token->token = $state['payment_method']->id;
|
||||
$company_gateway_token->company_gateway_id = $this->stripe->company_gateway->id;
|
||||
$company_gateway_token->gateway_type_id = $state['gateway_type_id'];
|
||||
$company_gateway_token->gateway_customer_reference = $state['customer'];
|
||||
$company_gateway_token->meta = $state['payment_meta'];
|
||||
$company_gateway_token->save();
|
||||
|
||||
if ($this->stripe->client->gateway_tokens->count() == 1) {
|
||||
$this->stripe->client->gateway_tokens()->update(['is_default' => 0]);
|
||||
|
||||
$company_gateway_token->is_default = 1;
|
||||
$company_gateway_token->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,14 +12,14 @@
|
||||
|
||||
namespace App\PaymentDrivers\Stripe;
|
||||
|
||||
use App\Events\Payment\PaymentWasCreated;
|
||||
use App\Exceptions\PaymentFailed;
|
||||
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\PaymentDrivers\StripePaymentDriver;
|
||||
use App\Utils\Ninja;
|
||||
|
||||
class SOFORT
|
||||
{
|
||||
@ -34,74 +34,90 @@ class SOFORT
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['return_url'] = $this->buildReturnUrl($data);
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['amount_with_fee'], $this->stripe->client->currency()->precision);
|
||||
$data['return_url'] = $this->buildReturnUrl();
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision);
|
||||
$data['client'] = $this->stripe->client;
|
||||
$data['country'] = $this->stripe->client->country->iso_3166_2;
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
return render('gateways.stripe.sofort.pay', $data);
|
||||
}
|
||||
|
||||
private function buildReturnUrl($data): string
|
||||
private function buildReturnUrl(): string
|
||||
{
|
||||
return route('client.payments.response', [
|
||||
'company_gateway_id' => $this->stripe->company_gateway->id,
|
||||
'gateway_type_id' => GatewayType::SOFORT,
|
||||
'hashed_ids' => implode(',', $data['hashed_ids']),
|
||||
'amount' => $data['amount'],
|
||||
'fee' => $data['fee'],
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'payment_method_id' => GatewayType::SOFORT,
|
||||
]);
|
||||
}
|
||||
|
||||
public function paymentResponse($request)
|
||||
{
|
||||
$state = array_merge($request->all(), []);
|
||||
$amount = $state['amount'] + $state['fee'];
|
||||
$state['amount'] = $this->stripe->convertToStripeAmount($amount, $this->stripe->client->currency()->precision);
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, $request->all());
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
if ($request->redirect_status == 'succeeded') {
|
||||
return $this->processSuccessfulPayment($state);
|
||||
return $this->processSuccessfulPayment($request->source);
|
||||
}
|
||||
|
||||
return $this->processUnsuccessfulPayment($state);
|
||||
return $this->processUnsuccessfulPayment();
|
||||
}
|
||||
|
||||
public function processSuccessfulPayment($state)
|
||||
public function processSuccessfulPayment(string $source)
|
||||
{
|
||||
$state['charge_id'] = $state['source'];
|
||||
/* @todo: https://github.com/invoiceninja/invoiceninja/pull/3789/files#r436175798 */
|
||||
|
||||
$this->stripe->init();
|
||||
|
||||
$state['payment_type'] = PaymentType::SOFORT;
|
||||
|
||||
$data = [
|
||||
'payment_method' => $state['charge_id'],
|
||||
'payment_type' => $state['payment_type'],
|
||||
'amount' => $state['amount'],
|
||||
'gateway_type_id' => GatewayType::SOFORT,
|
||||
'payment_method' => $this->stripe->payment_hash->data->source,
|
||||
'payment_type' => PaymentType::SOFORT,
|
||||
'amount' => $this->stripe->convertFromStripeAmount($this->stripe->payment_hash->data->stripe_amount, $this->stripe->client->currency()->precision),
|
||||
'transaction_reference' => $source,
|
||||
];
|
||||
|
||||
$payment = $this->stripe->createPayment($data, Payment::STATUS_PENDING);
|
||||
|
||||
/* @todo: https://github.com/invoiceninja/invoiceninja/pull/3789/files#r436175798 */
|
||||
if (isset($state['hashed_ids'])) {
|
||||
$this->stripe->attachInvoices($payment, $state['hashed_ids']);
|
||||
}
|
||||
|
||||
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars()));
|
||||
|
||||
$logger_message = [
|
||||
'server_response' => $state,
|
||||
'data' => $data,
|
||||
];
|
||||
|
||||
SystemLogger::dispatch($logger_message, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::TYPE_STRIPE, $this->stripe->client);
|
||||
SystemLogger::dispatch(
|
||||
['response' => $this->stripe->payment_hash->data, 'data' => $data],
|
||||
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
||||
SystemLog::EVENT_GATEWAY_SUCCESS,
|
||||
SystemLog::TYPE_STRIPE,
|
||||
$this->stripe->client
|
||||
);
|
||||
|
||||
return redirect()->route('client.payments.show', ['payment' => $this->stripe->encodePrimaryKey($payment->id)]);
|
||||
}
|
||||
|
||||
public function processUnsuccessfulPayment($state)
|
||||
public function processUnsuccessfulPayment()
|
||||
{
|
||||
return redirect()->route('client.invoices.index')->with('warning', ctrans('texts.status_cancelled'));
|
||||
$server_response = $this->stripe->payment_hash->data;
|
||||
|
||||
PaymentFailureMailer::dispatch($this->stripe->client, $server_response->redirect_status, $this->stripe->client->company, $server_response->amount);
|
||||
|
||||
PaymentFailureMailer::dispatch(
|
||||
$this->stripe->client,
|
||||
$server_response,
|
||||
$this->stripe->client->company,
|
||||
$this->stripe->convertFromStripeAmount($this->stripe->payment_hash->data->stripe_amount, $this->stripe->client->currency()->precision)
|
||||
);
|
||||
|
||||
$message = [
|
||||
'server_response' => $server_response,
|
||||
'data' => $this->stripe->payment_hash->data,
|
||||
];
|
||||
|
||||
SystemLogger::dispatch(
|
||||
$message,
|
||||
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
||||
SystemLog::EVENT_GATEWAY_FAILURE,
|
||||
SystemLog::TYPE_STRIPE,
|
||||
$this->stripe->client
|
||||
);
|
||||
|
||||
throw new PaymentFailed('Failed to process the payment.', 500);
|
||||
}
|
||||
}
|
||||
|
@ -21,17 +21,19 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentHash;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Stripe\ACH;
|
||||
use App\PaymentDrivers\Stripe\Alipay;
|
||||
use App\PaymentDrivers\Stripe\Charge;
|
||||
use App\PaymentDrivers\Stripe\CreditCard;
|
||||
use App\PaymentDrivers\Stripe\SOFORT;
|
||||
use App\PaymentDrivers\Stripe\Utilities;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Exception;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\View\View;
|
||||
use Stripe\Customer;
|
||||
use Stripe\Exception\ApiErrorException;
|
||||
use Stripe\PaymentIntent;
|
||||
use Stripe\PaymentMethod;
|
||||
use Stripe\SetupIntent;
|
||||
use Stripe\Stripe;
|
||||
use Stripe\StripeClient;
|
||||
@ -55,7 +57,7 @@ class StripePaymentDriver extends BaseDriver
|
||||
|
||||
public static $methods = [
|
||||
GatewayType::CREDIT_CARD => CreditCard::class,
|
||||
GatewayType::BANK_TRANSFER => ACH::class,
|
||||
GatewayType::BANK_TRANSFER => SOFORT::class,
|
||||
GatewayType::ALIPAY => Alipay::class,
|
||||
GatewayType::SOFORT => SOFORT::class,
|
||||
GatewayType::APPLE_PAY => 1, // TODO
|
||||
@ -152,8 +154,7 @@ class StripePaymentDriver extends BaseDriver
|
||||
* Proxy method to pass the data into payment method authorizeView().
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return Factory|View
|
||||
* @return \Illuminate\Http\RedirectResponse|mixed
|
||||
*/
|
||||
public function authorizeView(array $data)
|
||||
{
|
||||
@ -169,8 +170,8 @@ class StripePaymentDriver extends BaseDriver
|
||||
/**
|
||||
* Processes the gateway response for credit card authorization.
|
||||
*
|
||||
* @param Request $request The returning request object
|
||||
* @return Factory|View
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\RedirectResponse|mixed
|
||||
*/
|
||||
public function authorizeResponse($request)
|
||||
{
|
||||
@ -187,7 +188,7 @@ class StripePaymentDriver extends BaseDriver
|
||||
* Process the payment with gateway.
|
||||
*
|
||||
* @param array $data
|
||||
* @return Factory|View|void
|
||||
* @return \Illuminate\Http\RedirectResponse|mixed
|
||||
*/
|
||||
public function processPaymentView(array $data)
|
||||
{
|
||||
@ -216,7 +217,7 @@ class StripePaymentDriver extends BaseDriver
|
||||
*
|
||||
* @param array $data The data array to be passed to Stripe
|
||||
* @return PaymentIntent The Stripe payment intent object
|
||||
* @throws \Stripe\Exception\ApiErrorException
|
||||
* @throws ApiErrorException
|
||||
*/
|
||||
public function createPaymentIntent($data): ?PaymentIntent
|
||||
{
|
||||
@ -230,7 +231,7 @@ class StripePaymentDriver extends BaseDriver
|
||||
* to enter card details without initiating a transaction.
|
||||
*
|
||||
* @return SetupIntent
|
||||
* @throws \Stripe\Exception\ApiErrorException
|
||||
* @throws ApiErrorException
|
||||
*/
|
||||
public function getSetupIntent(): SetupIntent
|
||||
{
|
||||
@ -253,7 +254,7 @@ class StripePaymentDriver extends BaseDriver
|
||||
*
|
||||
* @return null|Customer A Stripe customer object
|
||||
* @throws \Laracasts\Presenter\Exceptions\PresenterException
|
||||
* @throws \Stripe\Exception\ApiErrorException
|
||||
* @throws ApiErrorException
|
||||
*/
|
||||
public function findOrCreateCustomer(): ?Customer
|
||||
{
|
||||
@ -277,7 +278,7 @@ class StripePaymentDriver extends BaseDriver
|
||||
}
|
||||
|
||||
if (!$customer) {
|
||||
throw new \Exception('Unable to create gateway customer');
|
||||
throw new Exception('Unable to create gateway customer');
|
||||
}
|
||||
|
||||
return $customer;
|
||||
@ -316,7 +317,7 @@ class StripePaymentDriver extends BaseDriver
|
||||
'description' => $response->failure_reason,
|
||||
'code' => 422,
|
||||
];
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
SystemLogger::dispatch(['server_response' => $response, 'data' => request()->all(),], SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->client);
|
||||
|
||||
info($e->getMessage());
|
||||
@ -394,7 +395,7 @@ class StripePaymentDriver extends BaseDriver
|
||||
try {
|
||||
$stripe_payment_method = $this->getStripePaymentMethod($payment_method);
|
||||
$stripe_payment_method->attach(['customer' => $customer->id]);
|
||||
} catch (\Stripe\Exception\ApiErrorException | \Exception $e) {
|
||||
} catch (ApiErrorException | Exception $e) {
|
||||
$this->processInternallyFailedPayment($this, $e);
|
||||
}
|
||||
}
|
||||
@ -413,7 +414,7 @@ class StripePaymentDriver extends BaseDriver
|
||||
);
|
||||
|
||||
try {
|
||||
$response = $stripe->paymentMethods->detach($token->token);
|
||||
$stripe->paymentMethods->detach($token->token);
|
||||
} catch (Exception $e) {
|
||||
SystemLogger::dispatch([
|
||||
'server_response' => $e->getMessage(), 'data' => request()->all(),
|
||||
@ -431,13 +432,13 @@ class StripePaymentDriver extends BaseDriver
|
||||
*
|
||||
* @param string $source
|
||||
*
|
||||
* @return \Stripe\PaymentMethod|void
|
||||
* @return PaymentMethod|void
|
||||
*/
|
||||
public function getStripePaymentMethod(string $source)
|
||||
{
|
||||
try {
|
||||
return \Stripe\PaymentMethod::retrieve($source);
|
||||
} catch (\Stripe\Exception\ApiErrorException | \Exception $e) {
|
||||
return PaymentMethod::retrieve($source);
|
||||
} catch (ApiErrorException | Exception $e) {
|
||||
return $this->processInternallyFailedPayment($this, $e);
|
||||
}
|
||||
}
|
||||
|
2
public/js/clients/payments/stripe-sofort.js
vendored
2
public/js/clients/payments/stripe-sofort.js
vendored
@ -1,2 +1,2 @@
|
||||
/*! For license information please see stripe-sofort.js.LICENSE.txt */
|
||||
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=6)}({6:function(e,t,n){e.exports=n("RFiP")},RFiP:function(e,t){function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}new function e(t){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),n(this,"setupStripe",(function(){return r.stripe=Stripe(r.key),r})),n(this,"handle",(function(){var e={type:"sofort",amount:document.querySelector('meta[name="amount"]').content,currency:"eur",redirect:{return_url:document.querySelector('meta[name="return-url"]').content},sofort:{country:document.querySelector('meta[name="country"').content}};document.getElementById("pay-now").addEventListener("click",(function(t){document.getElementById("pay-now-button").disabled=!0,document.querySelector("#pay-now-button > svg").classList.remove("hidden"),document.querySelector("#pay-now-button > span").classList.add("hidden"),r.stripe.createSource(e).then((function(e){if(e.hasOwnProperty("source"))return window.location=e.source.redirect.url;document.getElementById("pay-now-button").disabled=!1,document.querySelector("#pay-now-button > svg").classList.add("hidden"),document.querySelector("#pay-now-button > span").classList.remove("hidden"),this.errors.textContent="",this.errors.textContent=e.error.message,this.errors.hidden=!1,document.getElementById("pay-now").disabled=!1}))}))})),this.key=t,this.errors=document.getElementById("errors")}(document.querySelector('meta[name="stripe-publishable-key"]').content).setupStripe().handle()}});
|
||||
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=6)}({6:function(e,t,n){e.exports=n("RFiP")},RFiP:function(e,t){function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}new function e(t){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),n(this,"setupStripe",(function(){return r.stripe=Stripe(r.key),r})),n(this,"handle",(function(){var e={type:"sofort",amount:document.querySelector('meta[name="amount"]').content,currency:"eur",redirect:{return_url:document.querySelector('meta[name="return-url"]').content},sofort:{country:document.querySelector('meta[name="country"').content}};document.getElementById("pay-now").addEventListener("click",(function(t){document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),r.stripe.createSource(e).then((function(e){if(e.hasOwnProperty("source"))return window.location=e.source.redirect.url;document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden"),this.errors.textContent="",this.errors.textContent=e.error.message,this.errors.hidden=!1,document.getElementById("pay-now").disabled=!1}))}))})),this.key=t,this.errors=document.getElementById("errors")}(document.querySelector('meta[name="stripe-publishable-key"]').content).setupStripe().handle()}});
|
@ -10,7 +10,7 @@
|
||||
"/js/clients/payments/stripe-ach.js": "/js/clients/payments/stripe-ach.js?id=c4012ad90f17d60432ad",
|
||||
"/js/clients/payments/stripe-alipay.js": "/js/clients/payments/stripe-alipay.js?id=6dbe9316b98deea55421",
|
||||
"/js/clients/payments/stripe-credit-card.js": "/js/clients/payments/stripe-credit-card.js?id=f4659d26a26d2f408397",
|
||||
"/js/clients/payments/stripe-sofort.js": "/js/clients/payments/stripe-sofort.js?id=7f5b13e34c75e63c015e",
|
||||
"/js/clients/payments/stripe-sofort.js": "/js/clients/payments/stripe-sofort.js?id=bb7c55ca3da2d29e55d2",
|
||||
"/js/clients/quotes/action-selectors.js": "/js/clients/quotes/action-selectors.js?id=1b8f9325aa6e8595e7fa",
|
||||
"/js/clients/quotes/approve.js": "/js/clients/quotes/approve.js?id=85bcae0a646882e56b12",
|
||||
"/js/clients/shared/multiple-downloads.js": "/js/clients/shared/multiple-downloads.js?id=5c35d28cf0a3286e7c45",
|
||||
|
14
resources/js/clients/payments/stripe-sofort.js
vendored
14
resources/js/clients/payments/stripe-sofort.js
vendored
@ -30,23 +30,23 @@ class ProcessSOFORT {
|
||||
.content,
|
||||
},
|
||||
sofort: {
|
||||
country: document.querySelector('meta[name="country"').content,
|
||||
country: document.querySelector('meta[name="country"]').content,
|
||||
},
|
||||
};
|
||||
|
||||
document.getElementById('pay-now').addEventListener('click', (e) => {
|
||||
document.getElementById('pay-now-button').disabled = true;
|
||||
document.querySelector('#pay-now-button > svg').classList.remove('hidden');
|
||||
document.querySelector('#pay-now-button > span').classList.add('hidden');
|
||||
document.getElementById('pay-now').disabled = true;
|
||||
document.querySelector('#pay-now > svg').classList.remove('hidden');
|
||||
document.querySelector('#pay-now > span').classList.add('hidden');
|
||||
|
||||
this.stripe.createSource(data).then(function(result) {
|
||||
if (result.hasOwnProperty('source')) {
|
||||
return (window.location = result.source.redirect.url);
|
||||
}
|
||||
|
||||
document.getElementById('pay-now-button').disabled = false;
|
||||
document.querySelector('#pay-now-button > svg').classList.add('hidden');
|
||||
document.querySelector('#pay-now-button > 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');
|
||||
|
||||
this.errors.textContent = '';
|
||||
this.errors.textContent = result.error.message;
|
||||
|
Loading…
x
Reference in New Issue
Block a user