PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.15
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.15
6.2.15 6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 All 197 releases
← All changes | app/Modules/Payments/PaymentMethods/Stripe/API/ApiRequest.php +25 -11 6.2.9 → 6.2.15 View file →
@@ -122,12 +122,18 @@
122 122 */
123 123 public static function request($request, $api = 'charges', $method = 'POST')
124 124 {
125 125 $headers = self::get_headers();
126 - if ('charges' === $api && 'POST' === $method) {
126 + if ('POST' === $method && in_array($api, ['charges', 'payment_intents', 'checkout/sessions'], true)) {
127 127 $customer = !empty($request['customer']) ? $request['customer'] : '';
128 128 $source = !empty($request['source']) ? $request['source'] : $customer;
129 - $key = ArrayHelper::get($request, 'metadata.fluentform_tid') . '-' . $source . '-' . $api;
129 + $transactionId = ArrayHelper::get($request, 'metadata.transaction_id');
130 + if (!$transactionId) {
131 + $transactionId = ArrayHelper::get($request, 'payment_intent_data.metadata.transaction_id');
132 + }
133 + $key = $transactionId
134 + ? 'fluentform-' . $transactionId . '-' . $api
135 + : ArrayHelper::get($request, 'metadata.fluentform_tid') . '-' . $source . '-' . $api;
130 136 $key = apply_filters_deprecated(
131 137 'fluentform_stripe_idempotency_key',
132 138 [
133 139 $key,
@@ -151,17 +157,25 @@
151 157 'fluentform/stripe_request_body',
152 158 'Use fluentform/stripe_request_body instead of fluentform_stripe_request_body.'
153 159 );
154 160
155 - $response = wp_safe_remote_post(
156 - self::$ENDPOINT . $api,
157 - array(
158 - 'method' => $method,
159 - 'headers' => $headers,
160 - 'body' => apply_filters('fluentform/stripe_request_body', $request, $api),
161 - 'timeout' => 50,
162 - )
163 - );
161 + $requestArgs = [
162 + 'method' => $method,
163 + 'headers' => $headers,
164 + 'body' => apply_filters('fluentform/stripe_request_body', $request, $api),
165 + 'timeout' => 50,
166 + ];
167 + $response = wp_safe_remote_post(self::$ENDPOINT . $api, $requestArgs);
168 +
169 + // Stripe replays the original result for this identical idempotent request.
170 + if (
171 + 'POST' === $method &&
172 + 'payment_intents' === $api &&
173 + (is_wp_error($response) || empty($response['body']))
174 + ) {
175 + $response = wp_safe_remote_post(self::$ENDPOINT . $api, $requestArgs);
176 + }
177 +
164 178 if (is_wp_error($response) || empty($response['body'])) {
165 179 return new \WP_Error('stripe_error', __('There was a problem connecting to the Stripe API endpoint.', 'fluentform'));
166 180 }
167 181