(tokenID, render)
| 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 |
no test coverage detected