mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #2087 from overleaf/subscription-invoices-link
Add Link to Invoices for Recurly Subscriptions GitOrigin-RevId: dd3aa999c26988f2bd42b0db83dbfb0ce586a0a7
This commit is contained in:
parent
25970e94da
commit
358cd22f54
3 changed files with 28 additions and 13 deletions
|
@ -28,17 +28,19 @@ const logger = require('logger-sharelatex')
|
|||
const _ = require('underscore')
|
||||
const async = require('async')
|
||||
|
||||
const buildBillingDetails = function(recurlySubscription) {
|
||||
const hostedLoginToken = __guard__(
|
||||
recurlySubscription != null ? recurlySubscription.account : undefined,
|
||||
x => x.hosted_login_token
|
||||
)
|
||||
const buildHostedLink = function(recurlySubscription, type) {
|
||||
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 [
|
||||
'https://',
|
||||
recurlySubdomain,
|
||||
'.recurly.com/account/billing_info/edit?ht=',
|
||||
'.recurly.com/account/',
|
||||
path,
|
||||
hostedLoginToken
|
||||
].join('')
|
||||
}
|
||||
|
@ -195,7 +197,11 @@ module.exports = {
|
|||
x => x._
|
||||
)
|
||||
),
|
||||
billingDetailsLink: buildBillingDetails(recurlySubscription),
|
||||
billingDetailsLink: buildHostedLink(
|
||||
recurlySubscription,
|
||||
'billingDetails'
|
||||
),
|
||||
accountManagementLink: buildHostedLink(recurlySubscription),
|
||||
price: SubscriptionFormatters.formatPrice(
|
||||
(recurlySubscription != null
|
||||
? recurlySubscription.unit_amount_in_cents
|
||||
|
|
|
@ -17,16 +17,23 @@ div(ng-controller="RecurlySubscriptionController")
|
|||
p
|
||||
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"
|
||||
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: form(action="/user/subscription/reactivate",method="post")
|
||||
input(type="hidden", name="_csrf", value=csrfToken)
|
||||
input(type="submit",value="Reactivate your subscription").btn.btn-success
|
||||
p
|
||||
a(href=personalSubscription.recurly.accountManagementLink, target="_blank").btn.btn-info #{translate("view_your_invoices")}
|
||||
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"
|
||||
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")}
|
||||
|
|
||||
a(href="/user/subscription/plans").btn.btn-success !{translate("create_new_subscription")}
|
||||
default
|
||||
p !{translate("problem_with_subscription_contact_us")}
|
||||
|
||||
|
|
|
@ -120,6 +120,8 @@ describe('Subscriptions', function() {
|
|||
activeCoupons: [],
|
||||
billingDetailsLink:
|
||||
'https://test.recurly.com/account/billing_info/edit?ht=mock-login-token',
|
||||
accountManagementLink:
|
||||
'https://test.recurly.com/account/mock-login-token',
|
||||
currency: 'GBP',
|
||||
nextPaymentDueAt: '5th May 2018',
|
||||
price: '£6.00',
|
||||
|
|
Loading…
Reference in a new issue