1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Merge pull request #8118 from paulwer/v5-develop

adding update_payment webhook
This commit is contained in:
David Bomba 2023-01-09 09:59:29 +11:00 committed by GitHub
commit 5dfd3206c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -78,6 +78,8 @@ class Webhook extends BaseModel
const EVENT_PROJECT_DELETE = 30;
const EVENT_UPDATE_PAYMENT = 31;
public static $valid_events = [
self::EVENT_CREATE_CLIENT,
@ -109,7 +111,8 @@ class Webhook extends BaseModel
self::EVENT_CREATE_CREDIT,
self::EVENT_UPDATE_CREDIT,
self::EVENT_DELETE_CREDIT,
self::EVENT_PROJECT_DELETE
self::EVENT_PROJECT_DELETE,
self::EVENT_UPDATE_PAYMENT
];
protected $fillable = [

View File

@ -42,6 +42,13 @@ class PaymentObserver
*/
public function updated(Payment $payment)
{
$subscriptions = Webhook::where('company_id', $payment->company->id)
->where('event_id', Webhook::EVENT_UPDATE_PAYMENT)
->exists();
if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_UPDATE_PAYMENT, $payment, $payment->company, 'invoices,client')->delay(now()->addSeconds(20));
}
}
/**