diff --git a/app/PaymentDrivers/Stripe/BankTransfer.php b/app/PaymentDrivers/Stripe/BankTransfer.php index 29b83c6c9a..ac655dfe10 100644 --- a/app/PaymentDrivers/Stripe/BankTransfer.php +++ b/app/PaymentDrivers/Stripe/BankTransfer.php @@ -68,7 +68,7 @@ class BankTransfer $data['return_url'] = $this->buildReturnUrl(); $data['gateway'] = $this->stripe; $data['client_secret'] = $intent ? $intent->client_secret : false; - + return render('gateways.stripe.bank_transfer.pay', $data); } @@ -124,31 +124,45 @@ class BankTransfer } /* Create a pending payment */ - if($pi->status == 'requires_action') { + if($pi->status == 'requires_action' && $pi->next_action->type == 'display_bank_transfer_instructions') { $data = [ - 'payment_method' => $pi->payment_method, - 'payment_type' => PaymentType::DIRECT_DEBIT, 'amount' => $this->stripe->convertFromStripeAmount($this->stripe->payment_hash->data->stripe_amount, $this->stripe->client->currency()->precision, $this->stripe->client->currency()), - 'transaction_reference' => $pi->id, - 'gateway_type_id' => GatewayType::DIRECT_DEBIT, + 'account_holder_name' => $pi->next_action->display_bank_transfer_instructions->financial_addresses[0]->account_holder_name, + 'account_number' => $pi->next_action->display_bank_transfer_instructions->financial_addresses[0]->account_number, + 'sort_code' => $pi->next_action->display_bank_transfer_instructions->financial_addresses[0]->sort_code, + 'reference' => $pi->next_action->display_bank_transfer_instructions->reference, + 'descripton' => $pi->description, + 'gateway' => $this->stripe->company_gateway, ]; - $payment = $this->stripe->createPayment($data, Payment::STATUS_PENDING); + return render('gateways.stripe.bank_transfer.bank_details', $data); - SystemLogger::dispatch( - ['response' => $this->stripe->payment_hash->data, 'data' => $data], - SystemLog::CATEGORY_GATEWAY_RESPONSE, - SystemLog::EVENT_GATEWAY_SUCCESS, - SystemLog::TYPE_STRIPE, - $this->stripe->client, - $this->stripe->client->company, - ); + // $data = [ + // 'payment_method' => $pi->payment_method, + // 'payment_type' => PaymentType::DIRECT_DEBIT, + // 'amount' => $this->stripe->convertFromStripeAmount($this->stripe->payment_hash->data->stripe_amount, $this->stripe->client->currency()->precision, $this->stripe->client->currency()), + // 'transaction_reference' => $pi->id, + // 'gateway_type_id' => GatewayType::DIRECT_DEBIT, - return redirect($pi->next_action->display_bank_transfer_instructions->hosted_instructions_url); + // ]; + + // $payment = $this->stripe->createPayment($data, Payment::STATUS_PENDING); + + // SystemLogger::dispatch( + // ['response' => $this->stripe->payment_hash->data, 'data' => $data], + // SystemLog::CATEGORY_GATEWAY_RESPONSE, + // SystemLog::EVENT_GATEWAY_SUCCESS, + // SystemLog::TYPE_STRIPE, + // $this->stripe->client, + // $this->stripe->client->company, + // ); + + // return redirect($pi->next_action->display_bank_transfer_instructions->hosted_instructions_url); } + return $this->processUnsuccesfulRedirect(); } diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index f714c7f095..0f31bc45a5 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -260,7 +260,12 @@ class StripePaymentDriver extends BaseDriver if ( $this->client && isset($this->client->country) - && in_array($this->client->country->iso_3166_2, ['FR', 'IE', 'NL', 'GB', 'DE', 'ES', 'JP', 'MX']) + && ( + (in_array($this->client->country->iso_3166_2, ['FR', 'IE', 'NL', 'DE', 'ES']) && $this->client->currency()->code == 'EUR') || + ($this->client->country->iso_3166_2 == 'JP' && $this->client->currency()->code == 'JPY') || + ($this->client->country->iso_3166_2 == 'MX' && $this->client->currency()->code == 'MXN') || + ($this->client->country->iso_3166_2 == 'GB' && $this->client->currency()->code == 'GBP') + ) ) { $types[] = GatewayType::DIRECT_DEBIT; }