mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
wip
This commit is contained in:
parent
d50c629476
commit
202cc9d670
@ -11,7 +11,7 @@ use App\Models\Payment;
|
|||||||
use App\Models\PaymentType;
|
use App\Models\PaymentType;
|
||||||
use App\Models\SystemLog;
|
use App\Models\SystemLog;
|
||||||
use App\PaymentDrivers\MolliePaymentDriver;
|
use App\PaymentDrivers\MolliePaymentDriver;
|
||||||
use App\Utils\Number;
|
use Illuminate\Contracts\Container\BindingResolutionException;
|
||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
|
||||||
@ -50,6 +50,8 @@ class CreditCard
|
|||||||
*/
|
*/
|
||||||
public function paymentResponse(PaymentResponseRequest $request)
|
public function paymentResponse(PaymentResponseRequest $request)
|
||||||
{
|
{
|
||||||
|
dd($this->mollie->gateway->mandates->listForId('cst_6S77wEkuQT'));
|
||||||
|
|
||||||
// TODO: Unit tests.
|
// TODO: Unit tests.
|
||||||
$amount = number_format((float) $this->mollie->payment_hash->data->amount_with_fee, 2, '.', '');
|
$amount = number_format((float) $this->mollie->payment_hash->data->amount_with_fee, 2, '.', '');
|
||||||
|
|
||||||
@ -58,7 +60,16 @@ class CreditCard
|
|||||||
->withData('client_id', $this->mollie->client->id);
|
->withData('client_id', $this->mollie->client->id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
$customer = $this->mollie->gateway->customers->create([
|
||||||
|
'name' => $this->mollie->client->name,
|
||||||
|
'metadata' => [
|
||||||
|
'id' => $this->mollie->client->hashed_id,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
$payment = $this->mollie->gateway->payments->create([
|
$payment = $this->mollie->gateway->payments->create([
|
||||||
|
'customerId' => $customer->id,
|
||||||
|
'sequenceType' => 'first',
|
||||||
'amount' => [
|
'amount' => [
|
||||||
'currency' => $this->mollie->client->currency()->code,
|
'currency' => $this->mollie->client->currency()->code,
|
||||||
'value' => $amount,
|
'value' => $amount,
|
||||||
@ -79,7 +90,7 @@ class CreditCard
|
|||||||
SystemLog::TYPE_MOLLIE
|
SystemLog::TYPE_MOLLIE
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->processSuccessfulPayment($payment);
|
return $this->processSuccessfulPayment($payment);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($payment->status === 'open') {
|
if ($payment->status === 'open') {
|
||||||
@ -139,4 +150,27 @@ class CreditCard
|
|||||||
|
|
||||||
throw new PaymentFailed($e->getMessage(), $e->getCode());
|
throw new PaymentFailed($e->getMessage(), $e->getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show authorization page.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return Factory|View
|
||||||
|
*/
|
||||||
|
public function authorizeView(array $data)
|
||||||
|
{
|
||||||
|
return render('gateways.mollie.credit_card.authorize', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function authorizeResponse($request)
|
||||||
|
{
|
||||||
|
$customer = $this->mollie->gateway->customers->create([
|
||||||
|
'name' => $this->mollie->client->name,
|
||||||
|
'metadata' => [
|
||||||
|
'id' => $this->mollie->client->hashed_id,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Save $customer->id to database..
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
@extends('portal.ninja2020.layout.payments', ['gateway_title' => ctrans('texts.credit_card'), 'card_title' =>
|
||||||
|
ctrans('texts.credit_card')])
|
||||||
|
|
||||||
|
@section('gateway_head')
|
||||||
|
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('gateway_content')
|
||||||
|
<form action="{{ route('client.payment_methods.store', ['method' => App\Models\GatewayType::CREDIT_CARD]) }}"
|
||||||
|
method="post" id="server_response">
|
||||||
|
@csrf
|
||||||
|
<input type="hidden" name="company_gateway_id" value="{{ $gateway->gateway_id }}">
|
||||||
|
{{-- <input type="hidden" name="payment_method_id" value="1"> --}}
|
||||||
|
<input type="hidden" name="gateway_response" id="gateway_response">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.method')])
|
||||||
|
{{ ctrans('texts.credit_card') }}
|
||||||
|
@endcomponent
|
||||||
|
|
||||||
|
@component('portal.ninja2020.components.general.card-element-single')
|
||||||
|
Click the "Add Payment Method" button to complete test payment.
|
||||||
|
@endcomponent
|
||||||
|
|
||||||
|
@component('portal.ninja2020.gateways.includes.pay_now', ['id' => 'authorize-card'])
|
||||||
|
{{ ctrans('texts.add_payment_method') }}
|
||||||
|
@endcomponent
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('gateway_footer')
|
||||||
|
<script>
|
||||||
|
document.getElementById('authorize-card')
|
||||||
|
.addEventListener('click', (e) => {
|
||||||
|
document.getElementById('server_response').submit();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endsection
|
Loading…
x
Reference in New Issue
Block a user