mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for BTC Pay
This commit is contained in:
parent
638c823722
commit
adf93942b2
@ -12,18 +12,19 @@
|
|||||||
|
|
||||||
namespace App\PaymentDrivers;
|
namespace App\PaymentDrivers;
|
||||||
|
|
||||||
use App\Utils\Traits\MakesHash;
|
|
||||||
use App\Models\PaymentHash;
|
|
||||||
use App\Models\GatewayType;
|
|
||||||
use App\PaymentDrivers\BTCPay\BTCPay;
|
|
||||||
use App\Models\SystemLog;
|
|
||||||
use App\Models\Payment;
|
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Exceptions\PaymentFailed;
|
|
||||||
use App\Models\PaymentType;
|
|
||||||
use BTCPayServer\Client\Webhook;
|
|
||||||
use App\Http\Requests\Payments\PaymentWebhookRequest;
|
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Models\SystemLog;
|
||||||
|
use App\Models\GatewayType;
|
||||||
|
use App\Models\PaymentHash;
|
||||||
|
use App\Models\PaymentType;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
|
use BTCPayServer\Client\Webhook;
|
||||||
|
use App\Exceptions\PaymentFailed;
|
||||||
|
use App\PaymentDrivers\BTCPay\BTCPay;
|
||||||
|
use App\Jobs\Mail\PaymentFailedMailer;
|
||||||
|
use App\Http\Requests\Payments\PaymentWebhookRequest;
|
||||||
|
|
||||||
class BTCPayPaymentDriver extends BaseDriver
|
class BTCPayPaymentDriver extends BaseDriver
|
||||||
{
|
{
|
||||||
@ -138,8 +139,6 @@ class BTCPayPaymentDriver extends BaseDriver
|
|||||||
|
|
||||||
$_invoice = $this->payment_hash->fee_invoice;
|
$_invoice = $this->payment_hash->fee_invoice;
|
||||||
|
|
||||||
// Invoice::with('client')->withTrashed()->find($this->payment_hash->fee_invoice_id);
|
|
||||||
|
|
||||||
$this->client = $_invoice->client;
|
$this->client = $_invoice->client;
|
||||||
|
|
||||||
$dataPayment = [
|
$dataPayment = [
|
||||||
@ -158,21 +157,49 @@ class BTCPayPaymentDriver extends BaseDriver
|
|||||||
}
|
}
|
||||||
switch ($btcpayRep->type) {
|
switch ($btcpayRep->type) {
|
||||||
case "InvoiceExpired":
|
case "InvoiceExpired":
|
||||||
|
|
||||||
|
if ($payment->status_id == Payment::STATUS_PENDING) {
|
||||||
|
$payment->service()->deletePayment();
|
||||||
|
$this->failedPaymentNotification($payment);
|
||||||
|
}
|
||||||
|
|
||||||
$StatusId = Payment::STATUS_CANCELLED;
|
$StatusId = Payment::STATUS_CANCELLED;
|
||||||
break;
|
break;
|
||||||
case "InvoiceInvalid":
|
case "InvoiceInvalid":
|
||||||
|
|
||||||
|
if ($payment->status_id == Payment::STATUS_PENDING) {
|
||||||
|
$payment->service()->deletePayment();
|
||||||
|
$this->failedPaymentNotification($payment);
|
||||||
|
}
|
||||||
|
|
||||||
$StatusId = Payment::STATUS_FAILED;
|
$StatusId = Payment::STATUS_FAILED;
|
||||||
break;
|
break;
|
||||||
case "InvoiceSettled":
|
case "InvoiceSettled":
|
||||||
$StatusId = Payment::STATUS_COMPLETED;
|
$StatusId = Payment::STATUS_COMPLETED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($payment->status_id != $StatusId) {
|
if ($payment->status_id != $StatusId) {
|
||||||
$payment->status_id = $StatusId;
|
$payment->status_id = $StatusId;
|
||||||
$payment->save();
|
$payment->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function failedPaymentNotification(Payment $payment): void
|
||||||
|
{
|
||||||
|
|
||||||
|
$error = ctrans('texts.client_payment_failure_body', [
|
||||||
|
'invoice' => implode(',', $payment->invoices->pluck('number')->toArray()),
|
||||||
|
'amount' => array_sum(array_column($this->payment_hash->invoices(), 'amount')) + $this->payment_hash->fee_total, ]);
|
||||||
|
|
||||||
|
PaymentFailedMailer::dispatch(
|
||||||
|
$this->payment_hash,
|
||||||
|
$payment->client->company,
|
||||||
|
$payment->client,
|
||||||
|
$error
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function refund(Payment $payment, $amount, $return_client_response = false)
|
public function refund(Payment $payment, $amount, $return_client_response = false)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user