diff --git a/app/Http/Controllers/Gateways/Checkout3dsController.php b/app/Http/Controllers/Gateways/Checkout3dsController.php new file mode 100644 index 000000000000..4dbada72ad86 --- /dev/null +++ b/app/Http/Controllers/Gateways/Checkout3dsController.php @@ -0,0 +1,42 @@ +getCompany()) { + return response()->json(['message' => 'Company record not found.', 'company_key' => $company_key]); + } + + if (!$request->getCompanyGateway()) { + return response()->json(['message' => 'Company gateway record not found.', 'company_gateway_id' => $company_gateway_id]); + } + + if (!$request->getPaymentHash()) { + return response()->json(['message' => 'Hash record not found.', 'hash' => $hash]); + } + + if (!$request->getClient()) { + return response()->json(['message' => 'Client record not found.']); + } + + return $request->getCompanyGateway() + ->driver($request->getClient()) + ->process3dsConfirmation($request); + } +} diff --git a/app/Http/Requests/Gateways/Checkout3ds/Checkout3dsRequest.php b/app/Http/Requests/Gateways/Checkout3ds/Checkout3dsRequest.php new file mode 100644 index 000000000000..021379542094 --- /dev/null +++ b/app/Http/Requests/Gateways/Checkout3ds/Checkout3dsRequest.php @@ -0,0 +1,57 @@ +company_key)->first(); + } + + public function getCompanyGateway() + { + return CompanyGateway::find($this->decodePrimaryKey($this->company_gateway_id)); + } + + public function getPaymentHash() + { + return PaymentHash::where('hash', $this->hash)->first(); + } + + public function getClient() + { + return Client::find($this->getPaymentHash()->data->client_id); + } +} diff --git a/app/Http/Requests/Payments/PaymentWebhookRequest.php b/app/Http/Requests/Payments/PaymentWebhookRequest.php index 2642f2458e93..2fc33f6494f9 100644 --- a/app/Http/Requests/Payments/PaymentWebhookRequest.php +++ b/app/Http/Requests/Payments/PaymentWebhookRequest.php @@ -100,14 +100,15 @@ class PaymentWebhookRequest extends Request /** * Resolve client from payment hash. * - * @return null|\App\Models\Client + * @return null|\App\Models\Client|bool */ public function getClient() { $hash = $this->getPaymentHash(); - if($hash) + if($hash) { return Client::find($hash->data->client_id)->firstOrFail(); + } return false; } diff --git a/app/PaymentDrivers/CheckoutCom/CreditCard.php b/app/PaymentDrivers/CheckoutCom/CreditCard.php index 44ea6023b68e..b30e37ca7404 100644 --- a/app/PaymentDrivers/CheckoutCom/CreditCard.php +++ b/app/PaymentDrivers/CheckoutCom/CreditCard.php @@ -144,7 +144,7 @@ class CreditCard if ($this->checkout->client->currency()->code == 'EUR' || $this->checkout->company_gateway->getConfigField('threeds')) { $payment->{'3ds'} = ['enabled' => true]; - $payment->{'success_url'} = route('payment_webhook', [ + $payment->{'success_url'} = route('checkout.3ds_redirect', [ 'company_key' => $this->checkout->client->company->company_key, 'company_gateway_id' => $this->checkout->company_gateway->hashed_id, 'hash' => $this->checkout->payment_hash->hash, diff --git a/app/PaymentDrivers/CheckoutComPaymentDriver.php b/app/PaymentDrivers/CheckoutComPaymentDriver.php index 1e9b041fab22..df8609096582 100644 --- a/app/PaymentDrivers/CheckoutComPaymentDriver.php +++ b/app/PaymentDrivers/CheckoutComPaymentDriver.php @@ -13,6 +13,7 @@ namespace App\PaymentDrivers; use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; +use App\Http\Requests\Gateways\Checkout3ds\Checkout3dsRequest; use App\Http\Requests\Payments\PaymentWebhookRequest; use App\Jobs\Mail\PaymentFailureMailer; use App\Jobs\Util\SystemLogger; @@ -287,6 +288,11 @@ class CheckoutComPaymentDriver extends BaseDriver } public function processWebhookRequest(PaymentWebhookRequest $request, Payment $payment = null) + { + return true; + } + + public function process3dsConfirmation(Checkout3dsRequest $request) { $this->init(); $this->setPaymentHash($request->getPaymentHash()); diff --git a/routes/web.php b/routes/web.php index 5a7b556ecd9a..715f8d5d5ead 100644 --- a/routes/web.php +++ b/routes/web.php @@ -36,4 +36,6 @@ Route::group(['middleware' => ['url_db']], function () { }); Route::get('stripe/signup/{token}', 'StripeConnectController@initialize')->name('stripe_connect.initialization'); -Route::get('stripe/completed', 'StripeConnectController@completed')->name('stripe_connect.return'); \ No newline at end of file +Route::get('stripe/completed', 'StripeConnectController@completed')->name('stripe_connect.return'); + +Route::get('checkout/3ds_redirect/{company_key}/{company_gateway_id}/{hash}', 'Gateways\Checkout3dsController@index')->name('checkout.3ds_redirect');