mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 09:54:34 -04:00
Add payment method button added on Cconfirm payment page.
This commit is contained in:
parent
7be910ea69
commit
c9f900a673
@ -14,6 +14,7 @@ namespace App\PaymentDrivers\Forte;
|
||||
|
||||
use App\Models\Payment;
|
||||
use App\Models\GatewayType;
|
||||
use App\Models\PaymentHash;
|
||||
use App\Models\PaymentType;
|
||||
use App\Http\Requests\Request;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
@ -160,7 +161,7 @@ class ACH
|
||||
|
||||
$this->forte->storeGatewayToken($data, ['gateway_customer_reference' => $customer_token]);
|
||||
|
||||
return redirect()->route('client.payment_methods.index');
|
||||
return redirect()->route('client.payment_methods.index')->withSuccess('Payment Method added.');
|
||||
}
|
||||
|
||||
public function paymentView(array $data)
|
||||
@ -169,17 +170,12 @@ class ACH
|
||||
$this->forte->payment_hash->save();
|
||||
|
||||
$data['gateway'] = $this;
|
||||
$data['system_amount_with_fee'] = $data['amount_with_fee'];
|
||||
$data['fee_percent'] = $this->forte->company_gateway->fees_and_limits->{GatewayType::BANK_TRANSFER}->fee_percent;
|
||||
$data['total']['fee_total'] = $data['total']['invoice_totals'] * $data['fee_percent'] / 100;
|
||||
$data['total']['amount_with_fee'] = $data['total']['fee_total'] + $data['total']['invoice_totals'];
|
||||
$data['amount_with_fee'] = $data['total']['amount_with_fee'];
|
||||
return render('gateways.forte.ach.pay', $data);
|
||||
}
|
||||
|
||||
public function paymentResponse($request)
|
||||
{
|
||||
$data=$request;
|
||||
$payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$request->input('payment_hash')])->firstOrFail();
|
||||
|
||||
try {
|
||||
$curl = curl_init();
|
||||
@ -194,8 +190,8 @@ class ACH
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS =>'{
|
||||
"action":"sale",
|
||||
"authorization_amount": '.$data->amount_with_fee.',
|
||||
"paymethod_token": "'.$data->payment_token.'",
|
||||
"authorization_amount": '.$payment_hash->data->total->amount_with_fee.',
|
||||
"paymethod_token": "'.$request->payment_token.'",
|
||||
"echeck":{
|
||||
"sec_code":"PPD",
|
||||
},
|
||||
@ -228,10 +224,13 @@ class ACH
|
||||
return redirect('client/invoices')->withErrors($error);
|
||||
}
|
||||
|
||||
$data['gateway_type_id']=GatewayType::CREDIT_CARD;
|
||||
$data['amount']=$request->system_amount_with_fee;
|
||||
$data['payment_type']=PaymentType::ACH;
|
||||
$data['transaction_reference']=$response->transaction_id;
|
||||
$data = [
|
||||
'payment_method' => $request->payment_method_id,
|
||||
'payment_type' => PaymentType::parseCardType(strtolower($request->card_brand)) ?: PaymentType::CREDIT_CARD_OTHER,
|
||||
'amount' => $payment_hash->data->amount_with_fee,
|
||||
'transaction_reference' => $response->transaction_id,
|
||||
'gateway_type_id' => GatewayType::CREDIT_CARD,
|
||||
];
|
||||
|
||||
$payment=$this->forte->createPayment($data, Payment::STATUS_COMPLETED);
|
||||
return redirect('client/invoices')->withSuccess('Invoice paid.');
|
||||
|
@ -14,6 +14,7 @@ namespace App\PaymentDrivers\Forte;
|
||||
|
||||
use App\Models\Payment;
|
||||
use App\Models\GatewayType;
|
||||
use App\Models\PaymentHash;
|
||||
use App\Models\PaymentType;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
@ -165,7 +166,7 @@ class CreditCard
|
||||
|
||||
$this->forte->storeGatewayToken($data, ['gateway_customer_reference' => $customer_token]);
|
||||
|
||||
return redirect()->route('client.payment_methods.index');
|
||||
return redirect()->route('client.payment_methods.index')->withSuccess('Payment Method added.');
|
||||
}
|
||||
|
||||
public function paymentView(array $data)
|
||||
@ -174,17 +175,12 @@ class CreditCard
|
||||
$this->forte->payment_hash->save();
|
||||
|
||||
$data['gateway'] = $this;
|
||||
$data['system_amount_with_fee'] = $data['amount_with_fee'];
|
||||
$data['fee_percent'] = $this->forte->company_gateway->fees_and_limits->{GatewayType::CREDIT_CARD}->fee_percent;
|
||||
$data['total']['fee_total'] = $data['total']['invoice_totals'] * $data['fee_percent'] / 100;
|
||||
$data['total']['amount_with_fee'] = $data['total']['fee_total'] + $data['total']['invoice_totals'];
|
||||
$data['amount_with_fee'] = $data['total']['amount_with_fee'];
|
||||
return render('gateways.forte.credit_card.pay', $data);
|
||||
}
|
||||
|
||||
public function paymentResponse(PaymentResponseRequest $request)
|
||||
{
|
||||
$data=$request;
|
||||
$payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$request->input('payment_hash')])->firstOrFail();
|
||||
|
||||
try {
|
||||
$curl = curl_init();
|
||||
@ -199,9 +195,9 @@ class CreditCard
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS =>'{
|
||||
"action":"sale",
|
||||
"authorization_amount": '.$data->amount_with_fee.',
|
||||
"service_fee_amount": '.$data->fee_total.',
|
||||
"paymethod_token": "'.$data->payment_token.'",
|
||||
"authorization_amount": '.$payment_hash->data->total->amount_with_fee.',
|
||||
"service_fee_amount": '.$payment_hash->data->total->fee_total.',
|
||||
"paymethod_token": "'.$request->payment_token.'",
|
||||
"billing_address":{
|
||||
"first_name": "'.auth()->user()->client->name.'",
|
||||
"last_name": "'.auth()->user()->client->name.'"
|
||||
@ -230,11 +226,13 @@ class CreditCard
|
||||
return redirect('client/invoices')->withErrors($error);
|
||||
}
|
||||
|
||||
$data['gateway_type_id']=GatewayType::CREDIT_CARD;
|
||||
$data['amount']=$request->system_amount_with_fee;
|
||||
$data['payment_type']=PaymentType::parseCardType(strtolower($request->card_brand)) ?: PaymentType::CREDIT_CARD_OTHER;
|
||||
$data['transaction_reference']=$response->transaction_id;
|
||||
|
||||
$data = [
|
||||
'payment_method' => $request->payment_method_id,
|
||||
'payment_type' => PaymentType::parseCardType(strtolower($request->card_brand)) ?: PaymentType::CREDIT_CARD_OTHER,
|
||||
'amount' => $payment_hash->data->amount_with_fee,
|
||||
'transaction_reference' => $response->transaction_id,
|
||||
'gateway_type_id' => GatewayType::CREDIT_CARD,
|
||||
];
|
||||
$payment=$this->forte->createPayment($data, Payment::STATUS_COMPLETED);
|
||||
return redirect('client/invoices')->withSuccess('Invoice paid.');
|
||||
}
|
||||
|
@ -21,9 +21,6 @@
|
||||
<input type="hidden" name="dataDescriptor" id="dataDescriptor"/>
|
||||
<input type="hidden" name="token" id="token"/>
|
||||
<input type="hidden" name="store_card" id="store_card"/>
|
||||
<input type="hidden" name="amount_with_fee" id="amount_with_fee" value="{{ $total['amount_with_fee'] }}"/>
|
||||
<input type="hidden" name="system_amount_with_fee" id="system_amount_with_fee" value="{{ $system_amount_with_fee }}"/>
|
||||
<input type="hidden" name="fee_total" id="fee_total" value="{{ $total['fee_total'] }}"/>
|
||||
|
||||
<div id="errors"></div>
|
||||
|
||||
@ -47,7 +44,15 @@
|
||||
<span class="ml-1 cursor-pointer">**** {{ optional($token->meta)->last4 }}</span>
|
||||
</label>
|
||||
@endforeach
|
||||
@endisset
|
||||
@else
|
||||
<div class="relative" x-data="{ open: false }" x-on:click.away="open = false">
|
||||
@if($client->getBankTransferGateway())
|
||||
<a data-cy="add-bank-account-link" href="{{ route('client.payment_methods.create', ['method' => $client->getBankTransferMethodType()]) }}" class="button button-primary bg-primary">
|
||||
{{ ctrans('texts.bank_account') }}
|
||||
</a>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@endcomponent
|
||||
<div class="bg-white px-4 py-5 flex justify-end">
|
||||
|
@ -21,9 +21,6 @@
|
||||
<input type="hidden" name="dataDescriptor" id="dataDescriptor"/>
|
||||
<input type="hidden" name="token" id="token"/>
|
||||
<input type="hidden" name="store_card" id="store_card"/>
|
||||
<input type="hidden" name="amount_with_fee" id="amount_with_fee" value="{{ $total['amount_with_fee'] }}"/>
|
||||
<input type="hidden" name="system_amount_with_fee" id="system_amount_with_fee" value="{{ $system_amount_with_fee }}"/>
|
||||
<input type="hidden" name="fee_total" id="fee_total" value="{{ $total['fee_total'] }}"/>
|
||||
|
||||
<div id="errors"></div>
|
||||
|
||||
@ -48,7 +45,16 @@
|
||||
<span class="ml-1 cursor-pointer">**** {{ optional($token->meta)->last4 }}</span>
|
||||
</label>
|
||||
@endforeach
|
||||
@endisset
|
||||
@else
|
||||
<div class="relative" x-data="{ open: false }" x-on:click.away="open = false">
|
||||
<!-- Add payment method button -->
|
||||
@if($client->getCreditCardGateway())
|
||||
<a data-cy="add-credit-card-link" href="{{ route('client.payment_methods.create', ['method' => App\Models\GatewayType::CREDIT_CARD]) }}" class="button button-primary bg-primary">
|
||||
{{ ctrans('texts.credit_card') }}
|
||||
</a>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@endcomponent
|
||||
<div class="bg-white px-4 py-5 flex justify-end">
|
||||
|
Loading…
x
Reference in New Issue
Block a user