Working on gateway authentication

This commit is contained in:
David Bomba 2024-03-15 14:21:42 +11:00
parent 5f1e1ac174
commit 094aadd6be
4 changed files with 64 additions and 39 deletions

View File

@ -157,34 +157,6 @@ class BraintreePaymentDriver extends BaseDriver
}
}
// public function updateCustomer()
// {
// $customer = $this->findOrCreateCustomer();
// $result = $this->gateway->customer()->update(
// $customer->id,
// [
// 'firstName' => $this->client->present()->name(),
// 'email' => $this->client->present()->email(),
// 'phone' => $this->client->present()->phone(),
// 'creditCard' => [
// 'billingAddress' => [
// 'options' => [
// 'updateExisting' => true
// ],
// 'firstName' => $this->client->present()->first_name() ?: $this->client->present()->name(),
// 'lastName' => $this->client->present()->last_name() ?: '',
// 'streetAddress' => $this->client->address1 ?: '',
// 'extendedAddress' =>$this->client->address2 ?: '',
// 'locality' => $this->client->city ?: '',
// 'postalCode' => $this->client->postal_code ?: '',
// 'countryCodeAlpha2' => $this->client->country ? $this->client->country->iso_3166_2 : 'US',
// ],
// ],
// ]
// );
// }
public function refund(Payment $payment, $amount, $return_client_response = false)
{
$this->init();
@ -324,13 +296,21 @@ class BraintreePaymentDriver extends BaseDriver
nlog('braintree webhook');
// if($webhookNotification)
// nlog($webhookNotification->kind);
// // Example values for webhook notification properties
// $message = $webhookNotification->kind; // "subscription_went_past_due"
// $message = $webhookNotification->timestamp->format('D M j G:i:s T Y'); // "Sun Jan 1 00:00:00 UTC 2012"
return response()->json([], 200);
}
public function auth(): bool
{
try {
$ct =$this->init()->gateway->clientToken()->generate();
nlog($ct);
return true;
}
catch(\Exception $e) {
}
return false;
}
}

View File

@ -534,4 +534,16 @@ class CheckoutComPaymentDriver extends BaseDriver
{
// Gateway doesn't support this feature.
}
public function auth(): bool
{
try{
$this->init()->gateway->getCustomersClient('x');
return true;
}
catch(\Exception $e){
}
return false;
}
}

View File

@ -211,4 +211,13 @@ class EwayPaymentDriver extends BaseDriver
return $fields;
}
public function auth(): bool
{
$response =$this->init()->eway->queryTransaction('xx');
return (bool) count($response->getErrors()) == 0;
}
}

View File

@ -11,13 +11,14 @@
namespace App\PaymentDrivers;
use App\Jobs\Util\SystemLogger;
use App\Models\GatewayType;
use App\Models\Payment;
use App\Models\SystemLog;
use App\PaymentDrivers\Forte\ACH;
use App\PaymentDrivers\Forte\CreditCard;
use App\Models\GatewayType;
use App\Jobs\Util\SystemLogger;
use App\Utils\Traits\MakesHash;
use App\PaymentDrivers\Forte\ACH;
use Illuminate\Support\Facades\Http;
use App\PaymentDrivers\Forte\CreditCard;
class FortePaymentDriver extends BaseDriver
{
@ -183,6 +184,29 @@ class FortePaymentDriver extends BaseDriver
];
}
public function auth(): bool
{
$forte_base_uri = "https://sandbox.forte.net/api/v3/";
if ($this->company_gateway->getConfigField('testMode') == false) {
$forte_base_uri = "https://api.forte.net/v3/";
}
$forte_api_access_id = $this->company_gateway->getConfigField('apiAccessId');
$forte_secure_key = $this->company_gateway->getConfigField('secureKey');
$forte_auth_organization_id = $this->company_gateway->getConfigField('authOrganizationId');
$forte_organization_id = $this->company_gateway->getConfigField('organizationId');
$forte_location_id = $this->company_gateway->getConfigField('locationId');
$response = Http::withBasicAuth($forte_api_access_id, $forte_secure_key)
->withHeaders(['X-Forte-Auth-Organization-Id' => $forte_organization_id])
->get("{$forte_base_uri}/organizations/{$forte_organization_id}/locations/{$forte_location_id}/customers/");
// nlog("{$forte_base_uri}/organizations/org_{$forte_organization_id}/customers/");
// {{baseURI}}/organizations/org_{{organizationID}}/locations/loc_{{locationID}}/customers
return $response->successful();
}
// public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash)
// {
// return $this->payment_method->yourTokenBillingImplmentation();