PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.7.1
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.7.1
1.7.1 1.7.0 1.6.6 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 All 51 releases
← All changes | app/Modules/PaymentMethods/PayPalGateway/SubscriptionManager.php +8 -9 1.4.2 → 1.7.1 View file →
@@ -4,9 +4,8 @@
4 4
5 5 use FluentCart\App\App;
6 6 use FluentCart\App\Helpers\Status;
7 7 use FluentCart\App\Models\Order;
8 -use FluentCart\App\Models\OrderTransaction;
9 8 use FluentCart\App\Models\ProductVariation;
10 9 use FluentCart\App\Models\Subscription;
11 10 use FluentCart\App\Models\SubscriptionMeta;
12 11 use FluentCart\App\Modules\PaymentMethods\PayPalGateway\API\API;
@@ -132,10 +131,14 @@
132 131 }
133 132
134 133 wp_send_json([
135 134 'status' => 'success',
136 - 'message' => 'Plan created successfully',
135 + 'message' => __('Plan created successfully', 'fluent-cart'),
137 136 'plan' => $plan,
137 + 'brand_name' => (new PayPalSettingsBase())->getBrandName([
138 + 'order' => $order,
139 + 'subscription' => $subscriptionModel,
140 + ]),
138 141 ], 200);
139 142 }
140 143
141 144 public function confirmSubscriptionSwitch($data, $subscriptionId)
@@ -186,10 +189,8 @@
186 189 if (!empty($nextBillingDate)) {
187 190 $nextBillingDate = gmdate('Y-m-d H:i:s', strtotime($nextBillingDate));
188 191 }
189 192
190 - $config = $subscription->config ?: [];
191 -
192 193 // update subscription in table
193 194 $data = array_filter([
194 195 'vendor_subscription_id' => $vendorSubscriptionId,
195 196 'vendor_plan_id' => $vendorPlanId,
@@ -196,13 +197,14 @@
196 197 'current_payment_method' => 'paypal',
197 198 'vendor_customer_id' => $vendorCustomerId,
198 199 'next_billing_date' => $nextBillingDate,
199 200 'status' => $this->getCorrectSubscriptionStatus(Arr::get($paypalSubscription, 'status')),
200 - 'config' => array_merge($config, ['is_trial_days_simulated' => 'yes'])
201 201 ]);
202 202
203 203 Subscription::query()->where('id', $subscriptionId)->update($data);
204 204
205 + $subscription->mergeConfig(['is_trial_days_simulated' => 'yes']);
206 +
205 207 $billingInfo = PaymentHelper::parsePaymentMethodDetails('paypal', [
206 208 'email' => Arr::get($paypalSubscription, 'subscriber.email_address'),
207 209 'payer_id' => Arr::get($paypalSubscription, 'subscriber.payer_id'),
208 210 'name' => Arr::get($paypalSubscription, 'subscriber.name.given_name') . ' ' . Arr::get($paypalSubscription, 'subscriber.name.surname'),
@@ -312,12 +314,9 @@
312 314 if ($nextBillingTimestamp && $nextBillingTimestamp > time()) {
313 315 $trialDays = ceil(($nextBillingTimestamp - time()) / 86400);
314 316 }
315 317
316 - $billCount = OrderTransaction::query()->where('subscription_id', $subscriptionModel->id)
317 - ->where('transaction_type', Status::TRANSACTION_TYPE_CHARGE)
318 - ->where('status', Status::TRANSACTION_SUCCEEDED)
319 - ->count();
318 + $billCount = $subscriptionModel->calculateBillCount();
320 319
321 320
322 321 $trialDays = SubscriptionHelper::checkTrailDaysLoopHole($subscriptionModel, $trialDays);
323 322