From 597cfc06627583ed2eac93f09a5e544fd54f4d9c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 6 Oct 2021 12:10:09 +1100 Subject: [PATCH] Fixes for Stripe --- app/Ninja/PaymentDrivers/BasePaymentDriver.php | 5 +++-- app/Ninja/PaymentDrivers/StripePaymentDriver.php | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Ninja/PaymentDrivers/BasePaymentDriver.php b/app/Ninja/PaymentDrivers/BasePaymentDriver.php index 00b7ec3ba149..4ff3498ba514 100644 --- a/app/Ninja/PaymentDrivers/BasePaymentDriver.php +++ b/app/Ninja/PaymentDrivers/BasePaymentDriver.php @@ -794,9 +794,10 @@ class BasePaymentDriver $payment->contact_id = $invitation->contact_id; $payment->transaction_reference = $ref; $payment->payment_date = $account->getDateTime()->format('Y-m-d'); - $payment->ip = Request::ip(); + $payment->ip = \Request::ip(); - $payment = $this->creatingPayment($payment, $paymentMethod); + //Laravel 6 upgrade - uncommented this line as it was causing a failure + // $payment = $this->creatingPayment($payment, $paymentMethod); if ($paymentMethod) { $payment->last4 = $paymentMethod->last4; diff --git a/app/Ninja/PaymentDrivers/StripePaymentDriver.php b/app/Ninja/PaymentDrivers/StripePaymentDriver.php index dbd7b15ba89b..22a17b00fe38 100644 --- a/app/Ninja/PaymentDrivers/StripePaymentDriver.php +++ b/app/Ninja/PaymentDrivers/StripePaymentDriver.php @@ -228,7 +228,6 @@ class StripePaymentDriver extends BasePaymentDriver if ( ! empty($data['payment_intent'])) { // Find the existing payment intent. $intent = PaymentIntent::retrieve($data['payment_intent']); - if ( ! $intent->amount == $data['amount'] * pow(10, $currency['precision'])) { // Make sure that the provided payment intent matches the invoice amount. throw new Exception('Incorrect PaymentIntent amount.'); @@ -270,8 +269,8 @@ class StripePaymentDriver extends BasePaymentDriver return $this->doOmnipayOnsitePurchase($data, $paymentMethod); } } - $intent = PaymentIntent::create($params); + } if (empty($intent)) { @@ -282,6 +281,7 @@ class StripePaymentDriver extends BasePaymentDriver throw new PaymentActionRequiredException(['payment_intent' => $intent]); } else if ($intent->status == 'succeeded') { $ref = ! empty($intent->charges->data) ? $intent->charges->data[0]->id : null; + $payment = $this->createPayment($ref, $paymentMethod); if ($this->invitation->invoice->account->isNinjaAccount()) { @@ -296,7 +296,6 @@ class StripePaymentDriver extends BasePaymentDriver $this->tokenResponse = $payment_method; parent::createToken(); } - return $payment; } else { throw new Exception('Invalid PaymentIntent status: ' . $intent->status);