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

Method finishSubscribe

app/views/account/SubscriptionView.js:498–536  ·  view source on GitHub ↗
(tokenID, render)

Source from the content-addressed store, hash-verified

496 }
497
498 finishSubscribe (tokenID, render) {
499 let left
500 if (this.state !== 'start subscribe') { return } // Don't intercept personal subcribe process
501
502 this.state = 'subscribing'
503 this.stateMessage = ''
504 this.justSubscribed = []
505 render()
506
507 let stripeInfo = _.clone((left = me.get('stripe')) != null ? left : {})
508 stripeInfo.token = tokenID
509 stripeInfo.subscribeEmails = this.recipientEmails
510 me.set('stripe', stripeInfo)
511
512 me.once('sync', () => {
513 if (application.tracker != null) {
514 application.tracker.trackEvent('Finished sponsored subscription purchase', { category: 'Subscription' })
515 }
516 return this.update(render)
517 })
518 me.once('error', (user, response, options) => {
519 let left1
520 console.error('We got an error subscribing with Stripe from our server:', response)
521 stripeInfo = (left1 = me.get('stripe')) != null ? left1 : {}
522 delete stripeInfo.token
523 const {
524 xhr
525 } = options
526 if (xhr.status === 402) {
527 this.state = 'declined'
528 this.stateMessage = ''
529 } else {
530 this.state = 'unknown_error'
531 this.stateMessage = `${xhr.status}: ${xhr.responseText}`
532 }
533 return render()
534 })
535 return me.patch({ headers: { 'X-Change-Plan': 'true' } })
536 }
537
538 unsubscribe (email, id, render) {
539 delete this.state

Callers 1

onStripeReceivedTokenMethod · 0.80

Calls 7

updateMethod · 0.95
patchMethod · 0.80
cloneMethod · 0.45
getMethod · 0.45
setMethod · 0.45
trackEventMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected