diff --git a/Http/Controllers/PaymentController.php b/Http/Controllers/PaymentController.php new file mode 100644 index 0000000..1a91705 --- /dev/null +++ b/Http/Controllers/PaymentController.php @@ -0,0 +1,32 @@ +with('payable', $payable); + } + + public function pay(Payable $payable, Request $request, CreateAndBeginPaymentHandler $createAndBeginPaymentHandler) + { + Validator::make( + $request->all(), + [ + 'paymentMethodId' => 'required', + 'cardToken' => 'required', + ] + )->validate(); + + $data = new PaymentDTO($request->get('paymentMethodId'), $request->get('cardToken'), $payable, $payable->payer()); + $createAndBeginPaymentHandler->handle($data); + } + +} diff --git a/composer.json b/composer.json index 2cf6820..d559673 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,9 @@ "konekt/enum-eloquent": "^1.2", "mercadopago/dx-php": "^1.2", "carbondate/carbon": "^1.33", - "spatie/laravel-html": "^2.22" + "spatie/laravel-html": "^2.22", + "illuminate/routing": "^5.8", + "illuminate/validation": "^5.8" }, "autoload": { "psr-4": { diff --git a/config/mppayments.php b/config/mppayments.php index 7e430d7..d9c1627 100644 --- a/config/mppayments.php +++ b/config/mppayments.php @@ -3,23 +3,15 @@ return [ /* - * Public Key for Custom Checkout + * Fields for Custom Checkout */ - 'public-key' => '', + 'public-key' => env('MPPAYMENTS_PUBLIC_KEY', ''), + 'access-token' => env('MPPAYMENTS_ACCESS_TOKEN', ''), /* - * Access Token for Custom Checkout + * FIelds for Basic Checkout */ - 'access-token' => '', - - /* - * Client Id for Basic Checkout - */ - 'client-id' => '', - - /* - * Client Secret for Basic Checkout - */ - 'client-secret' => '', + 'client-id' => env('MPPAYMENTS_CLIENT_ID', ''), + 'client-secret' => env('MPPAYMENTS_CLIENT_SECRET', ''), ]; diff --git a/resources/views/card-cvv.blade.php b/resources/views/card-cvv.blade.php new file mode 100644 index 0000000..5c9ff4a --- /dev/null +++ b/resources/views/card-cvv.blade.php @@ -0,0 +1,2 @@ +{{ html()->label('CVV', 'securityCode') }} + diff --git a/resources/views/card-expiration-month.blade.php b/resources/views/card-expiration-month.blade.php new file mode 100644 index 0000000..d5deaa1 --- /dev/null +++ b/resources/views/card-expiration-month.blade.php @@ -0,0 +1,2 @@ +{{ html()->label('Mes de Expiración', 'cardExpirationMonth') }} + diff --git a/resources/views/card-expiration-year.blade.php b/resources/views/card-expiration-year.blade.php new file mode 100644 index 0000000..dfe4b14 --- /dev/null +++ b/resources/views/card-expiration-year.blade.php @@ -0,0 +1,2 @@ +{{ html()->label('Año de Expiración', 'cardExpirationYear') }} + diff --git a/resources/views/card-name.blade.php b/resources/views/card-name.blade.php new file mode 100644 index 0000000..9a01d7c --- /dev/null +++ b/resources/views/card-name.blade.php @@ -0,0 +1,2 @@ +{{ html()->label('Nombre en la tarjeta', 'cardholderName') }} + diff --git a/resources/views/card-number.blade.php b/resources/views/card-number.blade.php new file mode 100644 index 0000000..1317449 --- /dev/null +++ b/resources/views/card-number.blade.php @@ -0,0 +1,2 @@ +{{ html()->label('Número de Tarjeta', 'cardNumber') }} + diff --git a/resources/views/doc-number.blade.php b/resources/views/doc-number.blade.php new file mode 100644 index 0000000..5eff21a --- /dev/null +++ b/resources/views/doc-number.blade.php @@ -0,0 +1,2 @@ +{{ html()->label('Número de Documento', 'docNumber') }} + diff --git a/resources/views/doc-type.blade.php b/resources/views/doc-type.blade.php new file mode 100644 index 0000000..c4fb6f0 --- /dev/null +++ b/resources/views/doc-type.blade.php @@ -0,0 +1,4 @@ +{{ html()->label('Tipo de Documento', 'docType') }} + diff --git a/resources/views/form.blade.php b/resources/views/form.blade.php index fee4272..23be5c5 100644 --- a/resources/views/form.blade.php +++ b/resources/views/form.blade.php @@ -1,42 +1,86 @@ -{{ html()->form('POST', route('checkout.doPay', $order))->id('pay')->open() }} - {{ html()->hidden('paymentMethodId')->id('paymentMethodId') }} - {{ html()->hidden('cardToken')->id('cardToken') }} +{{ html()->form('POST', route('pay', $payable))->id('pay')->open() }} + @include('payment-hidden')