mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Working on contact payment page
This commit is contained in:
parent
2f164d6a76
commit
b1836224e2
@ -14,6 +14,7 @@ namespace App\Http\Controllers\ClientPortal;
|
||||
use = namespace\Cache;
|
||||
use App\Filters\PaymentFilters;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\CompanyGateway;
|
||||
use App\Models\Payment;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Http\Request;
|
||||
@ -101,19 +102,23 @@ class PaymentController extends Controller
|
||||
Cache::put($cache_hash, 'value', now()->addMinutes(10));
|
||||
|
||||
//boot the payment gateway
|
||||
|
||||
//build the gateway specific views
|
||||
|
||||
$gateway = CompanyGateway::find($company_gateway_id);
|
||||
|
||||
//if there is a gateway fee, now is the time to calculate it
|
||||
//and add it to the invoice
|
||||
|
||||
$data = [
|
||||
'redirect_url' =>,
|
||||
'cache_hash' => $cache_hash,
|
||||
'invoices' => $invoices,
|
||||
'amount' => $amount,
|
||||
'gateway_data' =>,
|
||||
'cache_hash' => $cache_hash,
|
||||
'fee' => $gateway->calcGatewayFee($amount),
|
||||
'amount_with_fee' => ($amount + $gateway->calcGatewayFee($amount)),
|
||||
'gateway' => $gateway,
|
||||
'payment_method_id' => $payment_method_id,
|
||||
'token' => auth()->user()->client->gateway_token($gateway->id),
|
||||
];
|
||||
|
||||
return view('', $data);
|
||||
return view($gateway->driver()->viewForType($payment_method_id), $data);
|
||||
}
|
||||
|
||||
|
||||
|
@ -100,6 +100,25 @@ class Client extends BaseModel
|
||||
return $this->hasMany(ClientGatewayToken::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the specific payment token per
|
||||
* gateway - per payment method
|
||||
*
|
||||
* Allows the storage of multiple tokens
|
||||
* per client per gateway per payment_method
|
||||
*
|
||||
* @param int $gateway_id The gateway ID
|
||||
* @param int $payment_method_id The payment method ID
|
||||
* @return ClientGatewayToken The client token record
|
||||
*/
|
||||
public function gateway_token($gateway_id, $payment_method_id)
|
||||
{
|
||||
return $this->gateway_tokens
|
||||
->whereCompanyGatewayId($gateway_id)
|
||||
->wherePaymentMethod_id($payment_method_id)
|
||||
->first();
|
||||
}
|
||||
|
||||
public function contacts()
|
||||
{
|
||||
return $this->hasMany(ClientContact::class)->orderBy('is_primary', 'desc');
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace App\PaymentDrivers;
|
||||
|
||||
use App\Models\GatewayType;
|
||||
use Stripe\PaymentIntent;
|
||||
use Stripe\Stripe;
|
||||
|
||||
class StripePaymentDriver extends BasePaymentDriver
|
||||
@ -80,7 +81,7 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
return 'gateways.stripe.credit_card';
|
||||
break;
|
||||
case GatewayType::TOKEN:
|
||||
return 'gateways.stripe.token';
|
||||
return 'gateways.stripe.credit_card';
|
||||
break;
|
||||
case GatewayType::SOFORT:
|
||||
return 'gateways.stripe.sofort';
|
||||
@ -106,6 +107,16 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new String Payment Intent
|
||||
* @param array $data The data array to be passed to Stripe
|
||||
* @return PaymentIntent The Stripe payment intent object
|
||||
*/
|
||||
public function createIntent($data)
|
||||
{
|
||||
return PaymentIntent::create($data);
|
||||
}
|
||||
/************************************** Omnipay API methods **********************************************************/
|
||||
|
||||
|
||||
|
@ -908,6 +908,7 @@ class CreateUsersTable extends Migration
|
||||
$table->unsignedInteger('client_id')->nullable();
|
||||
$table->text('token');
|
||||
$table->unsignedInteger('company_gateway_id');
|
||||
$table->unsignedInteger('payment_method_id');
|
||||
$table->boolean('is_default');
|
||||
$table->timestamps(6);
|
||||
$table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
|
||||
|
@ -38,15 +38,30 @@
|
||||
<li class="list-group-item d-flex list-group-item-action justify-content-between align-items-center"><strong>{{ ctrans('texts.total')}}</strong>
|
||||
<h3><span class="badge badge-primary badge-pill"><strong>{{ $amount }}</strong></span></h3>
|
||||
</li>
|
||||
@if($fee)
|
||||
<li class="list-group-item d-flex list-group-item-action justify-content-between align-items-center"><strong>{{ ctrans('texts.gateway_fee')}}</strong>
|
||||
<h3><span class="badge badge-primary badge-pill"><strong>{{ $fee }}</strong></span></h3>
|
||||
</li>
|
||||
<li class="list-group-item d-flex list-group-item-action justify-content-between align-items-center"><strong>{{ ctrans('texts.amount_due')}}</strong>
|
||||
<h3><span class="badge badge-primary badge-pill"><strong>{{ $amount_with_fee }}</strong></span></h3>
|
||||
</li>
|
||||
@endif
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- Stripe Credit Card TOKEN Form-->
|
||||
@if($token)
|
||||
|
||||
<!-- Stripe Credit Card TOKEN Form-->
|
||||
|
||||
@else
|
||||
<!-- Stripe Credit Card Payment Form-->
|
||||
<div class="py-md-5">
|
||||
|
||||
</div>
|
||||
<!-- Stripe Credit Card Payment Form-->
|
||||
|
||||
@endif
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -56,7 +71,7 @@
|
||||
</body>
|
||||
@endsection
|
||||
@push('scripts')
|
||||
|
||||
<script src="https://js.stripe.com/v3/"></script>
|
||||
@endpush
|
||||
@section('footer')
|
||||
@endsection
|
||||
|
Loading…
x
Reference in New Issue
Block a user