PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.5
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.5
1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk All 48 releases
← All changes | app/Modules/PaymentMethods/StripeGateway/SubscriptionsManager.php +10 -7 1.3.25 → 1.6.5 View file →
@@ -3,9 +3,8 @@
3 3 namespace FluentCart\App\Modules\PaymentMethods\StripeGateway;
4 4
5 5 use FluentCart\App\Events\Subscription\SubscriptionActivated;
6 6 use FluentCart\App\Helpers\Status;
7 -use FluentCart\App\Models\OrderTransaction;
8 7 use FluentCart\App\Models\Subscription;
9 8 use FluentCart\App\Models\SubscriptionMeta;
10 9 use FluentCart\App\Modules\PaymentMethods\StripeGateway\API\API;
11 10 use FluentCart\App\Services\DateTime\DateTime;
@@ -77,17 +76,21 @@
77 76 }
78 77
79 78 /**
80 79 * Check rate limit for SetupIntent creation to prevent card testing fraud.
81 - *
82 - * Rate limit: 3 attempts per day per customer (for subscription card updates)
83 - *
80 + *
81 + * Rate limit: 5 attempts per day per customer by default (for subscription
82 + * card updates), overridable via the
83 + * fluent_cart/stripe/setup_intent_rate_limit_customer_daily filter. The SAME
84 + * filter default feeds getRemainingRateLimit(), so enforcement and the
85 + * displayed remaining count share one contract.
86 + *
84 87 * @param string $customerId Stripe customer ID
85 88 * @return bool|\WP_Error Returns true if allowed, WP_Error if rate limited
86 89 */
87 90 protected static function checkRateLimit($customerId)
88 91 {
89 - $customerDailyLimit = apply_filters('fluent_cart/stripe/setup_intent_rate_limit_customer_daily', 3, $customerId);
92 + $customerDailyLimit = apply_filters('fluent_cart/stripe/setup_intent_rate_limit_customer_daily', 5, $customerId);
90 93
91 94 $customerDailyKey = 'fct_stripe_setup_intent_rate_daily_' . md5($customerId);
92 95 $customerDailyAttempts = get_transient($customerDailyKey) ?: 0;
93 96
@@ -101,9 +104,9 @@
101 104 }
102 105
103 106 public function getRemainingRateLimit($customerId)
104 107 {
105 - $customerDailyLimit = apply_filters('fluent_cart/stripe/setup_intent_rate_limit_customer_daily', 3, $customerId);
108 + $customerDailyLimit = apply_filters('fluent_cart/stripe/setup_intent_rate_limit_customer_daily', 5, $customerId);
106 109 $customerDailyKey = 'fct_stripe_setup_intent_rate_daily_' . md5($customerId);
107 110 $customerDailyAttempts = get_transient($customerDailyKey) ?: 0;
108 111 return $customerDailyLimit - $customerDailyAttempts;
109 112 }
@@ -213,9 +216,9 @@
213 216 $nextBillingDate = gmdate('Y-m-d H:i:s', (int) $nextBillingDate);
214 217 }
215 218
216 219 $status = StripeHelper::transformSubscriptionStatus($response, $subscription);
217 - $billCount = OrderTransaction::query()->where('subscription_id', $subscription->id)->count();
220 + $billCount = $subscription->calculateBillCount();
218 221
219 222 $oldStatus = $subscription->status;
220 223
221 224 if (Arr::get($response, 'id')) {