← All changes
|
app/Modules/PaymentMethods/PayPalGateway/SubscriptionManager.php
+4
-9
1.5.1
→
1.6.5
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,9 +131,9 @@ | ||
| 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, |
| 138 | 137 | ], 200); |
| 139 | 138 | } |
| 140 | 139 | |
| @@ -186,10 +185,8 @@ | ||
| 186 | 185 | if (!empty($nextBillingDate)) { |
| 187 | 186 | $nextBillingDate = gmdate('Y-m-d H:i:s', strtotime($nextBillingDate)); |
| 188 | 187 | } |
| 189 | 188 | |
| 190 | - $config = $subscription->config ?: []; | |
| 191 | - | |
| 192 | 189 | // update subscription in table |
| 193 | 190 | $data = array_filter([ |
| 194 | 191 | 'vendor_subscription_id' => $vendorSubscriptionId, |
| 195 | 192 | 'vendor_plan_id' => $vendorPlanId, |
| @@ -196,13 +193,14 @@ | ||
| 196 | 193 | 'current_payment_method' => 'paypal', |
| 197 | 194 | 'vendor_customer_id' => $vendorCustomerId, |
| 198 | 195 | 'next_billing_date' => $nextBillingDate, |
| 199 | 196 | 'status' => $this->getCorrectSubscriptionStatus(Arr::get($paypalSubscription, 'status')), |
| 200 | - 'config' => array_merge($config, ['is_trial_days_simulated' => 'yes']) | |
| 201 | 197 | ]); |
| 202 | 198 | |
| 203 | 199 | Subscription::query()->where('id', $subscriptionId)->update($data); |
| 204 | 200 | |
| 201 | + $subscription->mergeConfig(['is_trial_days_simulated' => 'yes']); | |
| 202 | + | |
| 205 | 203 | $billingInfo = PaymentHelper::parsePaymentMethodDetails('paypal', [ |
| 206 | 204 | 'email' => Arr::get($paypalSubscription, 'subscriber.email_address'), |
| 207 | 205 | 'payer_id' => Arr::get($paypalSubscription, 'subscriber.payer_id'), |
| 208 | 206 | 'name' => Arr::get($paypalSubscription, 'subscriber.name.given_name') . ' ' . Arr::get($paypalSubscription, 'subscriber.name.surname'), |
| @@ -312,12 +310,9 @@ | ||
| 312 | 310 | if ($nextBillingTimestamp && $nextBillingTimestamp > time()) { |
| 313 | 311 | $trialDays = ceil(($nextBillingTimestamp - time()) / 86400); |
| 314 | 312 | } |
| 315 | 313 | |
| 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(); | |
| 314 | + $billCount = $subscriptionModel->calculateBillCount(); | |
| 320 | 315 | |
| 321 | 316 | |
| 322 | 317 | $trialDays = SubscriptionHelper::checkTrailDaysLoopHole($subscriptionModel, $trialDays); |
| 323 | 318 | |