mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Update Stripe to latest API with idempotency keys
This commit is contained in:
parent
7bde5690f4
commit
fd4064f4e5
@ -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());
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user