diff --git a/app/Console/Commands/DemoMode.php b/app/Console/Commands/DemoMode.php index 20324049db61..1e01f40c16e2 100644 --- a/app/Console/Commands/DemoMode.php +++ b/app/Console/Commands/DemoMode.php @@ -83,6 +83,12 @@ class DemoMode extends Command $cached_tables = config('ninja.cached_tables'); + $this->info('Migrating'); + Artisan::call('migrate:fresh --force'); + + $this->info('Seeding'); + Artisan::call('db:seed --force'); + foreach ($cached_tables as $name => $class) { if (! Cache::has($name)) { // check that the table exists in case the migration is pending @@ -105,11 +111,7 @@ class DemoMode extends Command } } - $this->info('Migrating'); - Artisan::call('migrate:fresh --force'); - $this->info('Seeding'); - Artisan::call('db:seed --force'); $this->info('Seeding Random Data'); $this->createSmallAccount(); diff --git a/app/PaymentDrivers/Stripe/ACH.php b/app/PaymentDrivers/Stripe/ACH.php index 2a5689ccf901..cc25056ca673 100644 --- a/app/PaymentDrivers/Stripe/ACH.php +++ b/app/PaymentDrivers/Stripe/ACH.php @@ -331,7 +331,7 @@ class ACH $data = [ 'gateway_type_id' => $cgt->gateway_type_id, 'payment_type' => PaymentType::ACH, - 'transaction_reference' => $response->charges->data[0]->id, + 'transaction_reference' => isset($response->latest_charge) ? $response->latest_charge : $response->charges->data[0]->id, 'amount' => $amount, ]; diff --git a/app/PaymentDrivers/Stripe/BrowserPay.php b/app/PaymentDrivers/Stripe/BrowserPay.php index 6840421f3e28..95fd39a8503d 100644 --- a/app/PaymentDrivers/Stripe/BrowserPay.php +++ b/app/PaymentDrivers/Stripe/BrowserPay.php @@ -135,7 +135,7 @@ class BrowserPay implements MethodInterface 'payment_method' => $gateway_response->payment_method, 'payment_type' => PaymentType::parseCardType(strtolower($payment_method->card->brand)), 'amount' => $this->stripe->convertFromStripeAmount($gateway_response->amount, $this->stripe->client->currency()->precision, $this->stripe->client->currency()), - 'transaction_reference' => optional($payment_intent->charges->data[0])->id, + 'transaction_reference' => isset($payment_intent->latest_charge) ? $payment_intent->latest_charge : $payment_intent->charges->data[0]->id, 'gateway_type_id' => GatewayType::APPLE_PAY, ]; diff --git a/app/PaymentDrivers/Stripe/Charge.php b/app/PaymentDrivers/Stripe/Charge.php index 691f6ca5bb13..0c781c09ec4d 100644 --- a/app/PaymentDrivers/Stripe/Charge.php +++ b/app/PaymentDrivers/Stripe/Charge.php @@ -144,17 +144,16 @@ class Charge $payment_method_type = $response->charges->data[0]->payment_method_details->card->brand; $status = Payment::STATUS_COMPLETED; } - - if($response?->status == 'processing'){ - //allows us to jump over the next stage - used for SEPA - }elseif($response?->status != 'succeeded'){ + + if(!in_array($response?->status, ['succeeded', 'processing'])){ $this->stripe->processInternallyFailedPayment($this->stripe, new \Exception('Auto billing failed.',400)); } $data = [ 'gateway_type_id' => $cgt->gateway_type_id, 'payment_type' => $this->transformPaymentTypeToConstant($payment_method_type), - 'transaction_reference' => $response->charges->data[0]->id, + 'transaction_reference' => isset($response->latest_charge) ? $response->latest_charge : $response->charges->data[0]->id, + // 'transaction_reference' => $response->charges->data[0]->id, 'amount' => $amount, ]; diff --git a/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php b/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php index d7cab34fab4e..1caf382e567f 100644 --- a/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php +++ b/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php @@ -267,6 +267,39 @@ class PaymentIntentWebhook implements ShouldQueue } } + // private function updateSepaPayment($payment_hash, $client, $meta) + // { + + // $company_gateway = CompanyGateway::find($this->company_gateway_id); + // $payment_method_type = GatewayType::SEPA; + // $driver = $company_gateway->driver($client)->init()->setPaymentMethod($payment_method_type); + + // $payment_hash->data = array_merge((array) $payment_hash->data, $this->stripe_request); + // $payment_hash->save(); + // $driver->setPaymentHash($payment_hash); + + // $data = [ + // 'payment_method' => $payment_hash->data->object->payment_method, + // 'payment_type' => PaymentType::parseCardType(strtolower($meta['card_details'])) ?: PaymentType::CREDIT_CARD_OTHER, + // 'amount' => $payment_hash->data->amount_with_fee, + // 'transaction_reference' => $meta['transaction_reference'], + // 'gateway_type_id' => GatewayType::CREDIT_CARD, + // ]; + + // $payment = $driver->createPayment($data, Payment::STATUS_COMPLETED); + + // SystemLogger::dispatch( + // ['response' => $this->stripe_request, 'data' => $data], + // SystemLog::CATEGORY_GATEWAY_RESPONSE, + // SystemLog::EVENT_GATEWAY_SUCCESS, + // SystemLog::TYPE_STRIPE, + // $client, + // $client->company, + // ); + + + // } + private function updateCreditCardPayment($payment_hash, $client, $meta) {