mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Support updating card on file
This commit is contained in:
parent
1616746267
commit
b2f0012aae
@ -75,7 +75,7 @@ class OnlinePaymentController extends BaseController
|
||||
]);
|
||||
}
|
||||
|
||||
if (! $invitation->invoice->canBePaid()) {
|
||||
if (! $invitation->invoice->canBePaid() && ! request()->update) {
|
||||
return redirect()->to('view/' . $invitation->invitation_key);
|
||||
}
|
||||
|
||||
@ -120,14 +120,16 @@ class OnlinePaymentController extends BaseController
|
||||
$gatewayTypeId = Session::get($invitation->id . 'gateway_type');
|
||||
$paymentDriver = $invitation->account->paymentDriver($invitation, $gatewayTypeId);
|
||||
|
||||
if (! $invitation->invoice->canBePaid()) {
|
||||
if (! $invitation->invoice->canBePaid() && ! request()->update) {
|
||||
return redirect()->to('view/' . $invitation->invitation_key);
|
||||
}
|
||||
|
||||
try {
|
||||
$paymentDriver->completeOnsitePurchase($request->all());
|
||||
|
||||
if ($paymentDriver->isTwoStep()) {
|
||||
if (request()->update) {
|
||||
return redirect('/client/dashboard')->withMessage(trans('texts.updated_payment_details'));
|
||||
} elseif ($paymentDriver->isTwoStep()) {
|
||||
Session::flash('warning', trans('texts.bank_account_verification_next_steps'));
|
||||
} else {
|
||||
Session::flash('message', trans('texts.applied_payment'));
|
||||
|
@ -559,6 +559,15 @@ class Client extends EntityModel
|
||||
{
|
||||
return $this->payment_terms == -1 ? 0 : $this->payment_terms;
|
||||
}
|
||||
|
||||
public function firstInvitationKey()
|
||||
{
|
||||
if ($invoice = $this->invoices->first()) {
|
||||
if ($invitation = $invoice->invitations->first()) {
|
||||
return $invitation->invitation_key;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Client::creating(function ($client) {
|
||||
|
@ -157,6 +157,11 @@ class BasePaymentDriver
|
||||
return redirect()->to('view/' . $this->invitation->invitation_key);
|
||||
}
|
||||
|
||||
$url = 'payment/' . $this->invitation->invitation_key;
|
||||
if (request()->update) {
|
||||
$url .= '?update=true';
|
||||
}
|
||||
|
||||
$data = [
|
||||
'details' => ! empty($input['details']) ? json_decode($input['details']) : false,
|
||||
'accountGateway' => $this->accountGateway,
|
||||
@ -164,7 +169,7 @@ class BasePaymentDriver
|
||||
'gateway' => $gateway,
|
||||
'showAddress' => $this->accountGateway->show_address,
|
||||
'showBreadcrumbs' => false,
|
||||
'url' => 'payment/' . $this->invitation->invitation_key,
|
||||
'url' => $url,
|
||||
'amount' => $this->invoice()->getRequestedAmount(),
|
||||
'invoiceNumber' => $this->invoice()->invoice_number,
|
||||
'client' => $this->client(),
|
||||
@ -293,7 +298,7 @@ class BasePaymentDriver
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->isTwoStep()) {
|
||||
if ($this->isTwoStep() || request()->update) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2269,6 +2269,9 @@ $LANG = array(
|
||||
'select_label' => 'Select Label',
|
||||
'label' => 'Label',
|
||||
'service' => 'Service',
|
||||
'update_payment_details' => 'Update payment details',
|
||||
'updated_payment_details' => 'Successfully updated payment details',
|
||||
'update_credit_card' => 'Update Credit Card',
|
||||
|
||||
);
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
<center>
|
||||
@if(isset($amount))
|
||||
{!! Button::success(strtoupper(trans('texts.pay_now') . ' - ' . $account->formatMoney($amount, $client, CURRENCY_DECORATOR_CODE) ))
|
||||
{!! Button::success(request()->update ? strtoupper(trans('texts.submit')) : strtoupper(trans('texts.pay_now') . ' - ' . $account->formatMoney($amount, $client, CURRENCY_DECORATOR_CODE) ))
|
||||
->submit()
|
||||
->large() !!}
|
||||
@else
|
||||
|
@ -316,11 +316,12 @@
|
||||
<p> </p>
|
||||
<center>
|
||||
@if (isset($invitation))
|
||||
{!! Button::normal(strtoupper(trans('texts.cancel')))->large()->asLinkTo($invitation->getLink()) !!}
|
||||
{!! Button::normal(strtoupper(trans('texts.cancel')))->large()->asLinkTo(HTMLUtils::previousUrl('/credits')) !!}
|
||||
|
||||
@endif
|
||||
@if(isset($amount))
|
||||
{!! Button::success(strtoupper(trans('texts.pay_now') . ' - ' . $account->formatMoney($amount, $client, CURRENCY_DECORATOR_CODE) ))
|
||||
|
||||
@if (isset($amount))
|
||||
{!! Button::success(request()->update ? strtoupper(trans('texts.submit')) : strtoupper(trans('texts.pay_now') . ' - ' . $account->formatMoney($amount, $client, CURRENCY_DECORATOR_CODE) ))
|
||||
->submit()
|
||||
->large() !!}
|
||||
@else
|
||||
|
@ -15,7 +15,11 @@
|
||||
<header>
|
||||
@if ($client && isset($invoiceNumber))
|
||||
<h2>{{ $client->getDisplayName() }}</h2>
|
||||
<h3>{{ trans('texts.invoice') . ' ' . $invoiceNumber }}<span>| {{ trans('texts.amount_due') }}: <em>{{ $account->formatMoney($amount, $client, CURRENCY_DECORATOR_CODE) }}</em></span></h3>
|
||||
@if (request()->update)
|
||||
<h3>{{ trans('texts.update_payment_details') }}</h3>
|
||||
@else
|
||||
<h3>{{ trans('texts.invoice') . ' ' . $invoiceNumber }}<span>| {{ trans('texts.amount_due') }}: <em>{{ $account->formatMoney($amount, $client, CURRENCY_DECORATOR_CODE) }}</em></span></h3>
|
||||
@endif
|
||||
@elseif ($paymentTitle)
|
||||
<h2>{{ $paymentTitle }}
|
||||
@if(isset($paymentSubtitle))
|
||||
|
@ -77,54 +77,63 @@
|
||||
</script>
|
||||
@endif
|
||||
|
||||
@if(!empty($paymentMethods) && count($paymentMethods))
|
||||
<h3>{{ trans('texts.payment_methods') }}</h3>
|
||||
|
||||
@foreach ($paymentMethods as $paymentMethod)
|
||||
<div class="payment_method">
|
||||
<span class="payment_method_img_container">
|
||||
<img height="22" src="{{ $paymentMethod->imageUrl() }}"
|
||||
alt="{{ trans("texts.card_" . str_replace(' ', '', strtolower($paymentMethod->payment_type->name))) }}">
|
||||
</span>
|
||||
|
||||
@if($paymentMethod->payment_type_id == PAYMENT_TYPE_ACH)
|
||||
@if($paymentMethod->bank_name)
|
||||
{{ $paymentMethod->bank_name }}
|
||||
@else
|
||||
{{ trans('texts.bank_account') }}
|
||||
@endif
|
||||
@elseif($paymentMethod->payment_type_id == PAYMENT_TYPE_PAYPAL)
|
||||
{{ trans('texts.paypal') . ': ' . $paymentMethod->email }}
|
||||
@else
|
||||
{{ trans('texts.credit_card') }}
|
||||
@if ($invitationKey = $client->firstInvitationKey())
|
||||
<h3>
|
||||
{{ trans('texts.payment_methods') }}
|
||||
@if ($account->getGatewayByType(GATEWAY_TYPE_CREDIT_CARD)
|
||||
&& $account->getGatewayByType(GATEWAY_TYPE_TOKEN)
|
||||
&& $account->token_billing_type_id != TOKEN_BILLING_DISABLED)
|
||||
|
||||
{!! Button::success(strtoupper(trans('texts.update_credit_card')))->asLinkTo(URL::to("/payment/$invitationKey/credit_card?update=true")) !!}
|
||||
@endif
|
||||
</h3>
|
||||
|
||||
- {{ trans('texts.added_on', ['date' => Utils::dateToString($paymentMethod->created_at)]) }}
|
||||
@if(!empty($paymentMethods) && count($paymentMethods))
|
||||
@foreach ($paymentMethods as $paymentMethod)
|
||||
<div class="payment_method">
|
||||
<span class="payment_method_img_container">
|
||||
<img height="22" src="{{ $paymentMethod->imageUrl() }}"
|
||||
alt="{{ trans("texts.card_" . str_replace(' ', '', strtolower($paymentMethod->payment_type->name))) }}">
|
||||
</span>
|
||||
|
||||
@if($paymentMethod->payment_type_id == PAYMENT_TYPE_ACH)
|
||||
@if($paymentMethod->status == PAYMENT_METHOD_STATUS_NEW)
|
||||
@if($gateway->gateway_id == GATEWAY_STRIPE)
|
||||
<a href="#" onclick="completeVerification('{{$paymentMethod->public_id}}','{{$paymentMethod->currency->symbol}}')">({{trans('texts.complete_verification')}})</a>
|
||||
@if($paymentMethod->payment_type_id == PAYMENT_TYPE_ACH)
|
||||
@if($paymentMethod->bank_name)
|
||||
{{ $paymentMethod->bank_name }}
|
||||
@else
|
||||
[{{ trans('texts.verification_pending') }}]
|
||||
{{ trans('texts.bank_account') }}
|
||||
@endif
|
||||
@elseif($paymentMethod->status == PAYMENT_METHOD_STATUS_VERIFICATION_FAILED)
|
||||
[{{trans('texts.verification_failed')}}]
|
||||
@elseif($paymentMethod->payment_type_id == PAYMENT_TYPE_PAYPAL)
|
||||
{{ trans('texts.paypal') . ': ' . $paymentMethod->email }}
|
||||
@else
|
||||
{{ trans('texts.credit_card') }}
|
||||
@endif
|
||||
@endif
|
||||
|
|
||||
@if($paymentMethod->id == $paymentMethod->account_gateway_token->default_payment_method_id)
|
||||
{{trans('texts.used_for_auto_bill')}}
|
||||
@elseif($paymentMethod->payment_type_id != PAYMENT_TYPE_ACH || $paymentMethod->status == PAYMENT_METHOD_STATUS_VERIFIED)
|
||||
<a href="#" onclick="setDefault('{{$paymentMethod->public_id}}')">{{trans('texts.use_for_auto_bill')}}</a>
|
||||
@endif
|
||||
| <a href="#" title="{{ trans('texts.remove') }}" class="payment_method_remove" onclick="removePaymentMethod('{{$paymentMethod->public_id}}')">{{ trans('texts.remove') }}</a>
|
||||
|
||||
</div>
|
||||
@endforeach
|
||||
- {{ trans('texts.added_on', ['date' => Utils::dateToString($paymentMethod->created_at)]) }}
|
||||
|
||||
@if($paymentMethod->payment_type_id == PAYMENT_TYPE_ACH)
|
||||
@if($paymentMethod->status == PAYMENT_METHOD_STATUS_NEW)
|
||||
@if($gateway->gateway_id == GATEWAY_STRIPE)
|
||||
<a href="#" onclick="completeVerification('{{$paymentMethod->public_id}}','{{$paymentMethod->currency->symbol}}')">({{trans('texts.complete_verification')}})</a>
|
||||
@else
|
||||
[{{ trans('texts.verification_pending') }}]
|
||||
@endif
|
||||
@elseif($paymentMethod->status == PAYMENT_METHOD_STATUS_VERIFICATION_FAILED)
|
||||
[{{trans('texts.verification_failed')}}]
|
||||
@endif
|
||||
@endif
|
||||
|
|
||||
@if($paymentMethod->id == $paymentMethod->account_gateway_token->default_payment_method_id)
|
||||
{{trans('texts.used_for_auto_bill')}}
|
||||
@elseif($paymentMethod->payment_type_id != PAYMENT_TYPE_ACH || $paymentMethod->status == PAYMENT_METHOD_STATUS_VERIFIED)
|
||||
<a href="#" onclick="setDefault('{{$paymentMethod->public_id}}')">{{trans('texts.use_for_auto_bill')}}</a>
|
||||
@endif
|
||||
| <a href="#" title="{{ trans('texts.remove') }}" class="payment_method_remove" onclick="removePaymentMethod('{{$paymentMethod->public_id}}')">{{ trans('texts.remove') }}</a>
|
||||
|
||||
</div>
|
||||
@endforeach
|
||||
@endif
|
||||
@endif
|
||||
|
||||
|
||||
<center>
|
||||
@if (false && $account->getGatewayByType(GATEWAY_TYPE_CREDIT_CARD) && $account->getGatewayByType(GATEWAY_TYPE_TOKEN))
|
||||
{!! Button::success(strtoupper(trans('texts.add_credit_card')))
|
||||
|
@ -240,7 +240,7 @@
|
||||
->large() !!}
|
||||
|
||||
@if ($accountGateway->getPlaidEnabled() && !empty($amount))
|
||||
{!! Button::success(strtoupper(trans('texts.pay_now') . ' - ' . $account->formatMoney($amount, $client, CURRENCY_DECORATOR_CODE) ))
|
||||
{!! Button::success(request()->update ? strtoupper(trans('texts.submit')) : strtoupper(trans('texts.pay_now') . ' - ' . $account->formatMoney($amount, $client, CURRENCY_DECORATOR_CODE) ))
|
||||
->submit()
|
||||
->withAttributes(['style'=>'display:none', 'id'=>'pay_now_button'])
|
||||
->large() !!}
|
||||
|
@ -33,7 +33,7 @@
|
||||
{!! Button::normal(strtoupper(trans('texts.cancel')))->large()->asLinkTo($invitation->getLink()) !!}
|
||||
|
||||
@if(isset($amount) && empty($paymentMethodPending))
|
||||
{!! Button::success(strtoupper(trans('texts.pay_now') . ' - ' . $account->formatMoney($amount, $client, CURRENCY_DECORATOR_CODE) ))
|
||||
{!! Button::success(request()->update ? strtoupper(trans('texts.submit')) : strtoupper(trans('texts.pay_now') . ' - ' . $account->formatMoney($amount, $client, CURRENCY_DECORATOR_CODE) ))
|
||||
->submit()
|
||||
->large() !!}
|
||||
@else
|
||||
|
Loading…
x
Reference in New Issue
Block a user