MCPcopy Create free account
hub / github.com/codecombat/codecombat / startSubscribe

Method startSubscribe

app/views/account/SubscriptionView.js:466–496  ·  view source on GitHub ↗
(emails)

Source from the content-addressed store, hash-verified

464 }
465
466 startSubscribe (emails) {
467 let left
468 let email
469 this.recipientEmails = ((() => {
470 const result = []
471 for (email of Array.from(emails)) {
472 result.push(email.trim().toLowerCase())
473 }
474 return result
475 })())
476 _.remove(this.recipientEmails, email => _.isEmpty(email))
477 if (this.recipientEmails.length < 1) { return }
478
479 if (window.tracker != null) {
480 window.tracker.trackEvent('Start sponsored subscription', { category: 'Subscription' })
481 }
482
483 // TODO: this sometimes shows a rounded amount (e.g. $8.00)
484 const currentSubCount = (left = __guard__(__guard__(me.get('stripe'), x1 => x1.recipients), x => x.length)) != null ? left : 0
485 const newSubCount = this.recipientEmails.length + currentSubCount
486 const amount = utils.getSponsoredSubsAmount(basicPlanPrice, newSubCount, (__guard__(me.get('stripe'), x2 => x2.subscriptionID) != null)) - utils.getSponsoredSubsAmount(basicPlanPrice, currentSubCount, (__guard__(me.get('stripe'), x3 => x3.subscriptionID) != null))
487 const options = {
488 description: `${this.recipientEmails.length} ` + $.i18n.t('subscribe.stripe_description', { defaultValue: 'Monthly Subscriptions' }),
489 amount,
490 alipay: me.get('chinaVersion') || ((me.get('preferredLanguage') || 'en-US').slice(0, 2) === 'zh') ? true : 'auto',
491 alipayReusable: true
492 }
493 this.state = 'start subscribe'
494 this.stateMessage = ''
495 return stripeHandler.open(options)
496 }
497
498 finishSubscribe (tokenID, render) {
499 let left

Callers 1

Calls 4

__guard__Function · 0.70
trackEventMethod · 0.45
getMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected