diff --git a/app/PaymentDrivers/Stripe/Klarna.php b/app/PaymentDrivers/Stripe/Klarna.php index dfafdef7a2a2..d3e2678d215c 100644 --- a/app/PaymentDrivers/Stripe/Klarna.php +++ b/app/PaymentDrivers/Stripe/Klarna.php @@ -50,7 +50,7 @@ class Klarna $invoice_numbers = collect($data['invoices'])->pluck('invoice_number'); - if ($invoice_numbers.length > 0) { + if ($invoice_numbers > 0) { $description = ctrans('texts.payment_provider_paymenttext', ['invoicenumber' => $invoice_numbers->implode(', '), 'amount' => Number::formatMoney($amount, $this->stripe->client), 'client' => $this->stripe->client->present()->name()]); } else { $description = ctrans('texts.payment_prvoder_paymenttext_without_invoice', ['amount' => Number::formatMoney($amount, $this->stripe->client), 'client' => $this->stripe->client->present()->name()]); @@ -58,15 +58,15 @@ class Klarna $intent = \Stripe\PaymentIntent::create([ 'amount' => $data['stripe_amount'], - 'currency' => 'eur', + 'currency' => $this->stripe->client->getCurrencyCode(), 'payment_method_types' => ['klarna'], 'customer' => $this->stripe->findOrCreateCustomer(), 'description' => $description, 'metadata' => [ 'payment_hash' => $this->stripe->payment_hash->hash, - 'gateway_type_id' => GatewayType::GIROPAY, + 'gateway_type_id' => GatewayType::KLARNA, ], - ], $this->stripe->stripe_connect_auth); + ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st",true)])); $data['pi_client_secret'] = $intent->client_secret; @@ -109,7 +109,7 @@ class Klarna $data = [ 'payment_method' => $payment_intent, - 'payment_type' => PaymentType::GIROPAY, + 'payment_type' => PaymentType::KLARNA, 'amount' => $this->stripe->convertFromStripeAmount($this->stripe->payment_hash->data->stripe_amount, $this->stripe->client->currency()->precision, $this->stripe->client->currency()), 'transaction_reference' => $payment_intent, 'gateway_type_id' => GatewayType::KLARNA, diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index 09926793567d..acd39347054a 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -237,9 +237,9 @@ class StripePaymentDriver extends BaseDriver } if ($this->client && $this->client->currency() - && in_array($this->client->currency()->code, ['EUR', 'USD', 'GBP', 'DKK', 'SEK', 'NOK']) + && in_array($this->client->currency()->code, ['EUR', 'DKK', 'GBP', 'NOK', 'SEK', 'USD', 'AUD', 'NZD', 'CAD', 'PLN', 'CHF']) && isset($this->client->country) - && in_array($this->client->country->iso_3166_3, ['DE', 'AT', 'BE'])) { + && in_array($this->client->country->iso_3166_3, ['AUT','BEL','DNK','FIN','FRA','DEU','IRL','ITA','NLD','NOR','ESP','SWE','GBR','USA'])) { $types[] = GatewayType::KLARNA; }