Ensure Forte credentials are correctly padded

This commit is contained in:
David Bomba 2025-03-25 12:20:58 +11:00
parent 987e262ac5
commit 0b02ec4e3c
1 changed files with 52 additions and 7 deletions

View File

@ -238,6 +238,23 @@ class CompanyGatewayController extends BaseController
break; break;
case $this->forte_key: case $this->forte_key:
$config = $company_gateway->getConfig();
$config->authOrganizationId = !str_starts_with($config->authOrganizationId, 'org_')
? 'org_' . $config->authOrganizationId
: $config->authOrganizationId;
$config->organizationId = !str_starts_with($config->organizationId, 'org_')
? 'org_' . $config->organizationId
: $config->organizationId;
$config->locationId = !str_starts_with($config->locationId, 'loc_')
? 'loc_' . $config->locationId
: $config->locationId;
$company_gateway->setConfig($config);
$company_gateway->save();
dispatch(function () use ($company_gateway) { dispatch(function () use ($company_gateway) {
MultiDB::setDb($company_gateway->company->db); MultiDB::setDb($company_gateway->company->db);
$company_gateway->driver()->updateFees(); $company_gateway->driver()->updateFees();
@ -443,14 +460,42 @@ class CompanyGatewayController extends BaseController
$company_gateway->fees_and_limits = $fees_and_limits; $company_gateway->fees_and_limits = $fees_and_limits;
$company_gateway->save(); $company_gateway->save();
if ($company_gateway->gateway_key == $this->checkout_key) { switch ($company_gateway->gateway_key) {
CheckoutSetupWebhook::dispatch($company_gateway->company->company_key, $company_gateway->fresh()->id);
} elseif ($company_gateway->gateway_key == $this->forte_key) {
dispatch(function () use ($company_gateway) { case $this->checkout_key:
MultiDB::setDb($company_gateway->company->db); CheckoutSetupWebhook::dispatch($company_gateway->company->company_key, $company_gateway->id);
$company_gateway->driver()->updateFees(); break;
})->afterResponse();
case $this->forte_key:
$config = $company_gateway->getConfig();
$config->authOrganizationId = !str_starts_with($config->authOrganizationId, 'org_')
? 'org_' . $config->authOrganizationId
: $config->authOrganizationId;
$config->organizationId = !str_starts_with($config->organizationId, 'org_')
? 'org_' . $config->organizationId
: $config->organizationId;
$config->locationId = !str_starts_with($config->locationId, 'loc_')
? 'loc_' . $config->locationId
: $config->locationId;
$company_gateway->setConfig($config);
$company_gateway->save();
dispatch(function () use ($company_gateway) {
MultiDB::setDb($company_gateway->company->db);
$company_gateway->driver()->updateFees();
})->afterResponse();
break;
default:
# code...
break;
} }