mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Merge pull request #5864 from beganovich/v5-3105-checkout-3ds-route
(v5) Move Checkout.com 3DS confirmation logic into separate route
This commit is contained in:
commit
468b576ce5
42
app/Http/Controllers/Gateways/Checkout3dsController.php
Normal file
42
app/Http/Controllers/Gateways/Checkout3dsController.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers\Gateways;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Gateways\Checkout3ds\Checkout3dsRequest;
|
||||
|
||||
class Checkout3dsController extends Controller
|
||||
{
|
||||
public function index(Checkout3dsRequest $request, string $company_key, string $company_gateway_id, string $hash)
|
||||
{
|
||||
if (!$request->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);
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Gateways\Checkout3ds;
|
||||
|
||||
use App\Models\Client;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyGateway;
|
||||
use App\Models\PaymentHash;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class Checkout3dsRequest extends FormRequest
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public function getCompany()
|
||||
{
|
||||
return Company::where('company_key', $this->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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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());
|
||||
|
@ -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');
|
||||
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');
|
||||
|
Loading…
Reference in New Issue
Block a user