diff --git a/app/PaymentDrivers/Stripe/ACH.php b/app/PaymentDrivers/Stripe/ACH.php index 517022afcb82..5a5d893dfeb0 100644 --- a/app/PaymentDrivers/Stripe/ACH.php +++ b/app/PaymentDrivers/Stripe/ACH.php @@ -69,7 +69,7 @@ class ACH $customer = $this->stripe->findOrCreateCustomer(); try { - $source = Customer::createSource($customer->id, ['source' => $stripe_response->token->id], $this->stripe->stripe_connect_auth); + $source = Customer::createSource($customer->id, ['source' => $stripe_response->token->id], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st",true)])); } catch (InvalidRequestException $e) { throw new PaymentFailed($e->getMessage(), $e->getCode()); } diff --git a/app/PaymentDrivers/Stripe/ACSS.php b/app/PaymentDrivers/Stripe/ACSS.php index e9255b3bbbae..ecbf7bee19cf 100644 --- a/app/PaymentDrivers/Stripe/ACSS.php +++ b/app/PaymentDrivers/Stripe/ACSS.php @@ -55,7 +55,7 @@ class ACSS $customer = $this->stripe->findOrCreateCustomer(); try { - $source = Customer::createSource($customer->id, ['source' => $stripe_response->token->id], $this->stripe->stripe_connect_auth); + $source = Customer::createSource($customer->id, ['source' => $stripe_response->token->id], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st",true)])); } catch (InvalidRequestException $e) { throw new PaymentFailed($e->getMessage(), $e->getCode()); } diff --git a/app/PaymentDrivers/Stripe/BECS.php b/app/PaymentDrivers/Stripe/BECS.php index 942135eca767..40d1864cfb31 100644 --- a/app/PaymentDrivers/Stripe/BECS.php +++ b/app/PaymentDrivers/Stripe/BECS.php @@ -60,7 +60,7 @@ class BECS 'payment_hash' => $this->stripe->payment_hash->hash, 'gateway_type_id' => GatewayType::BECS, ], - ], $this->stripe->stripe_connect_auth); + ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st",true)])); $data['pi_client_secret'] = $intent->client_secret; diff --git a/app/PaymentDrivers/Stripe/Bancontact.php b/app/PaymentDrivers/Stripe/Bancontact.php index ae58f1b504ed..7bf2504301ad 100644 --- a/app/PaymentDrivers/Stripe/Bancontact.php +++ b/app/PaymentDrivers/Stripe/Bancontact.php @@ -57,7 +57,7 @@ class Bancontact 'gateway_type_id' => GatewayType::BANCONTACT, ], - ], $this->stripe->stripe_connect_auth); + ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st",true)])); $data['pi_client_secret'] = $intent->client_secret; diff --git a/app/PaymentDrivers/Stripe/Charge.php b/app/PaymentDrivers/Stripe/Charge.php index 467a87fad651..b0e5f1a17ce9 100644 --- a/app/PaymentDrivers/Stripe/Charge.php +++ b/app/PaymentDrivers/Stripe/Charge.php @@ -96,7 +96,7 @@ class Charge $data['off_session'] = true; } - $response = $this->stripe->createPaymentIntent($data, $this->stripe->stripe_connect_auth); + $response = $this->stripe->createPaymentIntent($data, array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st",true)])); SystemLogger::dispatch($response, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::TYPE_STRIPE, $this->stripe->client, $this->stripe->client->company); } catch (\Exception $e) { diff --git a/app/PaymentDrivers/Stripe/CreditCard.php b/app/PaymentDrivers/Stripe/CreditCard.php index 64b9df528317..e9bba8bd26e9 100644 --- a/app/PaymentDrivers/Stripe/CreditCard.php +++ b/app/PaymentDrivers/Stripe/CreditCard.php @@ -112,7 +112,7 @@ class CreditCard $state['store_card'] = false; } - $state['payment_intent'] = PaymentIntent::retrieve($state['server_response']->id, $this->stripe->stripe_connect_auth); + $state['payment_intent'] = PaymentIntent::retrieve($state['server_response']->id, array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st",true)])); $state['customer'] = $state['payment_intent']->customer; $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, $state); diff --git a/app/PaymentDrivers/Stripe/EPS.php b/app/PaymentDrivers/Stripe/EPS.php index 6a9b6a56e2f8..d9abbc4567ac 100644 --- a/app/PaymentDrivers/Stripe/EPS.php +++ b/app/PaymentDrivers/Stripe/EPS.php @@ -56,7 +56,7 @@ class EPS 'payment_hash' => $this->stripe->payment_hash->hash, 'gateway_type_id' => GatewayType::EPS, ], - ], $this->stripe->stripe_connect_auth); + ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st",true)])); $data['pi_client_secret'] = $intent->client_secret; diff --git a/app/PaymentDrivers/Stripe/FPX.php b/app/PaymentDrivers/Stripe/FPX.php index 914442e1edd8..de1a31e12fbb 100644 --- a/app/PaymentDrivers/Stripe/FPX.php +++ b/app/PaymentDrivers/Stripe/FPX.php @@ -57,7 +57,7 @@ class FPX 'payment_hash' => $this->stripe->payment_hash->hash, 'gateway_type_id' => GatewayType::FPX, ], - ], $this->stripe->stripe_connect_auth); + ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st",true)])); $data['pi_client_secret'] = $intent->client_secret; diff --git a/app/PaymentDrivers/Stripe/GIROPAY.php b/app/PaymentDrivers/Stripe/GIROPAY.php index 8655eec5f2fe..f726ee3c91a8 100644 --- a/app/PaymentDrivers/Stripe/GIROPAY.php +++ b/app/PaymentDrivers/Stripe/GIROPAY.php @@ -56,7 +56,7 @@ class GIROPAY 'payment_hash' => $this->stripe->payment_hash->hash, 'gateway_type_id' => GatewayType::GIROPAY, ], - ], $this->stripe->stripe_connect_auth); + ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st",true)])); $data['pi_client_secret'] = $intent->client_secret; diff --git a/app/PaymentDrivers/Stripe/PRZELEWY24.php b/app/PaymentDrivers/Stripe/PRZELEWY24.php index 71264afc58b9..ca15c1aa7a68 100644 --- a/app/PaymentDrivers/Stripe/PRZELEWY24.php +++ b/app/PaymentDrivers/Stripe/PRZELEWY24.php @@ -56,7 +56,7 @@ class PRZELEWY24 'payment_hash' => $this->stripe->payment_hash->hash, 'gateway_type_id' => GatewayType::PRZELEWY24, ], - ], $this->stripe->stripe_connect_auth); + ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st",true)])); $data['pi_client_secret'] = $intent->client_secret; diff --git a/app/PaymentDrivers/Stripe/SEPA.php b/app/PaymentDrivers/Stripe/SEPA.php index 0b817b8146ae..53af6f9e582c 100644 --- a/app/PaymentDrivers/Stripe/SEPA.php +++ b/app/PaymentDrivers/Stripe/SEPA.php @@ -67,7 +67,7 @@ class SEPA ], ]; - $intent = \Stripe\PaymentIntent::create($intent_data, $this->stripe->stripe_connect_auth); + $intent = \Stripe\PaymentIntent::create($intent_data, array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st",true)])); $data['pi_client_secret'] = $intent->client_secret; diff --git a/app/PaymentDrivers/Stripe/SOFORT.php b/app/PaymentDrivers/Stripe/SOFORT.php index 54ed593dcdd4..cb348ac8fb1f 100644 --- a/app/PaymentDrivers/Stripe/SOFORT.php +++ b/app/PaymentDrivers/Stripe/SOFORT.php @@ -56,7 +56,7 @@ class SOFORT 'payment_hash' => $this->stripe->payment_hash->hash, 'gateway_type_id' => GatewayType::SOFORT, ], - ], $this->stripe->stripe_connect_auth); + ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st",true)])); $data['pi_client_secret'] = $intent->client_secret; diff --git a/app/PaymentDrivers/Stripe/iDeal.php b/app/PaymentDrivers/Stripe/iDeal.php index 3abed0380f42..61fb90540d05 100644 --- a/app/PaymentDrivers/Stripe/iDeal.php +++ b/app/PaymentDrivers/Stripe/iDeal.php @@ -56,7 +56,7 @@ class iDeal 'payment_hash' => $this->stripe->payment_hash->hash, 'gateway_type_id' => GatewayType::IDEAL, ], - ], $this->stripe->stripe_connect_auth); + ], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st",true)])); $data['pi_client_secret'] = $intent->client_secret; diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index b0d5751e539a..178ce44bbb59 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -122,7 +122,7 @@ class StripePaymentDriver extends BaseDriver ); Stripe::setApiKey($this->company_gateway->getConfigField('apiKey')); - // Stripe::setApiVersion('2022-11-15'); + Stripe::setApiVersion('2022-11-15'); } @@ -387,7 +387,7 @@ class StripePaymentDriver extends BaseDriver $meta = $this->stripe_connect_auth; - return PaymentIntent::create($data, $meta); + return PaymentIntent::create($data, array_merge($meta, ['idempotency_key' => uniqid("st",true)])); } /** @@ -404,7 +404,7 @@ class StripePaymentDriver extends BaseDriver $params = ['usage' => 'off_session']; $meta = $this->stripe_connect_auth; - return SetupIntent::create($params, $meta); + return SetupIntent::create($params, array_merge($meta, ['idempotency_key' => uniqid("st",true)])); } /** @@ -481,7 +481,7 @@ class StripePaymentDriver extends BaseDriver $data['address']['state'] = $this->client->state; $data['address']['country'] = $this->client->country ? $this->client->country->iso_3166_2 : ''; - $customer = Customer::create($data, $this->stripe_connect_auth); + $customer = Customer::create($data, array_merge($this->stripe_connect_auth, ['idempotency_key' => uniqid("st",true)])); if (! $customer) { throw new Exception('Unable to create gateway customer');