Merge pull request #2087 from overleaf/subscription-invoices-link

Add Link to Invoices for Recurly Subscriptions

GitOrigin-RevId: dd3aa999c26988f2bd42b0db83dbfb0ce586a0a7
This commit is contained in:
Eric Mc Sween 2019-08-20 08:44:59 -04:00 committed by sharelatex
parent 25970e94da
commit 358cd22f54
3 changed files with 28 additions and 13 deletions

View file

@ -28,17 +28,19 @@ const logger = require('logger-sharelatex')
const _ = require('underscore') const _ = require('underscore')
const async = require('async') const async = require('async')
const buildBillingDetails = function(recurlySubscription) { const buildHostedLink = function(recurlySubscription, type) {
const hostedLoginToken = __guard__(
recurlySubscription != null ? recurlySubscription.account : undefined,
x => x.hosted_login_token
)
const recurlySubdomain = Settings.apis.recurly.subdomain const recurlySubdomain = Settings.apis.recurly.subdomain
if (hostedLoginToken != null && recurlySubdomain != null) { const hostedLoginToken = recurlySubscription.account.hosted_login_token
let path = ''
if (type === 'billingDetails') {
path = 'billing_info/edit?ht='
}
if (hostedLoginToken && recurlySubdomain) {
return [ return [
'https://', 'https://',
recurlySubdomain, recurlySubdomain,
'.recurly.com/account/billing_info/edit?ht=', '.recurly.com/account/',
path,
hostedLoginToken hostedLoginToken
].join('') ].join('')
} }
@ -195,7 +197,11 @@ module.exports = {
x => x._ x => x._
) )
), ),
billingDetailsLink: buildBillingDetails(recurlySubscription), billingDetailsLink: buildHostedLink(
recurlySubscription,
'billingDetails'
),
accountManagementLink: buildHostedLink(recurlySubscription),
price: SubscriptionFormatters.formatPrice( price: SubscriptionFormatters.formatPrice(
(recurlySubscription != null (recurlySubscription != null
? recurlySubscription.unit_amount_in_cents ? recurlySubscription.unit_amount_in_cents

View file

@ -17,16 +17,23 @@ div(ng-controller="RecurlySubscriptionController")
p p
a(href=personalSubscription.recurly.billingDetailsLink, target="_blank").btn.btn-info #{translate("update_your_billing_details")} a(href=personalSubscription.recurly.billingDetailsLink, target="_blank").btn.btn-info #{translate("update_your_billing_details")}
|   |  
a(href, ng-click="switchToCancellationView()", ng-hide="recurlyLoadError").btn.btn-primary !{translate("cancel_your_subscription")} a(href=personalSubscription.recurly.accountManagementLink, target="_blank").btn.btn-info #{translate("view_your_invoices")}
|  
a(href, ng-click="switchToCancellationView()", ng-hide="recurlyLoadError").btn.btn-danger !{translate("cancel_your_subscription")}
when "canceled" when "canceled"
p !{translate("currently_subscribed_to_plan", {planName:"<strong>" + personalSubscription.plan.name + "</strong>"})} p !{translate("currently_subscribed_to_plan", {planName:"<strong>" + personalSubscription.plan.name + "</strong>"})}
p !{translate("subscription_canceled_and_terminate_on_x", {terminateDate:"<strong>" + personalSubscription.recurly.nextPaymentDueAt + "</strong>"})} p !{translate("subscription_canceled_and_terminate_on_x", {terminateDate:"<strong>" + personalSubscription.recurly.nextPaymentDueAt + "</strong>"})}
p: form(action="/user/subscription/reactivate",method="post") p
input(type="hidden", name="_csrf", value=csrfToken) a(href=personalSubscription.recurly.accountManagementLink, target="_blank").btn.btn-info #{translate("view_your_invoices")}
input(type="submit",value="Reactivate your subscription").btn.btn-success p: form(action="/user/subscription/reactivate",method="post")
input(type="hidden", name="_csrf", value=csrfToken)
input(type="submit",value="Reactivate your subscription").btn.btn-success
when "expired" when "expired"
p !{translate("your_subscription_has_expired")} p !{translate("your_subscription_has_expired")}
a(href="/user/subscription/plans") !{translate("create_new_subscription")} p
a(href=personalSubscription.recurly.accountManagementLink, target="_blank").btn.btn-info #{translate("view_your_invoices")}
| &nbsp;
a(href="/user/subscription/plans").btn.btn-success !{translate("create_new_subscription")}
default default
p !{translate("problem_with_subscription_contact_us")} p !{translate("problem_with_subscription_contact_us")}

View file

@ -120,6 +120,8 @@ describe('Subscriptions', function() {
activeCoupons: [], activeCoupons: [],
billingDetailsLink: billingDetailsLink:
'https://test.recurly.com/account/billing_info/edit?ht=mock-login-token', 'https://test.recurly.com/account/billing_info/edit?ht=mock-login-token',
accountManagementLink:
'https://test.recurly.com/account/mock-login-token',
currency: 'GBP', currency: 'GBP',
nextPaymentDueAt: '5th May 2018', nextPaymentDueAt: '5th May 2018',
price: '£6.00', price: '£6.00',