From ceab20b82909d87e45d24e04f3b2595093b000f2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 4 Dec 2021 22:50:12 +1100 Subject: [PATCH] Fixes for mollie webhooks --- app/PaymentDrivers/BaseDriver.php | 5 +++-- app/PaymentDrivers/MolliePaymentDriver.php | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 82121041c081..16519fd1d531 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -263,12 +263,13 @@ class BaseDriver extends AbstractPaymentDriver event('eloquent.created: App\Models\Payment', $payment); - if ($this->client->getSetting('client_online_payment_notification')) + if ($this->client->getSetting('client_online_payment_notification') && in_array($status, [Payment::STATUS_COMPLETED, Payment::STATUS_PENDING + ])) $payment->service()->sendEmail(); event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars())); - if (property_exists($this->payment_hash->data, 'billing_context')) { + if (property_exists($this->payment_hash->data, 'billing_context') && $status == Payment::STATUS_COMPLETED) { $billing_subscription = \App\Models\Subscription::find($this->payment_hash->data->billing_context->subscription_id); // To access campaign hash => $this->payment_hash->data->billing_context->campaign; diff --git a/app/PaymentDrivers/MolliePaymentDriver.php b/app/PaymentDrivers/MolliePaymentDriver.php index 3c6f785d39b5..8f4c72b39832 100644 --- a/app/PaymentDrivers/MolliePaymentDriver.php +++ b/app/PaymentDrivers/MolliePaymentDriver.php @@ -324,19 +324,18 @@ class MolliePaymentDriver extends BaseDriver /* Harvest Payment Hash*/ $payment_hash = PaymentHash::where('hash', $payment->metadata->hash)->first(); - $data = [ 'gateway_type_id' => $payment->metadata->gateway_type_id, 'amount' => $amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total, 'payment_type' => $payment->metadata->payment_type_id, 'transaction_reference' => $payment->id, ]; - + $record = $this->createPayment( $data, $codes[$payment->status] ); - + } }