Init
This commit is contained in:
parent
24e450cddd
commit
be95286690
|
|
@ -583,8 +583,9 @@ class CompanyGatewayController extends BaseController
|
||||||
|
|
||||||
public function test(TestCompanyGatewayRequest $request, CompanyGateway $company_gateway)
|
public function test(TestCompanyGatewayRequest $request, CompanyGateway $company_gateway)
|
||||||
{
|
{
|
||||||
|
$message = $company_gateway->driver()->auth();
|
||||||
return response()->json(['message' => $company_gateway->driver()->auth() ? 'true' : 'false'], 200);
|
$is_ok = $message === 'ok';
|
||||||
|
return response()->json(['message' => $message], $is_ok ? 200 : 400);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -205,8 +205,8 @@ class AuthorizePaymentDriver extends BaseDriver
|
||||||
return $this->import();
|
return $this->import();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function auth(): bool
|
public function auth(): string
|
||||||
{
|
{
|
||||||
return $this->init()->getPublicClientKey() ?? false;
|
return $this->init()->getPublicClientKey() ? 'ok' : 'error';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ class BaseDriver extends AbstractPaymentDriver
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if returning responses should be headless or classic redirect.
|
* Indicates if returning responses should be headless or classic redirect.
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
public bool $headless = false;
|
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;
|
$this->headless = $headless;
|
||||||
|
|
||||||
|
|
@ -418,7 +418,7 @@ class BaseDriver extends AbstractPaymentDriver
|
||||||
}
|
}
|
||||||
|
|
||||||
$invoice = $this->payment_hash->fee_invoice;
|
$invoice = $this->payment_hash->fee_invoice;
|
||||||
|
|
||||||
if(!$invoice)
|
if(!$invoice)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -434,7 +434,7 @@ class BaseDriver extends AbstractPaymentDriver
|
||||||
$unconfirmed_fee_count = collect($invoice->line_items)
|
$unconfirmed_fee_count = collect($invoice->line_items)
|
||||||
->where('type_id', '3')
|
->where('type_id', '3')
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
if ($unconfirmed_fee_count == 0) {
|
if ($unconfirmed_fee_count == 0) {
|
||||||
|
|
||||||
nlog("apparently no fee, so injecting here!");
|
nlog("apparently no fee, so injecting here!");
|
||||||
|
|
@ -912,11 +912,11 @@ class BaseDriver extends AbstractPaymentDriver
|
||||||
/**
|
/**
|
||||||
* Stub for checking authentication.
|
* Stub for checking authentication.
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function auth(): bool
|
public function auth(): string
|
||||||
{
|
{
|
||||||
return true;
|
return 'ok';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function importCustomers()
|
public function importCustomers()
|
||||||
|
|
|
||||||
|
|
@ -145,20 +145,19 @@ class BlockonomicsPaymentDriver extends BaseDriver
|
||||||
return $this->payment_method->refund($payment, $amount); //this is your custom implementation from here
|
return $this->payment_method->refund($payment, $amount); //this is your custom implementation from here
|
||||||
}
|
}
|
||||||
|
|
||||||
public function auth(): bool
|
public function auth(): string
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$api_key = $this->company_gateway->getConfigField('apiKey');
|
$api_key = $this->company_gateway->getConfigField('apiKey');
|
||||||
$url = $this->NEW_ADDRESS_URL . '?reset=1';
|
$url = $this->NEW_ADDRESS_URL . '?reset=1';
|
||||||
$response = Http::withToken($api_key)
|
$response = Http::withToken($api_key)
|
||||||
->post($url, []);
|
->post($url, []);
|
||||||
if($response->successful()) {
|
if($response->successful()) {
|
||||||
return true;
|
return 'ok';
|
||||||
}
|
}
|
||||||
return false;
|
return 'error';
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return false;
|
return $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -333,18 +333,18 @@ class BraintreePaymentDriver extends BaseDriver
|
||||||
return response()->json([], 200);
|
return response()->json([], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function auth(): bool
|
public function auth(): string
|
||||||
{
|
{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$ct = $this->init()->gateway->clientToken()->generate();
|
$ct = $this->init()->gateway->clientToken()->generate();
|
||||||
|
|
||||||
return true;
|
return 'ok';
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return 'error';
|
||||||
}
|
}
|
||||||
|
|
||||||
private function find(string $customer_id = '')
|
private function find(string $customer_id = '')
|
||||||
|
|
|
||||||
|
|
@ -190,13 +190,13 @@ class CBAPowerBoardPaymentDriver extends BaseDriver
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function auth(): bool
|
public function auth(): string
|
||||||
{
|
{
|
||||||
$this->init();
|
$this->init();
|
||||||
|
|
||||||
$this->settings()->updateSettings();
|
$this->settings()->updateSettings();
|
||||||
|
|
||||||
return true;
|
return 'ok';
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -538,15 +538,15 @@ class CheckoutComPaymentDriver extends BaseDriver
|
||||||
// Gateway doesn't support this feature.
|
// Gateway doesn't support this feature.
|
||||||
}
|
}
|
||||||
|
|
||||||
public function auth(): bool
|
public function auth(): string
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->init()->gateway->getCustomersClient('x');
|
$this->init()->gateway->getCustomersClient('x');
|
||||||
return true;
|
return 'ok';
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return 'error';
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getToken(string $token, $gateway_customer_reference)
|
private function getToken(string $token, $gateway_customer_reference)
|
||||||
|
|
|
||||||
|
|
@ -212,12 +212,13 @@ class EwayPaymentDriver extends BaseDriver
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function auth(): bool
|
public function auth(): string
|
||||||
{
|
{
|
||||||
|
|
||||||
$response = $this->init()->eway->queryTransaction('xx');
|
$response = $this->init()->eway->queryTransaction('xx');
|
||||||
|
|
||||||
return (bool) count($response->getErrors()) == 0;
|
$message = (bool) count($response->getErrors()) == 0 ? 'ok' : 'error';
|
||||||
|
return $message;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ class FortePaymentDriver extends BaseDriver
|
||||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||||
CURLOPT_POSTFIELDS => '{
|
CURLOPT_POSTFIELDS => '{
|
||||||
"action":"reverse",
|
"action":"reverse",
|
||||||
"authorization_amount":'.$amount.',
|
"authorization_amount":'.$amount.',
|
||||||
"original_transaction_id":"'.$payment->transaction_reference.'",
|
"original_transaction_id":"'.$payment->transaction_reference.'",
|
||||||
"authorization_code": "9ZQ754"
|
"authorization_code": "9ZQ754"
|
||||||
|
|
@ -193,7 +193,7 @@ class FortePaymentDriver extends BaseDriver
|
||||||
////////////////////////////////////////////
|
////////////////////////////////////////////
|
||||||
// DB
|
// DB
|
||||||
///////////////////////////////////////////
|
///////////////////////////////////////////
|
||||||
public function auth(): bool
|
public function auth(): string
|
||||||
{
|
{
|
||||||
|
|
||||||
$forte_base_uri = "https://sandbox.forte.net/api/v3/";
|
$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])
|
->withHeaders(['X-Forte-Auth-Organization-Id' => $forte_organization_id])
|
||||||
->get("{$forte_base_uri}/organizations/{$forte_organization_id}/locations/{$forte_location_id}/customers/");
|
->get("{$forte_base_uri}/organizations/{$forte_organization_id}/locations/{$forte_location_id}/customers/");
|
||||||
|
|
||||||
return $response->successful();
|
return $response->successful() ? 'ok' : 'error';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ class GoCardlessPaymentDriver extends BaseDriver
|
||||||
public function init(): self
|
public function init(): self
|
||||||
{
|
{
|
||||||
$environment = $this->company_gateway->getConfigField('testMode') ? \GoCardlessPro\Environment::SANDBOX : \GoCardlessPro\Environment::LIVE;
|
$environment = $this->company_gateway->getConfigField('testMode') ? \GoCardlessPro\Environment::SANDBOX : \GoCardlessPro\Environment::LIVE;
|
||||||
|
|
||||||
if ($this->company_gateway->getConfigField('oauth2')) {
|
if ($this->company_gateway->getConfigField('oauth2')) {
|
||||||
$environment = \GoCardlessPro\Environment::LIVE;
|
$environment = \GoCardlessPro\Environment::LIVE;
|
||||||
}
|
}
|
||||||
|
|
@ -568,15 +568,16 @@ class GoCardlessPaymentDriver extends BaseDriver
|
||||||
return render('gateways.gocardless.verification');
|
return render('gateways.gocardless.verification');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function auth(): bool
|
|
||||||
|
public function auth(): string
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$customers = $this->init()->gateway->customers()->list();
|
$customers = $this->init()->gateway->customers()->list();
|
||||||
return true;
|
return 'ok';
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return 'error';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -427,18 +427,18 @@ class MolliePaymentDriver extends BaseDriver
|
||||||
return \number_format((float) $amount, 2, '.', '');
|
return \number_format((float) $amount, 2, '.', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function auth(): bool
|
public function auth(): string
|
||||||
{
|
{
|
||||||
$this->init();
|
$this->init();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$p = $this->gateway->payments->page();
|
$p = $this->gateway->payments->page();
|
||||||
return true;
|
return 'ok';
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return 'error';
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -499,17 +499,17 @@ class PayPalBasePaymentDriver extends BaseDriver
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function auth(): bool
|
public function auth(): string
|
||||||
{
|
{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->init()->getClientToken();
|
$this->init()->getClientToken();
|
||||||
return true;
|
return 'ok';
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return 'error';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function importCustomers()
|
public function importCustomers()
|
||||||
|
|
|
||||||
|
|
@ -307,16 +307,18 @@ class PaytracePaymentDriver extends BaseDriver
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function auth(): bool
|
|
||||||
|
|
||||||
|
public function auth(): string
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->init()->generateAuthHeaders() && strlen($this->company_gateway->getConfigField('integratorId')) > 2;
|
$this->init()->generateAuthHeaders() && strlen($this->company_gateway->getConfigField('integratorId')) > 2;
|
||||||
return true;
|
return 'ok';
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return 'error';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -435,7 +435,7 @@ class SquarePaymentDriver extends BaseDriver
|
||||||
return $amount;
|
return $amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function auth(): bool
|
public function auth(): string
|
||||||
{
|
{
|
||||||
|
|
||||||
$api_response = $this->init()
|
$api_response = $this->init()
|
||||||
|
|
@ -444,7 +444,7 @@ class SquarePaymentDriver extends BaseDriver
|
||||||
->listCustomers();
|
->listCustomers();
|
||||||
|
|
||||||
|
|
||||||
return (bool) count($api_response->getErrors()) == 0;
|
return (bool) count($api_response->getErrors()) == 0 ? 'ok' : 'error';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1035,25 +1035,25 @@ class StripePaymentDriver extends BaseDriver implements SupportsHeadlessInterfac
|
||||||
}, $string);
|
}, $string);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function auth(): bool
|
public function auth(): string
|
||||||
{
|
{
|
||||||
$this->init();
|
$this->init();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->verifyConnect();
|
$this->verifyConnect();
|
||||||
return true;
|
return 'ok';
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return 'error';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function setHeadless(bool $headless): self
|
public function setHeadless(bool $headless): self
|
||||||
{
|
{
|
||||||
$this->headless = $headless;
|
$this->headless = $headless;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue