This commit is contained in:
cnohall 2025-03-13 09:02:40 +09:00
parent 24e450cddd
commit be95286690
15 changed files with 52 additions and 48 deletions

View File

@ -583,8 +583,9 @@ class CompanyGatewayController extends BaseController
public function test(TestCompanyGatewayRequest $request, CompanyGateway $company_gateway)
{
return response()->json(['message' => $company_gateway->driver()->auth() ? 'true' : 'false'], 200);
$message = $company_gateway->driver()->auth();
$is_ok = $message === 'ok';
return response()->json(['message' => $message], $is_ok ? 200 : 400);
}

View File

@ -205,8 +205,8 @@ class AuthorizePaymentDriver extends BaseDriver
return $this->import();
}
public function auth(): bool
public function auth(): string
{
return $this->init()->getPublicClientKey() ?? false;
return $this->init()->getPublicClientKey() ? 'ok' : 'error';
}
}

View File

@ -58,7 +58,7 @@ class BaseDriver extends AbstractPaymentDriver
/**
* Indicates if returning responses should be headless or classic redirect.
*
*
* @var bool
*/
public bool $headless = false;
@ -181,7 +181,7 @@ class BaseDriver extends AbstractPaymentDriver
}
public function setHeadless(bool $headless): self
public function setHeadless(bool $headless): self
{
$this->headless = $headless;
@ -418,7 +418,7 @@ class BaseDriver extends AbstractPaymentDriver
}
$invoice = $this->payment_hash->fee_invoice;
if(!$invoice)
return;
@ -434,7 +434,7 @@ class BaseDriver extends AbstractPaymentDriver
$unconfirmed_fee_count = collect($invoice->line_items)
->where('type_id', '3')
->count();
if ($unconfirmed_fee_count == 0) {
nlog("apparently no fee, so injecting here!");
@ -912,11 +912,11 @@ class BaseDriver extends AbstractPaymentDriver
/**
* Stub for checking authentication.
*
* @return bool
* @return string
*/
public function auth(): bool
public function auth(): string
{
return true;
return 'ok';
}
public function importCustomers()

View File

@ -145,20 +145,19 @@ class BlockonomicsPaymentDriver extends BaseDriver
return $this->payment_method->refund($payment, $amount); //this is your custom implementation from here
}
public function auth(): bool
public function auth(): string
{
try {
$api_key = $this->company_gateway->getConfigField('apiKey');
$url = $this->NEW_ADDRESS_URL . '?reset=1';
$response = Http::withToken($api_key)
->post($url, []);
if($response->successful()) {
return true;
return 'ok';
}
return false;
return 'error';
} catch (\Exception $e) {
return false;
return $e->getMessage();
}
}

View File

@ -333,18 +333,18 @@ class BraintreePaymentDriver extends BaseDriver
return response()->json([], 200);
}
public function auth(): bool
public function auth(): string
{
try {
$ct = $this->init()->gateway->clientToken()->generate();
return true;
return 'ok';
} catch (\Exception $e) {
}
return false;
return 'error';
}
private function find(string $customer_id = '')

View File

@ -190,13 +190,13 @@ class CBAPowerBoardPaymentDriver extends BaseDriver
{
}
public function auth(): bool
public function auth(): string
{
$this->init();
$this->settings()->updateSettings();
return true;
return 'ok';
}

View File

@ -538,15 +538,15 @@ class CheckoutComPaymentDriver extends BaseDriver
// Gateway doesn't support this feature.
}
public function auth(): bool
public function auth(): string
{
try {
$this->init()->gateway->getCustomersClient('x');
return true;
return 'ok';
} catch (\Exception $e) {
}
return false;
return 'error';
}
private function getToken(string $token, $gateway_customer_reference)

View File

@ -212,12 +212,13 @@ class EwayPaymentDriver extends BaseDriver
return $fields;
}
public function auth(): bool
public function auth(): string
{
$response = $this->init()->eway->queryTransaction('xx');
return (bool) count($response->getErrors()) == 0;
$message = (bool) count($response->getErrors()) == 0 ? 'ok' : 'error';
return $message;
}

View File

@ -112,7 +112,7 @@ class FortePaymentDriver extends BaseDriver
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{
"action":"reverse",
"action":"reverse",
"authorization_amount":'.$amount.',
"original_transaction_id":"'.$payment->transaction_reference.'",
"authorization_code": "9ZQ754"
@ -193,7 +193,7 @@ class FortePaymentDriver extends BaseDriver
////////////////////////////////////////////
// DB
///////////////////////////////////////////
public function auth(): bool
public function auth(): string
{
$forte_base_uri = "https://sandbox.forte.net/api/v3/";
@ -210,7 +210,7 @@ class FortePaymentDriver extends BaseDriver
->withHeaders(['X-Forte-Auth-Organization-Id' => $forte_organization_id])
->get("{$forte_base_uri}/organizations/{$forte_organization_id}/locations/{$forte_location_id}/customers/");
return $response->successful();
return $response->successful() ? 'ok' : 'error';
}

View File

@ -98,7 +98,7 @@ class GoCardlessPaymentDriver extends BaseDriver
public function init(): self
{
$environment = $this->company_gateway->getConfigField('testMode') ? \GoCardlessPro\Environment::SANDBOX : \GoCardlessPro\Environment::LIVE;
if ($this->company_gateway->getConfigField('oauth2')) {
$environment = \GoCardlessPro\Environment::LIVE;
}
@ -568,15 +568,16 @@ class GoCardlessPaymentDriver extends BaseDriver
return render('gateways.gocardless.verification');
}
public function auth(): bool
public function auth(): string
{
try {
$customers = $this->init()->gateway->customers()->list();
return true;
return 'ok';
} catch (\Exception $e) {
}
return false;
return 'error';
}
}

View File

@ -427,18 +427,18 @@ class MolliePaymentDriver extends BaseDriver
return \number_format((float) $amount, 2, '.', '');
}
public function auth(): bool
public function auth(): string
{
$this->init();
try {
$p = $this->gateway->payments->page();
return true;
return 'ok';
} catch (\Exception $e) {
}
return false;
return 'error';
}
}

View File

@ -499,17 +499,17 @@ class PayPalBasePaymentDriver extends BaseDriver
}
public function auth(): bool
public function auth(): string
{
try {
$this->init()->getClientToken();
return true;
return 'ok';
} catch (\Exception $e) {
}
return false;
return 'error';
}
public function importCustomers()

View File

@ -307,16 +307,18 @@ class PaytracePaymentDriver extends BaseDriver
return $fields;
}
public function auth(): bool
public function auth(): string
{
try {
$this->init()->generateAuthHeaders() && strlen($this->company_gateway->getConfigField('integratorId')) > 2;
return true;
return 'ok';
} catch (\Exception $e) {
}
return false;
return 'error';
}

View File

@ -435,7 +435,7 @@ class SquarePaymentDriver extends BaseDriver
return $amount;
}
public function auth(): bool
public function auth(): string
{
$api_response = $this->init()
@ -444,7 +444,7 @@ class SquarePaymentDriver extends BaseDriver
->listCustomers();
return (bool) count($api_response->getErrors()) == 0;
return (bool) count($api_response->getErrors()) == 0 ? 'ok' : 'error';
}

View File

@ -1035,25 +1035,25 @@ class StripePaymentDriver extends BaseDriver implements SupportsHeadlessInterfac
}, $string);
}
public function auth(): bool
public function auth(): string
{
$this->init();
try {
$this->verifyConnect();
return true;
return 'ok';
} catch (\Exception $e) {
}
return false;
return 'error';
}
/**
* @inheritDoc
*/
public function setHeadless(bool $headless): self
public function setHeadless(bool $headless): self
{
$this->headless = $headless;