mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 05:54:38 -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 = namespace\Cache;
|
||||||
use App\Filters\PaymentFilters;
|
use App\Filters\PaymentFilters;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\CompanyGateway;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@ -101,19 +102,23 @@ class PaymentController extends Controller
|
|||||||
Cache::put($cache_hash, 'value', now()->addMinutes(10));
|
Cache::put($cache_hash, 'value', now()->addMinutes(10));
|
||||||
|
|
||||||
//boot the payment gateway
|
//boot the payment gateway
|
||||||
|
$gateway = CompanyGateway::find($company_gateway_id);
|
||||||
//build the gateway specific views
|
|
||||||
|
|
||||||
|
|
||||||
|
//if there is a gateway fee, now is the time to calculate it
|
||||||
|
//and add it to the invoice
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'redirect_url' =>,
|
'cache_hash' => $cache_hash,
|
||||||
'invoices' => $invoices,
|
'invoices' => $invoices,
|
||||||
'amount' => $amount,
|
'amount' => $amount,
|
||||||
'gateway_data' =>,
|
'fee' => $gateway->calcGatewayFee($amount),
|
||||||
'cache_hash' => $cache_hash,
|
'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);
|
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()
|
public function contacts()
|
||||||
{
|
{
|
||||||
return $this->hasMany(ClientContact::class)->orderBy('is_primary', 'desc');
|
return $this->hasMany(ClientContact::class)->orderBy('is_primary', 'desc');
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace App\PaymentDrivers;
|
namespace App\PaymentDrivers;
|
||||||
|
|
||||||
use App\Models\GatewayType;
|
use App\Models\GatewayType;
|
||||||
|
use Stripe\PaymentIntent;
|
||||||
use Stripe\Stripe;
|
use Stripe\Stripe;
|
||||||
|
|
||||||
class StripePaymentDriver extends BasePaymentDriver
|
class StripePaymentDriver extends BasePaymentDriver
|
||||||
@ -80,7 +81,7 @@ class StripePaymentDriver extends BasePaymentDriver
|
|||||||
return 'gateways.stripe.credit_card';
|
return 'gateways.stripe.credit_card';
|
||||||
break;
|
break;
|
||||||
case GatewayType::TOKEN:
|
case GatewayType::TOKEN:
|
||||||
return 'gateways.stripe.token';
|
return 'gateways.stripe.credit_card';
|
||||||
break;
|
break;
|
||||||
case GatewayType::SOFORT:
|
case GatewayType::SOFORT:
|
||||||
return 'gateways.stripe.sofort';
|
return 'gateways.stripe.sofort';
|
||||||
@ -106,6 +107,16 @@ class StripePaymentDriver extends BasePaymentDriver
|
|||||||
break;
|
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 **********************************************************/
|
/************************************** Omnipay API methods **********************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
@ -908,6 +908,7 @@ class CreateUsersTable extends Migration
|
|||||||
$table->unsignedInteger('client_id')->nullable();
|
$table->unsignedInteger('client_id')->nullable();
|
||||||
$table->text('token');
|
$table->text('token');
|
||||||
$table->unsignedInteger('company_gateway_id');
|
$table->unsignedInteger('company_gateway_id');
|
||||||
|
$table->unsignedInteger('payment_method_id');
|
||||||
$table->boolean('is_default');
|
$table->boolean('is_default');
|
||||||
$table->timestamps(6);
|
$table->timestamps(6);
|
||||||
$table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
|
$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>
|
<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>
|
<h3><span class="badge badge-primary badge-pill"><strong>{{ $amount }}</strong></span></h3>
|
||||||
</li>
|
</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>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Stripe Credit Card TOKEN Form-->
|
||||||
|
@if($token)
|
||||||
|
|
||||||
|
<!-- Stripe Credit Card TOKEN Form-->
|
||||||
|
|
||||||
|
@else
|
||||||
<!-- Stripe Credit Card Payment Form-->
|
<!-- Stripe Credit Card Payment Form-->
|
||||||
<div class="py-md-5">
|
<div class="py-md-5">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- Stripe Credit Card Payment Form-->
|
<!-- Stripe Credit Card Payment Form-->
|
||||||
|
@endif
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -56,7 +71,7 @@
|
|||||||
</body>
|
</body>
|
||||||
@endsection
|
@endsection
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
|
<script src="https://js.stripe.com/v3/"></script>
|
||||||
@endpush
|
@endpush
|
||||||
@section('footer')
|
@section('footer')
|
||||||
@endsection
|
@endsection
|
||||||
|
Loading…
x
Reference in New Issue
Block a user