Adding proration messaging to upgrades. I believe payments are finally done.

This commit is contained in:
Samuel Clay 2022-04-08 16:08:06 -04:00
parent ae6bbc0aec
commit 7d2a5cd206
4 changed files with 40 additions and 20 deletions

View file

@ -258,8 +258,9 @@ class Profile(models.Model):
if never_expire:
self.premium_expire = None
self.save()
logging.user(self.user, "~BY~SK~FW~SBNEW PREMIUM ACCOUNT! WOOHOO!!! ~FR%s subscriptions~SN!" % (subs.count()))
if not was_premium:
logging.user(self.user, "~BY~SK~FW~SBNEW PREMIUM ACCOUNT! WOOHOO!!! ~FR%s subscriptions~SN!" % (subs.count()))
return True
@ -303,8 +304,9 @@ class Profile(models.Model):
if never_expire:
self.premium_expire = None
self.save()
logging.user(self.user, "~BY~SK~FW~SBNEW PREMIUM ~BBARCHIVE~BY ACCOUNT! WOOHOO!!! ~FR%s subscriptions~SN!" % (subs.count()))
if not was_archive:
logging.user(self.user, "~BY~SK~FW~SBNEW PREMIUM ~BBARCHIVE~BY ACCOUNT! WOOHOO!!! ~FR%s subscriptions~SN!" % (subs.count()))
return True
@ -349,8 +351,9 @@ class Profile(models.Model):
if never_expire:
self.premium_expire = None
self.save()
logging.user(self.user, "~BY~SK~FW~SBNEW PREMIUM ~BGPRO~BY ACCOUNT! WOOHOO!!! ~FR%s subscriptions~SN!" % (subs.count()))
if not was_pro:
logging.user(self.user, "~BY~SK~FW~SBNEW PREMIUM ~BGPRO~BY ACCOUNT! WOOHOO!!! ~FR%s subscriptions~SN!" % (subs.count()))
return True
@ -778,7 +781,7 @@ class Profile(models.Model):
def cancel_premium(self):
paypal_cancel = self.cancel_premium_paypal()
stripe_cancel = self.cancel_premium_stripe()
# self.setup_premium_history() # Don't bother, webhooks will force new history
self.setup_premium_history() # Sure, webhooks will force new history, but they take forever
return stripe_cancel or paypal_cancel
def cancel_premium_paypal(self, cancel_older_subscriptions_only=False):

View file

@ -285,6 +285,9 @@ def paypal_webhooks(request):
elif data['event_type'] == "PAYMENT.SALE.COMPLETED":
user = User.objects.get(pk=int(data['resource']['custom']))
user.profile.setup_premium_history()
elif data['event_type'] == "PAYMENT.CAPTURE.REFUNDED":
user = User.objects.get(pk=int(data['resource']['custom_id']))
user.profile.setup_premium_history()
elif data['event_type'] in ["BILLING.SUBSCRIPTION.CANCELLED", "BILLING.SUBSCRIPTION.SUSPENDED"]:
user = User.objects.get(pk=int(data['resource']['custom_id']))
user.profile.setup_premium_history()

View file

@ -10166,8 +10166,15 @@ form.opml_import_form input {
/* -moz-box-shadow:0 2px 0 #1a5e0e;*/
/* box-shadow:0 2px 0 #1a5e0e;*/
}
.NB-modal-feedchooser .NB-premium-prorate-message {
font-size: 1em;
color: rgba(0,0,0,0.5);
text-transform: none;
padding: 6px 32px 0;
}
.NB-modal-feedchooser .NB-creditcards {
width: 100%;
margin: 8px 0 0;
}
.NB-modal-feedchooser .NB-creditcards img {
width: 24px;

View file

@ -122,12 +122,12 @@ _.extend(NEWSBLUR.ReaderFeedchooser.prototype, {
$.make('div', { className: 'NB-payment-providers' }, [
(!NEWSBLUR.Globals.is_premium && $.make("div", { className: "NB-feedchooser-premium-upgrade" }, [
$.make('div', { className: 'NB-provider-main' }, [
$creditcards.clone(),
$.make('div', {
className: "NB-provider-button-premium NB-modal-submit-button NB-modal-submit-green"
}, [
"Upgrade to Premium"
])
]),
$creditcards.clone()
]),
$.make('div', { className: 'NB-feedchooser-or-bar' }),
$.make("div", { className: "NB-provider-alternate" }, [
@ -159,8 +159,8 @@ _.extend(NEWSBLUR.ReaderFeedchooser.prototype, {
$.make("div", { className: "NB-provider-alternate" }, [
(NEWSBLUR.Globals.active_provider != "paypal" && "subscribe with "),
(NEWSBLUR.Globals.active_provider != "paypal" && $.make("div", { className: "NB-splash-link NB-paypal-button", "data-plan": "premium" }, "")),
(NEWSBLUR.Globals.active_provider == "paypal" && $creditcards.clone()),
(NEWSBLUR.Globals.active_provider == "paypal" && $.make("div", { className: "NB-stripe-button-switch-premium NB-modal-submit-button NB-modal-submit-green" }, "Switch to Credit Card"))
(NEWSBLUR.Globals.active_provider == "paypal" && $.make("div", { className: "NB-stripe-button-switch-premium NB-modal-submit-button NB-modal-submit-green" }, "Switch to Credit Card")),
(NEWSBLUR.Globals.active_provider == "paypal" && $creditcards.clone())
])
])),
(NEWSBLUR.Globals.is_premium && !NEWSBLUR.Globals.is_archive && !NEWSBLUR.Globals.is_pro && NEWSBLUR.Globals.premium_renewal && $.make("div", { className: "NB-feedchooser-premium-upgrade" }, [
@ -175,8 +175,8 @@ _.extend(NEWSBLUR.ReaderFeedchooser.prototype, {
$.make("div", { className: "NB-provider-alternate" }, [
(NEWSBLUR.Globals.active_provider != "paypal" && "subscribe with "),
(NEWSBLUR.Globals.active_provider != "paypal" && $.make("div", { className: "NB-splash-link NB-paypal-button", "data-plan": "premium" }, "")),
(NEWSBLUR.Globals.active_provider == "paypal" && $creditcards.clone()),
(NEWSBLUR.Globals.active_provider == "paypal" && $.make("div", { className: "NB-stripe-button-switch-premium NB-modal-submit-button NB-modal-submit-green" }, "Switch to Credit Card"))
(NEWSBLUR.Globals.active_provider == "paypal" && $.make("div", { className: "NB-stripe-button-switch-premium NB-modal-submit-button NB-modal-submit-green" }, "Switch to Credit Card")),
(NEWSBLUR.Globals.active_provider == "paypal" && $creditcards.clone())
])
]))
])
@ -224,14 +224,15 @@ _.extend(NEWSBLUR.ReaderFeedchooser.prototype, {
}, [
"Upgrade to Premium Archive",
(NEWSBLUR.Globals.active_provider == "paypal" && " with PayPal")
])
]),
this.make_premium_archive_prorate_message(),
]),
$.make('div', { className: 'NB-feedchooser-or-bar' }),
$.make("div", { className: "NB-provider-alternate" }, [
(NEWSBLUR.Globals.active_provider != "paypal" && "subscribe with "),
(NEWSBLUR.Globals.active_provider != "paypal" && $.make("div", { className: "NB-splash-link NB-paypal-button", "data-plan": "archive" }, "")),
(NEWSBLUR.Globals.active_provider == "paypal" && $creditcards),
(NEWSBLUR.Globals.active_provider == "paypal" && $.make("div", { className: "NB-stripe-button-switch-archive NB-modal-submit-button NB-modal-submit-green" }, "Switch to Credit Card"))
(NEWSBLUR.Globals.active_provider == "paypal" && $.make("div", { className: "NB-stripe-button-switch-archive NB-modal-submit-button NB-modal-submit-green" }, "Switch to Credit Card")),
(NEWSBLUR.Globals.active_provider == "paypal" && $creditcards)
])
// $.make('div', { className: "NB-provider-note" }, "Note: Due to the intricacies of PayPal integration, you will be charged the full amount. If you switch to credit card, you will only be charged a prorated amount.")
])),
@ -258,8 +259,8 @@ _.extend(NEWSBLUR.ReaderFeedchooser.prototype, {
$.make("div", { className: "NB-provider-alternate" }, [
(NEWSBLUR.Globals.active_provider != "paypal" && "subscribe with "),
(NEWSBLUR.Globals.active_provider != "paypal" && $.make("div", { className: "NB-splash-link NB-paypal-button", "data-plan": "archive" }, "")),
(NEWSBLUR.Globals.active_provider == "paypal" && $creditcards.clone()),
(NEWSBLUR.Globals.active_provider == "paypal" && $.make("div", { className: "NB-stripe-button-switch-archive NB-modal-submit-button NB-modal-submit-green" }, "Switch to Credit Card"))
(NEWSBLUR.Globals.active_provider == "paypal" && $.make("div", { className: "NB-stripe-button-switch-archive NB-modal-submit-button NB-modal-submit-green" }, "Switch to Credit Card")),
(NEWSBLUR.Globals.active_provider == "paypal" && $creditcards.clone())
])
])),
(NEWSBLUR.Globals.is_archive && !NEWSBLUR.Globals.is_pro && NEWSBLUR.Globals.premium_renewal && $.make("div", { className: "NB-feedchooser-premium-upgrade" }, [
@ -274,8 +275,8 @@ _.extend(NEWSBLUR.ReaderFeedchooser.prototype, {
$.make("div", { className: "NB-provider-alternate" }, [
(NEWSBLUR.Globals.active_provider != "paypal" && "subscribe with "),
(NEWSBLUR.Globals.active_provider != "paypal" && $.make("div", { className: "NB-splash-link NB-paypal-button", "data-plan": "archive" }, "")),
(NEWSBLUR.Globals.active_provider == "paypal" && $creditcards.clone()),
(NEWSBLUR.Globals.active_provider == "paypal" && $.make("div", { className: "NB-stripe-button-switch-archive NB-modal-submit-button NB-modal-submit-green" }, "Switch to Credit Card"))
(NEWSBLUR.Globals.active_provider == "paypal" && $.make("div", { className: "NB-stripe-button-switch-archive NB-modal-submit-button NB-modal-submit-green" }, "Switch to Credit Card")),
(NEWSBLUR.Globals.active_provider == "paypal" && $creditcards.clone())
])
]))
])
@ -322,6 +323,12 @@ _.extend(NEWSBLUR.ReaderFeedchooser.prototype, {
]);
},
make_premium_archive_prorate_message: function () {
if (!_.contains(["paypal", "stripe"], NEWSBLUR.Globals.active_provider))
return;
return $.make('div', { className: "NB-premium-prorate-message" }, "Your existing subscription will be prorated");
},
make_paypal_button: function() {
jQuery.ajax({
type: "GET",