mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for squar
This commit is contained in:
parent
85b5398718
commit
787400ff39
@ -116,7 +116,7 @@ class CreditCard implements MethodInterface
|
||||
$amount_money->setAmount($amount);
|
||||
$amount_money->setCurrency($this->square_driver->client->currency()->code);
|
||||
|
||||
$body = new \Square\Models\CreatePaymentRequest($token, $request->idempotencyKey, $amount_money);
|
||||
$body = new \Square\Models\CreatePaymentRequest($token, $request->idempotencyKey);
|
||||
$body->setAmountMoney($amount_money);
|
||||
$body->setAutocomplete(true);
|
||||
$body->setLocationId($this->square_driver->company_gateway->getConfigField('locationId'));
|
||||
|
@ -104,13 +104,15 @@ class SquareWebhook implements ShouldQueue
|
||||
|
||||
MultiDB::findAndSetDbByCompanyKey($this->company_key);
|
||||
|
||||
$this->company_gateway = CompanyGateway::queyr()->withTrashed()->find($this->company_gateway_id);
|
||||
$this->company_gateway = CompanyGateway::query()->withTrashed()->find($this->company_gateway_id);
|
||||
$this->driver = $this->company_gateway->driver()->init();
|
||||
$this->square = $this->driver->square;
|
||||
|
||||
$status = $this->webhook_array['data']['object']['payment']['status'] ?? false;
|
||||
$payment_id = $this->webhook_array['data']['object']['payment']['id'] ?? null;
|
||||
|
||||
$payment_status = false;
|
||||
|
||||
match($status){
|
||||
'APPROVED' => $payment_status = false,
|
||||
'COMPLETED' => $payment_status = Payment::STATUS_COMPLETED,
|
||||
@ -131,7 +133,6 @@ class SquareWebhook implements ShouldQueue
|
||||
if($payment->status_id == Payment::STATUS_PENDING && in_array($payment_status, [Payment::STATUS_CANCELLED, Payment::STATUS_FAILED])){
|
||||
$payment->service()->deletePayment();
|
||||
|
||||
|
||||
if ($this->driver->payment_hash) {
|
||||
$error = ctrans('texts.client_payment_failure_body', [
|
||||
'invoice' => implode(',', $payment->invoices->pluck('number')->toArray()),
|
||||
@ -157,7 +158,7 @@ class SquareWebhook implements ShouldQueue
|
||||
//toggle pending to completed.
|
||||
}
|
||||
|
||||
private function retrieveOrCreatePayment(?string $payment_reference, int $payment_status): \App\Models\Payment
|
||||
private function retrieveOrCreatePayment(?string $payment_reference, int $payment_status): ?\App\Models\Payment
|
||||
{
|
||||
|
||||
$payment = Payment::withTrashed()->where('transaction_reference', $payment_reference)->first();
|
||||
@ -273,6 +274,7 @@ class SquareWebhook implements ShouldQueue
|
||||
else{
|
||||
nlog("Square Webhook - Payment not found: $payment_reference");
|
||||
nlog($apiResponse->getErrors());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -230,7 +230,7 @@ class SquarePaymentDriver extends BaseDriver
|
||||
$amount_money->setAmount($amount);
|
||||
$amount_money->setCurrency($this->client->currency()->code);
|
||||
|
||||
$body = new \Square\Models\CreatePaymentRequest($cgt->token, \Illuminate\Support\Str::random(32), $amount_money);
|
||||
$body = new \Square\Models\CreatePaymentRequest($cgt->token, \Illuminate\Support\Str::random(32));
|
||||
$body->setCustomerId($cgt->gateway_customer_reference);
|
||||
$body->setAmountMoney($amount_money);
|
||||
$body->setReferenceId($payment_hash->hash);
|
||||
|
Loading…
x
Reference in New Issue
Block a user