Minor fixes for Stripe connect webhooks

This commit is contained in:
David Bomba 2022-05-14 07:54:19 +10:00
parent 0c55a9968d
commit 3b6a4b7538
2 changed files with 9 additions and 2 deletions

View File

@ -131,7 +131,7 @@ class NinjaMailerJob implements ShouldQueue
$response = $e->getResponse(); $response = $e->getResponse();
$message_body = json_decode($response->getBody()->getContents()); $message_body = json_decode($response->getBody()->getContents());
if(property_exists($message_body, 'Message')){ if($message_body && property_exists($message_body, 'Message')){
$message = $message_body->Message; $message = $message_body->Message;
nlog($message); nlog($message);
} }
@ -268,9 +268,10 @@ class NinjaMailerJob implements ShouldQueue
return false; return false;
/* On the hosted platform, if the user is over the email quotas, we do not send the email. */ /* On the hosted platform, if the user is over the email quotas, we do not send the email. */
if(Ninja::isHosted() && $this->company->account->emailQuotaExceeded()) if(Ninja::isHosted() && $this->company->account && $this->company->account->emailQuotaExceeded())
return true; return true;
/* Ensure the user has a valid email address */
if(!str_contains($this->nmo->to_user->email, "@")) if(!str_contains($this->nmo->to_user->email, "@"))
return true; return true;

View File

@ -601,9 +601,14 @@ class StripePaymentDriver extends BaseDriver
} }
} elseif ($request->type === 'source.chargeable') { } elseif ($request->type === 'source.chargeable') {
$this->init(); $this->init();
foreach ($request->data as $transaction) { foreach ($request->data as $transaction) {
if(!$request->data['object']['amount'] || empty($request->data['object']['amount']))
continue;
$charge = \Stripe\Charge::create([ $charge = \Stripe\Charge::create([
'amount' => $request->data['object']['amount'], 'amount' => $request->data['object']['amount'],
'currency' => $request->data['object']['currency'], 'currency' => $request->data['object']['currency'],
@ -619,6 +624,7 @@ class StripePaymentDriver extends BaseDriver
->orWhere('transaction_reference', $transaction['id']); ->orWhere('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();