mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-01-16 19:05:08 -05:00
Subscription Module Update - Confirmation update
This commit is contained in:
@@ -758,6 +758,8 @@ class SubscriptionController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$payment_details = $planPrice->plan->title;
|
||||
$coupon_id = null;
|
||||
if($request->promo_code != null){
|
||||
@@ -794,9 +796,13 @@ class SubscriptionController extends Controller
|
||||
|
||||
} else {
|
||||
|
||||
if($request->has('renew_now') && $request->renew_now && $request->has('prorate_discount') && $request->prorate_discount && $planPrice->payment == 'upfront'){
|
||||
if($request->has('renew_now') && $request->renew_now && $request->has('prorate_discount') && $request->prorate_discount){
|
||||
$prorate_discount = $request->prorate_discount;
|
||||
$payment_details .= ' - '.$planPrice->custom_interval.' Months ($'.number_format($planPrice->price - $prorate_discount,2).')';
|
||||
if( $planPrice->payment == 'upfront'){
|
||||
$payment_details .= ' - '.$planPrice->custom_interval.' Months ($'.number_format($planPrice->price - $prorate_discount,2).')';
|
||||
} else if($planPrice->payment == 'monthly' ){
|
||||
$payment_details .= ' - '.$planPrice->custom_interval.' Months ($'.number_format(($planPrice->price / $planPrice->custom_interval) - $prorate_discount,2).' prorated 1st month only then $'.number_format($planPrice->price / $planPrice->custom_interval,2).' per month)' ;
|
||||
}
|
||||
} else if($prorate_discount > 0){
|
||||
$payment_details .= $planPrice->payment == 'monthly' ? ' - '.$planPrice->custom_interval.' Months ($'.number_format(($planPrice->price / $planPrice->custom_interval) - $prorate_discount,2).' prorated 1st month only then $'.number_format($planPrice->price / $planPrice->custom_interval,2).' per month)' : ' - '.$planPrice->custom_interval.' Months ($'.number_format($planPrice->price,2).')';
|
||||
} else {
|
||||
@@ -817,7 +823,7 @@ class SubscriptionController extends Controller
|
||||
'user_name' => auth()->user()->name,
|
||||
'user_email' => auth()->user()->email,
|
||||
'subscription_plan_price_id' => $planPrice->stripe_price_id,
|
||||
'prorate_discount' => (float)$prorate_discount,
|
||||
'prorate_discount' => number_format($prorate_discount,2,'.',''),
|
||||
'coupon_id' => $coupon_id,
|
||||
'renew_now' => $request->has('renew_now') ? $request->renew_now : false
|
||||
]
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -2,7 +2,7 @@
|
||||
"/js/manager.js": "/js/manager.js?id=a7b502d3ac84fb0837b00f164abf1322",
|
||||
"/js/plans.js": "/js/plans.js?id=44f6262765603c3fbbc22fa21c8c6b3d",
|
||||
"/js/subscribers.js": "/js/subscribers.js?id=c50b8df20b804eab1746e8ca53430b8b",
|
||||
"/js/subscription.js": "/js/subscription.js?id=c7580cd0ce07c514d36a1010b18f6236",
|
||||
"/js/subscription.js": "/js/subscription.js?id=40938e689bfa1c4f006f21513734b6c5",
|
||||
"/js/coupons.js": "/js/coupons.js?id=42bc1666ee535147ec0f388be7d24b08",
|
||||
"/css/subscription.css": "/css/subscription.css?id=0342847ae42b28305a436dfd8ea6e63f",
|
||||
"/css/subscribers.css": "/css/subscribers.css?id=fd57e1a4067d2e49244bfeabab15affd",
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<p class="mb-3 text-center" v-html="prorate_message"></p>
|
||||
<div class="flex column-gap-4 align-items-center justify-content-center">
|
||||
<Button label="Cancel" @click="prorate_notice = false" class="p-button-sm p-button-danger"/>
|
||||
<Button v-if="prorate_type == 'yearly'" label="Go to A La Carte" @click="goToAlacarte" class="p-button-sm p-button-warning"/>
|
||||
<Button v-if="prorate_type == 'yearly'" label="I agree to process later" @click="handleProrateSubscription(false)" class="p-button-sm p-button-success"/>
|
||||
<Button v-if="prorate_type == 'monthly'" label="Renew Now" @click="handleProrateSubscription(true)" class="p-button-sm p-button-success"/>
|
||||
<Button v-if="prorate_type == 'monthly'" label="Process Later" @click="handleProrateSubscription(false)" class="p-button-sm p-button-warning" />
|
||||
@@ -50,7 +51,10 @@
|
||||
<ul class="pricing-wrapper">
|
||||
|
||||
<label class="d-block" v-for="(price, key) in subscription.filtered_prices" :key="price.id">
|
||||
<input type="radio" name="subscription_price_id" :value="price.id" :id="`subscription-plan-price-${price.id}`" :data-subscription-plan="subscription.title" :data-subscription-plan-popular="subscription.popular" :data-subscription-price-monthly="price.price / price.custom_interval" :data-subscription-price-total="price.price" :data-subscription-interval="price.custom_interval" :data-subscription-interval-type="price.custom_interval_type" :data-subscription-discount="0" class="subscription-plan d-none" :checked=" subscription.popular && price.payment == duration">
|
||||
<input type="radio" name="subscription_price_id" :value="price.id" :id="`subscription-plan-price-${price.id}`" :data-subscription-plan="subscription.title"
|
||||
:data-subscription-price-total-credits="price.total_credits"
|
||||
:data-subscription-plan-popular="subscription.popular"
|
||||
:data-subscription-price-monthly="price.price / price.custom_interval" :data-subscription-price-total="price.price" :data-subscription-interval="price.custom_interval" :data-subscription-interval-type="price.custom_interval_type" :data-subscription-discount="0" class="subscription-plan d-none" :checked=" subscription.popular && price.payment == duration">
|
||||
<li :data-type="price.payment" :class="`${key == 0 ? 'is-visible' : 'is-hidden' }`">
|
||||
<header class="pricing-header pb-2">
|
||||
<div class="d-flex justify-content-between">
|
||||
@@ -189,6 +193,8 @@ export default {
|
||||
applying_coupon: false,
|
||||
applied_coupon: false,
|
||||
coupon_discount: null,
|
||||
selected_plan_price: null,
|
||||
prorate_credit: 0,
|
||||
duration: 'monthly'
|
||||
}
|
||||
},
|
||||
@@ -245,19 +251,29 @@ export default {
|
||||
},
|
||||
handleNewSubscription(payment_method) {
|
||||
const e = this;
|
||||
e.form.subscription_price_id = $('input[name="subscription_price_id"]:checked').val();
|
||||
e.form.subscription_price_id = $("input[name=subscription_price_id]:checked").val();
|
||||
e.form.payment_method = payment_method;
|
||||
e.prorate_credit = 0;
|
||||
|
||||
//show popup
|
||||
if(e.current_subscription.status == 'active' && !e.current_subscription.trialing && e.current_subscription.payment_mode == 'Monthly' && e.duration == 'upfront'){
|
||||
e.prorate_type = 'monthly';
|
||||
e.prorate_notice = true;
|
||||
e.prorate_message = `You have <strong>${e.current_subscription.days_left} days</strong> remaining on the current plan.<br>If you select <strong>"Renew Now"</strong> you will receive a discount of <strong>$${parseFloat((e.current_subscription.subscription_price / 30) * e.current_subscription.days_left).toFixed(2)}</strong> and your plan will start from today.<br>If you select <strong>"Process Later"</strong> your payment and credits will be applied on <strong>${e.current_subscription.next_payment_date}</strong>.`;
|
||||
|
||||
e.prorate_message = `You have <strong>${e.current_subscription.days_left} days</strong> remaining on the current plan.<br>If you select <strong>"Renew Now"</strong> you will receive a discount of <strong>$${parseFloat((e.current_subscription.subscription_price / 30) * e.current_subscription.days_left).toFixed(2)}</strong> and your plan will begin immediately after approval.<br>If you select <strong>"Process Later"</strong> your payment and credits will be applied on <strong>${e.current_subscription.next_payment_date}</strong>.`;
|
||||
} else if(e.current_subscription.status == 'active' && !e.current_subscription.trialing && e.current_subscription.payment_mode == 'Monthly' && e.duration == 'monthly' && e.current_subscription.plan_status){
|
||||
e.prorate_type = 'monthly';
|
||||
e.prorate_notice = true;
|
||||
e.prorate_credit = $("input[name=subscription_price_id]:checked").data('subscription-price-total-credits') - (( e.current_subscription.plan_total_credits / e.current_subscription.plan_months ) * (e.current_subscription.plan_months - e.current_subscription.paid_invoice));
|
||||
if(e.prorate_credit >= 0){
|
||||
e.prorate_message = `You have <strong>${e.current_subscription.days_left} days</strong> remaining on the current plan.<br>If you select <strong>"Renew Now"</strong> you will receive a discount of <strong>$${parseFloat((e.current_subscription.subscription_price / 30) * e.current_subscription.days_left).toFixed(2)}</strong> and be granted <strong>${ Math.floor(e.prorate_credit)}</strong> prorated credits. Your plan will begin immediately after approval.<br>If you select <strong>"Process Later"</strong> your payment and credits will be applied on <strong>${e.current_subscription.next_payment_date}</strong>.`;
|
||||
} else {
|
||||
e.prorate_message = `You have <strong>${e.current_subscription.days_left} days</strong> remaining on the current plan.<br>If you select <strong>"Renew Now"</strong> you will receive a discount of <strong>$${parseFloat((e.current_subscription.subscription_price / 30) * e.current_subscription.days_left).toFixed(2)}</strong> and a reduction of <strong>${ Math.floor(Math.abs(e.prorate_credit))}</strong> credits. Your plan will begin immediately after approval.<br>If you select <strong>"Process Later"</strong> your payment and credits will be applied on <strong>${e.current_subscription.next_payment_date}</strong>.`;
|
||||
}
|
||||
|
||||
} else if(e.current_subscription.status == 'active' && !e.current_subscription.trialing && e.current_subscription.days_left > 0){
|
||||
e.prorate_type = 'yearly';
|
||||
e.prorate_notice = true;
|
||||
e.prorate_message = `You have <strong>${e.current_subscription.days_left} days</strong> days remaining on the current plan. Your new package payment will process on <strong>${e.current_subscription.next_payment_date}</strong>. If you need credits before then, please purchase them in al a carte.`;
|
||||
e.prorate_message = `You have <strong>${e.current_subscription.days_left} days</strong> days remaining on the current plan. Your new package payment will process on <strong>${e.current_subscription.next_payment_date}</strong>. If you need credits before then, please purchase them in a la carte.`;
|
||||
} else {
|
||||
|
||||
if(payment_method == 'stripe'){
|
||||
@@ -411,6 +427,9 @@ export default {
|
||||
}
|
||||
return html;
|
||||
},
|
||||
goToAlacarte(){
|
||||
window.location.href = '/a-la-carte';
|
||||
},
|
||||
reset() {
|
||||
const e = this;
|
||||
e.subscription_plans = null;
|
||||
|
||||
@@ -134,8 +134,6 @@ trait SubscriptionTrait
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'subscription_id' => $currentSubscription ? $currentSubscription->txn_id : null,
|
||||
'plan' => $currentSubscription ? $currentSubscription->planPrice->plan->title : null,
|
||||
@@ -146,6 +144,9 @@ trait SubscriptionTrait
|
||||
'discount' => (float)$currentSubscription->discount->coupon->discount
|
||||
] : null,
|
||||
'plan_image' => $currentSubscription ? $currentSubscription->planPrice->plan->image_url : null,
|
||||
'plan_total_credits' => $currentSubscription ? $currentSubscription->planPrice->total_credits : 0,
|
||||
'plan_months' => $currentSubscription ? $currentSubscription->planPrice->custom_interval : 0,
|
||||
'plan_status' => $currentSubscription ? $currentSubscription->planPrice->plan->status : false,
|
||||
'approved' => $currentSubscription ? $currentSubscription->approved : false,
|
||||
'subscription_end' => $currentSubscription ? \Carbon\Carbon::parse($currentSubscription->renewal_start_date == null ? $currentSubscription->created_at : $currentSubscription->renewal_start_date)->addMonths($currentSubscription->payment_method == 'prepaid' ? $currentSubscription->planPrice->access_expire_duration : $currentSubscription->planPrice->custom_interval)->format('j M Y, g:i a') : null,
|
||||
'subscription_expired' => $currentSubscription && $currentSubscription->expired_at != null ? \Carbon\Carbon::now()->gt(\Carbon\Carbon::parse($currentSubscription->expired_at)) : true,
|
||||
@@ -160,6 +161,7 @@ trait SubscriptionTrait
|
||||
] : null,
|
||||
'payment_method' => $currentSubscription ? $currentSubscription->payment_method : null,
|
||||
'payment_mode' => $currentSubscription ? $currentSubscription->payment_mode : null,
|
||||
'paid_invoice' => $currentSubscription ? $currentSubscription->paid_invoice : 0,
|
||||
'trialing' => $currentSubscription ? $currentSubscription->trialing : false,
|
||||
'status' => $currentSubscription ? $currentSubscription->status : false
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user