Minor adjustments for webhooks

This commit is contained in:
David Bomba 2024-08-06 14:04:03 +10:00
parent 7acb369408
commit 7c6732e896

View File

@ -59,38 +59,22 @@ class PaymentIntentProcessingWebhook implements ShouldQueue
/* Stub processing payment intents with a pending payment */ /* Stub processing payment intents with a pending payment */
public function handle() public function handle()
{ {
nlog($this->stripe_request);
// The first payment will always be a PI payment - subsequent are PY
MultiDB::findAndSetDbByCompanyKey($this->company_key); MultiDB::findAndSetDbByCompanyKey($this->company_key);
$company = Company::query()->where('company_key', $this->company_key)->first(); $company = Company::query()->where('company_key', $this->company_key)->first();
foreach ($this->stripe_request as $transaction) { foreach ($this->stripe_request as $transaction) {
$payment = Payment::query() $payment = Payment::query()
->where('company_id', $company->id) ->where('company_id', $company->id)
->where(function ($query) use ($transaction) { ->where('transaction_reference', $transaction['id'])
if(isset($transaction['payment_intent'])) {
$query->where('transaction_reference', $transaction['payment_intent']);
}
if(isset($transaction['payment_intent']) && isset($transaction['id'])) {
$query->orWhere('transaction_reference', $transaction['id']);
}
if(!isset($transaction['payment_intent']) && isset($transaction['id'])) {
$query->where('transaction_reference', $transaction['id']);
}
})
->first(); ->first();
if ($payment) { if ($payment) {
$payment->status_id = Payment::STATUS_PENDING; nlog("found payment");
$payment->save();
$this->payment_completed = true; $this->payment_completed = true;
} }