Add event to process webhook payments

This commit is contained in:
2023-05-13 23:51:27 +10:00
parent 12b63a506f
commit c1bb20dec0
6 changed files with 97 additions and 5 deletions

View File

@@ -9,9 +9,10 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use App\Models\{Account,Invoice,Payment,PaymentItem,ProviderToken};
use App\Models\{Account,Invoice,Payment,PaymentItem,ProviderToken,Site};
use Intuit\Models\Payment as PaymentModel;
/**
@@ -49,6 +50,10 @@ class AccountingPaymentSync implements ShouldQueue
*/
public function handle()
{
// @todo Can this be automatically determined?
$site = Site::findOrFail($this->to->site_id);
Config::set('site',$site);
// See if we are already linked
if (($x=$this->to->provider->payments->where('pivot.ref',$this->pmi->id))->count() === 1) {
$o = $x->pop();