From 5457838c4d6991f54ccf9412516a535ee026f705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 16 Nov 2020 13:37:13 +0100 Subject: [PATCH] Store 'amount' in payment hash (Stripe/CC) --- app/PaymentDrivers/Stripe/CreditCard.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/PaymentDrivers/Stripe/CreditCard.php b/app/PaymentDrivers/Stripe/CreditCard.php index 565b038207b7..6b72bee7107b 100644 --- a/app/PaymentDrivers/Stripe/CreditCard.php +++ b/app/PaymentDrivers/Stripe/CreditCard.php @@ -120,6 +120,16 @@ class CreditCard { $stripe_method = $this->stripe->getStripePaymentMethod($this->stripe->payment_hash->data->server_response->payment_method); + $data = [ + 'payment_method' => $this->stripe->payment_hash->data->server_response->payment_method, + 'payment_type' => PaymentType::parseCardType(strtolower($stripe_method->card->brand)), + 'amount' => $this->stripe->convertFromStripeAmount($this->stripe->payment_hash->data->server_response->amount, $this->stripe->client->currency()->precision), + 'transaction_reference' => $this->stripe->payment_hash->data->server_response->id, + ]; + + $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['amount' => $data['amount']]); + $this->stripe->payment_hash->save(); + if ($this->stripe->payment_hash->data->store_card) { $customer = $this->stripe->findOrCreateCustomer(); @@ -128,13 +138,6 @@ class CreditCard $this->storePaymentMethod($stripe_method, $this->stripe->payment_hash->data->payment_method_id, $customer); } - $data = [ - 'payment_method' => $this->stripe->payment_hash->data->server_response->payment_method, - 'payment_type' => PaymentType::parseCardType(strtolower($stripe_method->card->brand)), - 'amount' => $this->stripe->convertFromStripeAmount($this->stripe->payment_hash->data->server_response->amount, $this->stripe->client->currency()->precision), - 'transaction_reference' => $this->stripe->payment_hash->data->server_response->id, - ]; - $payment = $this->stripe->createPayment($data, \App\Models\Payment::STATUS_COMPLETED); SystemLogger::dispatch(