diff --git a/app/PaymentDrivers/Mollie/CreditCard.php b/app/PaymentDrivers/Mollie/CreditCard.php index 38886e65d722..959ecdc9c1c2 100644 --- a/app/PaymentDrivers/Mollie/CreditCard.php +++ b/app/PaymentDrivers/Mollie/CreditCard.php @@ -11,7 +11,7 @@ use App\Models\Payment; use App\Models\PaymentType; use App\Models\SystemLog; use App\PaymentDrivers\MolliePaymentDriver; -use App\Utils\Number; +use Illuminate\Contracts\Container\BindingResolutionException; use Illuminate\Contracts\View\Factory; use Illuminate\View\View; @@ -50,6 +50,8 @@ class CreditCard */ public function paymentResponse(PaymentResponseRequest $request) { + dd($this->mollie->gateway->mandates->listForId('cst_6S77wEkuQT')); + // TODO: Unit tests. $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); 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([ + 'customerId' => $customer->id, + 'sequenceType' => 'first', 'amount' => [ 'currency' => $this->mollie->client->currency()->code, 'value' => $amount, @@ -79,7 +90,7 @@ class CreditCard SystemLog::TYPE_MOLLIE ); - return $this->processSuccessfulPayment($payment); + return $this->processSuccessfulPayment($payment); } if ($payment->status === 'open') { @@ -139,4 +150,27 @@ class CreditCard 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.. + } } diff --git a/resources/views/portal/ninja2020/gateways/mollie/credit_card/authorize.blade.php b/resources/views/portal/ninja2020/gateways/mollie/credit_card/authorize.blade.php new file mode 100644 index 000000000000..5e3ae5d75ef3 --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/mollie/credit_card/authorize.blade.php @@ -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') +
+ @csrf + + {{-- --}} + +
+ + @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') + +@endsection