mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 13:54:34 -04:00
Fixes for Payment Webhooks
This commit is contained in:
parent
384642acde
commit
c26afd69e2
@ -114,7 +114,7 @@ class PaymentController extends Controller
|
|||||||
} else {
|
} else {
|
||||||
$payment = PaymentFactory::create($payment_hash->fee_invoice->company_id, $payment_hash->fee_invoice->user_id);
|
$payment = PaymentFactory::create($payment_hash->fee_invoice->company_id, $payment_hash->fee_invoice->user_id);
|
||||||
$payment->client_id = $payment_hash->fee_invoice->client_id;
|
$payment->client_id = $payment_hash->fee_invoice->client_id;
|
||||||
$payment->save();
|
$payment->saveQuietly();
|
||||||
|
|
||||||
$payment_hash->payment_id = $payment->id;
|
$payment_hash->payment_id = $payment->id;
|
||||||
$payment_hash->save();
|
$payment_hash->save();
|
||||||
@ -122,6 +122,8 @@ class PaymentController extends Controller
|
|||||||
|
|
||||||
$payment = $payment->service()->applyCredits($payment_hash)->save();
|
$payment = $payment->service()->applyCredits($payment_hash)->save();
|
||||||
|
|
||||||
|
event('eloquent.created: App\Models\Payment', $payment);
|
||||||
|
|
||||||
if (property_exists($payment_hash->data, 'billing_context')) {
|
if (property_exists($payment_hash->data, 'billing_context')) {
|
||||||
$billing_subscription = \App\Models\Subscription::find($payment_hash->data->billing_context->subscription_id);
|
$billing_subscription = \App\Models\Subscription::find($payment_hash->data->billing_context->subscription_id);
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ class BaseDriver extends AbstractPaymentDriver
|
|||||||
$payment->type_id = $data['payment_type'];
|
$payment->type_id = $data['payment_type'];
|
||||||
$payment->transaction_reference = $data['transaction_reference'];
|
$payment->transaction_reference = $data['transaction_reference'];
|
||||||
$payment->client_contact_id = $client_contact_id;
|
$payment->client_contact_id = $client_contact_id;
|
||||||
$payment->save();
|
$payment->saveQuietly();
|
||||||
|
|
||||||
$this->payment_hash->payment_id = $payment->id;
|
$this->payment_hash->payment_id = $payment->id;
|
||||||
$this->payment_hash->save();
|
$this->payment_hash->save();
|
||||||
@ -248,6 +248,8 @@ class BaseDriver extends AbstractPaymentDriver
|
|||||||
|
|
||||||
$payment->service()->updateInvoicePayment($this->payment_hash);
|
$payment->service()->updateInvoicePayment($this->payment_hash);
|
||||||
|
|
||||||
|
event('eloquent.created: App\Models\Payment', $payment);
|
||||||
|
|
||||||
if ($this->client->getSetting('client_online_payment_notification'))
|
if ($this->client->getSetting('client_online_payment_notification'))
|
||||||
$payment->service()->sendEmail();
|
$payment->service()->sendEmail();
|
||||||
|
|
||||||
@ -392,11 +394,9 @@ class BaseDriver extends AbstractPaymentDriver
|
|||||||
|
|
||||||
public function clientPaymentFailureMailer($error)
|
public function clientPaymentFailureMailer($error)
|
||||||
{
|
{
|
||||||
nlog("outside");
|
|
||||||
|
|
||||||
if ($this->payment_hash && is_array($this->payment_hash->invoices())) {
|
if ($this->payment_hash && is_array($this->payment_hash->invoices())) {
|
||||||
|
|
||||||
nlog("inside");
|
|
||||||
|
|
||||||
$nmo = new NinjaMailerObject;
|
$nmo = new NinjaMailerObject;
|
||||||
$nmo->mailable = new NinjaMailer((new ClientPaymentFailureObject($this->client, $error, $this->client->company, $this->payment_hash))->build());
|
$nmo->mailable = new NinjaMailer((new ClientPaymentFailureObject($this->client, $error, $this->client->company, $this->payment_hash))->build());
|
||||||
|
@ -273,7 +273,9 @@ class BasePaymentDriver
|
|||||||
$paid_invoices = $payment_hash->invoices();
|
$paid_invoices = $payment_hash->invoices();
|
||||||
$invoices = Invoice::whereIn('id', $this->transformKeys(array_column($paid_invoices, 'invoice_id')))->withTrashed()->get();
|
$invoices = Invoice::whereIn('id', $this->transformKeys(array_column($paid_invoices, 'invoice_id')))->withTrashed()->get();
|
||||||
$payment->invoices()->sync($invoices);
|
$payment->invoices()->sync($invoices);
|
||||||
$payment->save();
|
$payment->saveQuietly();
|
||||||
|
|
||||||
|
event('eloquent.created: App\Models\Payment', $payment);
|
||||||
|
|
||||||
return $payment;
|
return $payment;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ class ApplyPaymentAmount extends AbstractService
|
|||||||
$payment->currency_id = $this->invoice->client->getSetting('currency_id');
|
$payment->currency_id = $this->invoice->client->getSetting('currency_id');
|
||||||
$payment->is_manual = true;
|
$payment->is_manual = true;
|
||||||
/* Create a payment relationship to the invoice entity */
|
/* Create a payment relationship to the invoice entity */
|
||||||
$payment->save();
|
$payment->saveQuietly();
|
||||||
|
|
||||||
$this->setExchangeRate($payment);
|
$this->setExchangeRate($payment);
|
||||||
|
|
||||||
@ -103,6 +103,8 @@ class ApplyPaymentAmount extends AbstractService
|
|||||||
|
|
||||||
$this->invoice->service()->workFlow()->save();
|
$this->invoice->service()->workFlow()->save();
|
||||||
|
|
||||||
|
event('eloquent.created: App\Models\Payment', $payment);
|
||||||
|
|
||||||
return $this->invoice;
|
return $this->invoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +122,7 @@ class ApplyPaymentAmount extends AbstractService
|
|||||||
//$payment->exchange_currency_id = $client_currency; // 23/06/2021
|
//$payment->exchange_currency_id = $client_currency; // 23/06/2021
|
||||||
$payment->exchange_currency_id = $company_currency;
|
$payment->exchange_currency_id = $company_currency;
|
||||||
|
|
||||||
$payment->save();
|
$payment->saveQuietly();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,6 +175,8 @@ class AutoBillInvoice extends AbstractService
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event('eloquent.created: App\Models\Payment', $payment);
|
||||||
|
|
||||||
$payment->ledger()
|
$payment->ledger()
|
||||||
->updatePaymentBalance($amount * -1)
|
->updatePaymentBalance($amount * -1)
|
||||||
->save();
|
->save();
|
||||||
@ -190,6 +192,7 @@ class AutoBillInvoice extends AbstractService
|
|||||||
->updateCreditBalance($amount * -1, "Credit {$current_credit->number} used to pay down Invoice {$this->invoice->number}")
|
->updateCreditBalance($amount * -1, "Credit {$current_credit->number} used to pay down Invoice {$this->invoice->number}")
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
|
|
||||||
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars()));
|
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars()));
|
||||||
|
|
||||||
return $this->invoice
|
return $this->invoice
|
||||||
|
@ -64,7 +64,7 @@ class MarkPaid extends AbstractService
|
|||||||
if((int)$payment_type_id > 0)
|
if((int)$payment_type_id > 0)
|
||||||
$payment->type_id = (int)$payment_type_id;
|
$payment->type_id = (int)$payment_type_id;
|
||||||
|
|
||||||
$payment->save();
|
$payment->saveQuietly();
|
||||||
|
|
||||||
$this->setExchangeRate($payment);
|
$this->setExchangeRate($payment);
|
||||||
|
|
||||||
@ -73,6 +73,8 @@ class MarkPaid extends AbstractService
|
|||||||
'amount' => $payment->amount,
|
'amount' => $payment->amount,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
event('eloquent.created: App\Models\Payment', $payment);
|
||||||
|
|
||||||
$this->invoice->next_send_date = null;
|
$this->invoice->next_send_date = null;
|
||||||
|
|
||||||
$this->invoice->service()
|
$this->invoice->service()
|
||||||
|
@ -39,12 +39,14 @@ class PaymentService
|
|||||||
$payment->transaction_reference = ctrans('texts.manual_entry');
|
$payment->transaction_reference = ctrans('texts.manual_entry');
|
||||||
$payment->currency_id = $invoice->client->getSetting('currency_id');
|
$payment->currency_id = $invoice->client->getSetting('currency_id');
|
||||||
/* Create a payment relationship to the invoice entity */
|
/* Create a payment relationship to the invoice entity */
|
||||||
$payment->save();
|
$payment->saveQuietly();
|
||||||
|
|
||||||
$payment->invoices()->attach($invoice->id, [
|
$payment->invoices()->attach($invoice->id, [
|
||||||
'amount' => $payment->amount,
|
'amount' => $payment->amount,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
event('eloquent.created: App\Models\Payment', $payment);
|
||||||
|
|
||||||
return $payment;
|
return $payment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +147,7 @@ class PaymentService
|
|||||||
|
|
||||||
public function save()
|
public function save()
|
||||||
{
|
{
|
||||||
$this->payment->save();
|
$this->payment->saveQuietly();
|
||||||
|
|
||||||
return $this->payment->fresh();
|
return $this->payment->fresh();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user