mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Adjustments for payment verifications
This commit is contained in:
parent
9846effc47
commit
86dd03d55b
@ -52,20 +52,31 @@ class PaymentIntentFailureWebhook implements ShouldQueue
|
|||||||
|
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
nlog("payment intent failed");
|
||||||
|
|
||||||
MultiDB::findAndSetDbByCompanyKey($this->company_key);
|
MultiDB::findAndSetDbByCompanyKey($this->company_key);
|
||||||
|
nlog($this->stripe_request);
|
||||||
|
|
||||||
$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) {
|
||||||
|
|
||||||
|
nlog($transaction);
|
||||||
|
|
||||||
$payment = Payment::query()
|
$payment = Payment::query()
|
||||||
->where('company_id', $company->id)
|
->where('company_id', $company->id)
|
||||||
->when(isset($transaction['payment_intent']), function ($query) use ($transaction) {
|
->where(function ($query) use ($transaction) {
|
||||||
$query->where('transaction_reference', $transaction['payment_intent']);
|
|
||||||
})
|
if(isset($transaction['payment_intent']))
|
||||||
->when(isset($transaction['id']), function ($query) use ($transaction) {
|
$query->where('transaction_reference', $transaction['payment_intent']);
|
||||||
$query->where('transaction_reference', $transaction['id']);
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
@ -65,17 +65,28 @@ class PaymentIntentProcessingWebhook implements ShouldQueue
|
|||||||
|
|
||||||
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)
|
||||||
->when(isset($transaction['payment_intent']), function ($query) use ($transaction) {
|
->where(function ($query) use ($transaction) {
|
||||||
$query->where('transaction_reference', $transaction['payment_intent']);
|
|
||||||
})
|
if(isset($transaction['payment_intent'])) {
|
||||||
->when(isset($transaction['id']), function ($query) use ($transaction) {
|
$query->where('transaction_reference', $transaction['payment_intent']);
|
||||||
$query->where('transaction_reference', $transaction['id']);
|
}
|
||||||
|
|
||||||
|
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;
|
$payment->status_id = Payment::STATUS_PENDING;
|
||||||
$payment->save();
|
$payment->save();
|
||||||
|
@ -66,15 +66,25 @@ class PaymentIntentWebhook implements ShouldQueue
|
|||||||
|
|
||||||
$payment = Payment::query()
|
$payment = Payment::query()
|
||||||
->where('company_id', $company->id)
|
->where('company_id', $company->id)
|
||||||
->when(isset($transaction['payment_intent']), function ($query) use ($transaction) {
|
->where(function ($query) use ($transaction) {
|
||||||
$query->where('transaction_reference', $transaction['payment_intent']);
|
|
||||||
})
|
if(isset($transaction['payment_intent'])) {
|
||||||
->when(isset($transaction['id']), function ($query) use ($transaction) {
|
$query->where('transaction_reference', $transaction['payment_intent']);
|
||||||
$query->where('transaction_reference', $transaction['id']);
|
}
|
||||||
|
|
||||||
|
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_COMPLETED;
|
$payment->status_id = Payment::STATUS_COMPLETED;
|
||||||
$payment->save();
|
$payment->save();
|
||||||
|
@ -706,15 +706,25 @@ class StripePaymentDriver extends BaseDriver
|
|||||||
if ($request->type === 'charge.succeeded') {
|
if ($request->type === 'charge.succeeded') {
|
||||||
foreach ($request->data as $transaction) {
|
foreach ($request->data as $transaction) {
|
||||||
|
|
||||||
$payment = Payment::query()
|
|
||||||
->where('company_id', $this->company_gateway->company_id)
|
$payment = Payment::query()
|
||||||
->when(isset($transaction['payment_intent']), function ($query) use ($transaction) {
|
->where('company_id', $this->company_gateway->company_id)
|
||||||
|
->where(function ($query) use ($transaction) {
|
||||||
|
|
||||||
|
if(isset($transaction['payment_intent'])) {
|
||||||
$query->where('transaction_reference', $transaction['payment_intent']);
|
$query->where('transaction_reference', $transaction['payment_intent']);
|
||||||
})
|
}
|
||||||
->when(isset($transaction['id']), function ($query) use ($transaction) {
|
|
||||||
|
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']);
|
$query->where('transaction_reference', $transaction['id']);
|
||||||
})
|
}
|
||||||
->first();
|
|
||||||
|
})
|
||||||
|
->first();
|
||||||
|
|
||||||
|
|
||||||
if ($payment) {
|
if ($payment) {
|
||||||
@ -743,17 +753,28 @@ class StripePaymentDriver extends BaseDriver
|
|||||||
|
|
||||||
if ($charge->captured) {
|
if ($charge->captured) {
|
||||||
|
|
||||||
|
|
||||||
$payment = Payment::query()
|
$payment = Payment::query()
|
||||||
->where('company_id', $this->company_gateway->company_id)
|
->where('company_id', $this->company_gateway->company_id)
|
||||||
->when(isset($transaction['payment_intent']), function ($query) use ($transaction) {
|
->where(function ($query) use ($transaction) {
|
||||||
$query->where('transaction_reference', $transaction['payment_intent']);
|
|
||||||
})
|
if(isset($transaction['payment_intent'])) {
|
||||||
->when(isset($transaction['id']), function ($query) use ($transaction) {
|
$query->where('transaction_reference', $transaction['payment_intent']);
|
||||||
$query->where('transaction_reference', $transaction['id']);
|
}
|
||||||
|
|
||||||
|
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_COMPLETED;
|
$payment->status_id = Payment::STATUS_COMPLETED;
|
||||||
$payment->save();
|
$payment->save();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user