diff --git a/apps/profile/models.py b/apps/profile/models.py
index 854b74ccc..003c45707 100644
--- a/apps/profile/models.py
+++ b/apps/profile/models.py
@@ -254,7 +254,7 @@ class Profile(models.Model):
UserSubscription.queue_new_feeds(self.user)
- self.setup_premium_history()
+ # self.setup_premium_history() # Let's not call this unnecessarily
if never_expire:
self.premium_expire = None
@@ -412,7 +412,7 @@ class Profile(models.Model):
return True
- def switch_paypal_subscription(self, plan):
+ def switch_paypal_subscription_approval_url(self, plan):
paypal_api = self.paypal_api()
if not paypal_api:
return
@@ -434,9 +434,9 @@ class Profile(models.Model):
return
logging.user(self.user, paypal_subscription)
- for link in paypal_subscription['links']:
+ for link in paypal_subscription.get('links', []):
if link['rel'] == 'approve':
- return False, link['href']
+ return link['href']
logging.user(self.user, f"~FRFailed to switch paypal subscription: ~FC{paypal_subscription}")
diff --git a/apps/profile/views.py b/apps/profile/views.py
index ec046df67..b04e6e05f 100644
--- a/apps/profile/views.py
+++ b/apps/profile/views.py
@@ -312,6 +312,7 @@ def paypal_form(request):
# Output the button.
return HttpResponse(form.render(), content_type='text/html')
+@login_required
def paypal_return(request):
return render(request, 'reader/paypal_return.xhtml', {
@@ -526,20 +527,17 @@ def switch_paypal_subscription(request):
paypal_url = request.user.profile.paypal_change_billing_details_url()
return HttpResponseRedirect(paypal_url)
- switch_successful, approve_url = request.user.profile.switch_paypal_subscription(plan)
+ approve_url = request.user.profile.switch_paypal_subscription_approval_url(plan)
logging.user(request, "~FCSwitching subscription to ~SB%s~SN~FC (%s)" %(
plan,
- '~FGsucceeded~FC' if switch_successful else '~FRfailed~FC'
+ '~FGsucceeded~FC' if approve_url else '~FRfailed~FC'
))
if approve_url:
return HttpResponseRedirect(approve_url)
-
- if switch_successful:
- return HttpResponseRedirect(reverse('paypal-return'))
-
- return stripe_checkout(request)
+
+ return HttpResponseRedirect(reverse('paypal-return'))
@login_required
def stripe_checkout(request):
@@ -640,7 +638,7 @@ def payment_history(request):
except stripe.error.InvalidRequestError:
pass
- if paypal_api and not next_invoice and user.profile.premium_renewal:
+ if paypal_api and not next_invoice and user.profile.premium_renewal and len(history):
next_invoice = dict(payment_date=history[0].payment_date+dateutil.relativedelta.relativedelta(years=1),
payment_amount=history[0].payment_amount,
payment_provider="(scheduled)",
diff --git a/media/css/reader/reader.css b/media/css/reader/reader.css
index 6bae4b0ab..15dce76af 100644
--- a/media/css/reader/reader.css
+++ b/media/css/reader/reader.css
@@ -9833,9 +9833,12 @@ form.opml_import_form input {
/* -moz-box-shadow:0 2px 0 #1a5e0e;*/
/* box-shadow:0 2px 0 #1a5e0e;*/
}
+.NB-modal-feedchooser .NB-creditcards {
+ width: 100%;
+}
.NB-modal-feedchooser .NB-creditcards img {
- width: 32px;
- height: 20px;
+ width: 24px;
+ height: 18px;
margin: 0 2px 0 0;
}
.NB-modal-feedchooser .NB-feedchooser-dollar {
@@ -10108,19 +10111,20 @@ form.opml_import_form input {
.NB-modal-feedchooser .NB-payment-providers {
margin: 0 24px 24px;
}
-.NB-modal-feedchooser .NB-provider-button {
+.NB-modal-feedchooser .NB-provider-main,
+.NB-modal-feedchooser .NB-provider-alternate {
text-align: center;
flex-grow: 1;
+ width: 50%;
+ font-size: 0.7em;
+ text-transform: uppercase;
+ color: #838b82;
+}
+.NB-modal-feedchooser .NB-provider-main .NB-modal-submit-button,
+.NB-modal-feedchooser .NB-provider-alternate .NB-modal-submit-button {
padding-top: 12px;
padding-bottom: 12px;
}
-.NB-modal-feedchooser .NB-alternate-provider {
- font-size: 0.7em;
- flex-grow: 1;
- text-transform: uppercase;
- text-align: center;
- color: #838b82;
-}
.NB-modal-feedchooser .NB-paypal-button {
margin-top: 6px;
}
diff --git a/media/img/reader/cc_amex.svg b/media/img/reader/cc_amex.svg
new file mode 100644
index 000000000..341611e4c
--- /dev/null
+++ b/media/img/reader/cc_amex.svg
@@ -0,0 +1,10 @@
+
+
\ No newline at end of file
diff --git a/media/img/reader/cc_discover.svg b/media/img/reader/cc_discover.svg
new file mode 100644
index 000000000..715465447
--- /dev/null
+++ b/media/img/reader/cc_discover.svg
@@ -0,0 +1,11 @@
+
+
\ No newline at end of file
diff --git a/media/img/reader/cc_mastercard.svg b/media/img/reader/cc_mastercard.svg
new file mode 100644
index 000000000..e9e86bddf
--- /dev/null
+++ b/media/img/reader/cc_mastercard.svg
@@ -0,0 +1,22 @@
+
+
\ No newline at end of file
diff --git a/media/img/reader/cc_stripe.svg b/media/img/reader/cc_stripe.svg
new file mode 100644
index 000000000..d7bfb98b3
--- /dev/null
+++ b/media/img/reader/cc_stripe.svg
@@ -0,0 +1,10 @@
+
+
\ No newline at end of file
diff --git a/media/img/reader/cc_visa.svg b/media/img/reader/cc_visa.svg
new file mode 100644
index 000000000..eba8d51a4
--- /dev/null
+++ b/media/img/reader/cc_visa.svg
@@ -0,0 +1,11 @@
+
+
\ No newline at end of file
diff --git a/media/js/newsblur/reader/reader_feedchooser.js b/media/js/newsblur/reader/reader_feedchooser.js
index 0363cbe19..6010f54cd 100644
--- a/media/js/newsblur/reader/reader_feedchooser.js
+++ b/media/js/newsblur/reader/reader_feedchooser.js
@@ -61,7 +61,13 @@ _.extend(NEWSBLUR.ReaderFeedchooser.prototype, {
make_modal: function () {
var self = this;
-
+ var $creditcards = $.make('div', { className: 'NB-creditcards' }, [
+ $.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + "/img/reader/cc_stripe.svg" }),
+ $.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + "/img/reader/cc_visa.svg" }),
+ $.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + "/img/reader/cc_mastercard.svg" }),
+ $.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + "/img/reader/cc_amex.svg" }),
+ $.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + "/img/reader/cc_discover.svg" })
+ ]);
this.$modal = $.make('div', { className: 'NB-modal-feedchooser NB-modal ' + (this.options.premium_only ? "NB-feedchooser-premium" : this.options.chooser_only ? "NB-feedchooser-chooser-only" : "NB-feedchooser-standard") }, [
// $.make('h2', { className: 'NB-modal-title' }, 'Choose Your '+this.MAX_FEEDS),
(!this.options.chooser_only && $.make('div', { className: 'NB-feedchooser-type NB-right' }, [
@@ -115,13 +121,16 @@ _.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-button NB-provider-button-premium NB-modal-submit-button NB-modal-submit-green"
- }, [
- "Upgrade to Premium"
+ $.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"
+ ])
]),
$.make('div', { className: 'NB-feedchooser-or-bar' }),
- $.make("div", { className: "NB-alternate-provider" }, [
+ $.make("div", { className: "NB-provider-alternate" }, [
"subscribe with ",
$.make("div", { className: "NB-splash-link NB-paypal-button", "data-plan": "premium" }, "")
])
@@ -138,30 +147,36 @@ _.extend(NEWSBLUR.ReaderFeedchooser.prototype, {
])
])),
(NEWSBLUR.Globals.is_premium && !NEWSBLUR.Globals.premium_renewal && $.make("div", { className: "NB-feedchooser-premium-upgrade" }, [
- $.make('div', {
- className: "NB-provider-button NB-provider-button-premium NB-modal-submit-button NB-modal-submit-green"
- }, [
- (NEWSBLUR.Globals.is_archive || NEWSBLUR.Globals.is_pro) && "Switch plans to a premium subscription",
- !(NEWSBLUR.Globals.is_archive || NEWSBLUR.Globals.is_pro) && "Restart your premium subscription",
+ $.make('div', { className: 'NB-provider-main' }, [
+ $.make('div', {
+ className: "NB-provider-button-premium NB-modal-submit-button NB-modal-submit-green"
+ }, [
+ (NEWSBLUR.Globals.is_archive || NEWSBLUR.Globals.is_pro) && "Switch plans to a premium subscription",
+ !(NEWSBLUR.Globals.is_archive || NEWSBLUR.Globals.is_pro) && "Restart your premium subscription",
+ ])
]),
$.make('div', { className: 'NB-feedchooser-or-bar' }),
- $.make("div", { className: "NB-alternate-provider" }, [
+ $.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" && $.make("div", { className: "NB-provider-button 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.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.is_premium && !NEWSBLUR.Globals.is_archive && !NEWSBLUR.Globals.is_pro && NEWSBLUR.Globals.premium_renewal && $.make("div", { className: "NB-feedchooser-premium-upgrade" }, [
- $.make('div', {
- className: "NB-provider-button NB-provider-button-change NB-modal-submit-button NB-modal-submit-grey"
- }, [
- "Change billing details"
+ $.make('div', { className: 'NB-provider-main' }, [
+ $.make('div', {
+ className: "NB-provider-button-change NB-modal-submit-button NB-modal-submit-grey"
+ }, [
+ "Change billing details"
+ ])
]),
$.make('div', { className: 'NB-feedchooser-or-bar' }),
- $.make("div", { className: "NB-alternate-provider" }, [
+ $.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" && $.make("div", { className: "NB-stripe-button-switch-premium NB-provider-button NB-modal-submit-button NB-modal-submit-green" }, "Switch to Credit Card"))
+ (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"))
])
]))
])
@@ -203,18 +218,22 @@ _.extend(NEWSBLUR.ReaderFeedchooser.prototype, {
]),
$.make('div', { className: 'NB-payment-providers' }, [
(!NEWSBLUR.Globals.is_archive && $.make("div", { className: "NB-feedchooser-premium-upgrade" }, [
- $.make('div', {
- className: "NB-provider-button NB-provider-button-archive NB-modal-submit-button NB-modal-submit-green"
- }, [
- "Upgrade to ",
- " Premium Archive",
- (NEWSBLUR.Globals.active_provider == "paypal" && " with PayPal")
+
+ $.make('div', { className: 'NB-provider-main' }, [
+ (NEWSBLUR.Globals.active_provider != "paypal" && $creditcards.clone()),
+ $.make('div', {
+ className: "NB-provider-button-archive NB-modal-submit-button NB-modal-submit-green"
+ }, [
+ "Upgrade to Premium Archive",
+ (NEWSBLUR.Globals.active_provider == "paypal" && " with PayPal")
+ ])
]),
$.make('div', { className: 'NB-feedchooser-or-bar' }),
- $.make("div", { className: "NB-alternate-provider" }, [
+ $.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" && $.make("div", { className: "NB-stripe-button-switch-archive NB-provider-button NB-modal-submit-button NB-modal-submit-green" }, "Switch to Credit Card"))
+ (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"))
])
// $.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.")
])),
@@ -229,30 +248,36 @@ _.extend(NEWSBLUR.ReaderFeedchooser.prototype, {
])
])),
(NEWSBLUR.Globals.is_archive && !NEWSBLUR.Globals.premium_renewal && $.make("div", { className: "NB-feedchooser-premium-upgrade" }, [
- $.make('div', {
- className: "NB-provider-button NB-provider-button-archive NB-modal-submit-button NB-modal-submit-green"
- }, [
- !NEWSBLUR.Globals.is_archive && "Switch plans to a premium archive subscription",
- NEWSBLUR.Globals.is_archive && "Restart your premium archive subscription",
+ $.make('div', { className: 'NB-provider-main' }, [
+ $.make('div', {
+ className: "NB-provider-button-archive NB-modal-submit-button NB-modal-submit-green"
+ }, [
+ !NEWSBLUR.Globals.is_archive && "Switch plans to a premium archive subscription",
+ NEWSBLUR.Globals.is_archive && "Restart your premium archive subscription",
+ ])
]),
$.make('div', { className: 'NB-feedchooser-or-bar' }),
- $.make("div", { className: "NB-alternate-provider" }, [
+ $.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" && $.make("div", { className: "NB-provider-button 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.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.is_archive && !NEWSBLUR.Globals.is_pro && NEWSBLUR.Globals.premium_renewal && $.make("div", { className: "NB-feedchooser-premium-upgrade" }, [
- $.make('div', {
- className: "NB-provider-button NB-provider-button-change NB-modal-submit-button NB-modal-submit-grey"
- }, [
- "Change billing details"
+ $.make('div', { className: 'NB-provider-main' }, [
+ $.make('div', {
+ className: "NB-provider-button-change NB-modal-submit-button NB-modal-submit-grey"
+ }, [
+ "Change billing details"
+ ])
]),
$.make('div', { className: 'NB-feedchooser-or-bar' }),
- $.make("div", { className: "NB-alternate-provider" }, [
+ $.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" && $.make("div", { className: "NB-stripe-button-switch-archive NB-provider-button NB-modal-submit-button NB-modal-submit-green" }, "Switch to Credit Card"))
+ (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"))
])
]))
])
diff --git a/templates/base.html b/templates/base.html
index fc14da0b2..42b52e359 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -86,7 +86,7 @@
'story_line_spacing' : 'm',
'hide_public_comments' : false,
'story_button_placement' : "right",
- 'days_of_unread' : {{ user_profile.days_of_unread }},
+ 'days_of_unread' : {% firstof user_profile.days_of_unread 30 %},
'timezone' : "{{ user_profile.timezone }}",
'title_counts' : true,
'show_global_shared_stories': true,