(render)
| 197 | } |
| 198 | |
| 199 | subscribe (render) { |
| 200 | let left |
| 201 | if (!this.prepaidCode) { return } |
| 202 | |
| 203 | if (this.prepaidCode === __guard__(me.get('stripe'), x => x.prepaidCode)) { |
| 204 | delete this.prepaidCode |
| 205 | return render() |
| 206 | } |
| 207 | |
| 208 | this.state = 'subscribing' |
| 209 | this.stateMessage = '' |
| 210 | render() |
| 211 | |
| 212 | let stripeInfo = _.clone((left = me.get('stripe')) != null ? left : {}) |
| 213 | stripeInfo.planID = basicPlanID |
| 214 | stripeInfo.prepaidCode = this.prepaidCode |
| 215 | me.set('stripe', stripeInfo) |
| 216 | |
| 217 | me.once('sync', () => { |
| 218 | if (application.tracker != null) { |
| 219 | application.tracker.trackEvent('Finished subscription purchase', { value: 0, category: 'Subscription' }) |
| 220 | } |
| 221 | delete this.prepaidCode |
| 222 | return this.update(render) |
| 223 | }) |
| 224 | me.once('error', (user, response, options) => { |
| 225 | let left1 |
| 226 | console.error('We got an error subscribing with Stripe from our server:', response) |
| 227 | stripeInfo = (left1 = me.get('stripe')) != null ? left1 : {} |
| 228 | delete stripeInfo.planID |
| 229 | delete stripeInfo.prepaidCode |
| 230 | me.set('stripe', stripeInfo) |
| 231 | const { |
| 232 | xhr |
| 233 | } = options |
| 234 | if (xhr.status === 402) { |
| 235 | this.state = 'declined' |
| 236 | this.stateMessage = '' |
| 237 | } else { |
| 238 | if (xhr.status === 403) { |
| 239 | delete this.prepaidCode |
| 240 | } |
| 241 | this.state = 'unknown_error' |
| 242 | this.stateMessage = `${xhr.status}: ${xhr.responseText}` |
| 243 | } |
| 244 | return render() |
| 245 | }) |
| 246 | return me.patch({ headers: { 'X-Change-Plan': 'true' } }) |
| 247 | } |
| 248 | |
| 249 | unsubscribe (message, render) { |
| 250 | const payPalInfo = me.get('payPal') |
no test coverage detected