mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Upgrades for Square
This commit is contained in:
parent
d4aeca5ad1
commit
87d14dd052
@ -34,11 +34,8 @@ class CreditCard implements MethodInterface
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
public $square_driver;
|
||||
|
||||
public function __construct(SquarePaymentDriver $square_driver)
|
||||
public function __construct(public SquarePaymentDriver $square_driver)
|
||||
{
|
||||
$this->square_driver = $square_driver;
|
||||
$this->square_driver->init();
|
||||
}
|
||||
|
||||
@ -103,8 +100,7 @@ class CreditCard implements MethodInterface
|
||||
);
|
||||
|
||||
if ($request->shouldUseToken()) {
|
||||
/** @var \App\Models\ClientGatewayToken $cgt **/
|
||||
$cgt = ClientGatewayToken::where('token', $request->token)->first();
|
||||
$cgt = ClientGatewayToken::query()->where('token', $request->token)->first();
|
||||
$token = $cgt->token;
|
||||
}
|
||||
|
||||
@ -122,7 +118,6 @@ class CreditCard implements MethodInterface
|
||||
|
||||
$body = new \Square\Models\CreatePaymentRequest($token, $request->idempotencyKey, $amount_money);
|
||||
$body->setAmountMoney($amount_money);
|
||||
|
||||
$body->setAutocomplete(true);
|
||||
$body->setLocationId($this->square_driver->company_gateway->getConfigField('locationId'));
|
||||
$body->setReferenceId($this->square_driver->payment_hash->hash);
|
||||
@ -134,7 +129,6 @@ class CreditCard implements MethodInterface
|
||||
$body->setVerificationToken($request->input('verificationToken'));
|
||||
}
|
||||
|
||||
/** @var ApiResponse */
|
||||
$response = $this->square_driver->square->getPaymentsApi()->createPayment($body);
|
||||
|
||||
if ($response->isSuccess()) {
|
||||
|
@ -17,7 +17,6 @@ use App\Models\SystemLog;
|
||||
use App\Models\GatewayType;
|
||||
use App\Models\PaymentHash;
|
||||
use App\Models\PaymentType;
|
||||
use Square\Http\ApiResponse;
|
||||
use App\Jobs\Util\SystemLogger;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Square\Utils\WebhooksHelper;
|
||||
@ -25,7 +24,6 @@ use App\Models\ClientGatewayToken;
|
||||
use Square\Models\WebhookSubscription;
|
||||
use App\PaymentDrivers\Square\CreditCard;
|
||||
use App\PaymentDrivers\Square\SquareWebhook;
|
||||
use Square\Models\ListWebhookSubscriptionsRequest;
|
||||
use Square\Models\CreateWebhookSubscriptionRequest;
|
||||
use App\Http\Requests\Payments\PaymentWebhookRequest;
|
||||
use Square\Models\Builders\RefundPaymentRequestBuilder;
|
||||
@ -238,7 +236,6 @@ class SquarePaymentDriver extends BaseDriver
|
||||
$body->setReferenceId($payment_hash->hash);
|
||||
$body->setNote(substr($description,0,500));
|
||||
|
||||
/** @var ApiResponse */
|
||||
$response = $this->square->getPaymentsApi()->createPayment($body);
|
||||
$body = json_decode($response->getBody());
|
||||
|
||||
@ -310,7 +307,6 @@ class SquarePaymentDriver extends BaseDriver
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// {
|
||||
// "subscription": {
|
||||
// "id": "wbhk_b35f6b3145074cf9ad513610786c19d5",
|
||||
@ -341,9 +337,9 @@ class SquarePaymentDriver extends BaseDriver
|
||||
$subscription->setName('Invoice_Ninja_Webhook_Subscription');
|
||||
$subscription->setEventTypes($event_types);
|
||||
|
||||
$subscription->setNotificationUrl('https://invoicing.co');
|
||||
// $subscription->setNotificationUrl('https://invoicing.co');
|
||||
|
||||
// $subscription->setNotificationUrl($this->company_gateway->webhookUrl());
|
||||
$subscription->setNotificationUrl($this->company_gateway->webhookUrl());
|
||||
// $subscription->setApiVersion('2021-12-15');
|
||||
|
||||
$body = new CreateWebhookSubscriptionRequest($subscription);
|
||||
@ -354,7 +350,7 @@ $subscription->setNotificationUrl('https://invoicing.co');
|
||||
if ($api_response->isSuccess()) {
|
||||
$subscription = $api_response->getResult()->getSubscription();
|
||||
$signatureKey = $subscription->getSignatureKey();
|
||||
|
||||
|
||||
$this->company_gateway->setConfigField('signatureKey', $signatureKey);
|
||||
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user