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

Method startPayPalSubscribe

app/views/core/SubscribeModal.js:185–208  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

183 }
184
185 startPayPalSubscribe () {
186 if (application.tracker != null) {
187 application.tracker.trackEvent('Started subscription purchase', { service: 'paypal' })
188 }
189 $('.purchase-button').addClass('disabled')
190 $('.purchase-button').html($.i18n.t('common.processing'))
191 return api.users.createBillingAgreement({ userID: me.id, productID: this.basicProduct.id })
192 .then(billingAgreement => {
193 for (const link of Array.from(billingAgreement.links)) {
194 if (link.rel === 'approval_url') {
195 if (application.tracker != null) {
196 application.tracker.trackEvent('Continue subscription purchase', { service: 'paypal', redirectUrl: link.href })
197 }
198 window.location = link.href
199 return
200 }
201 }
202 throw new Error(`PayPal billing agreement has no redirect link ${JSON.stringify(billingAgreement)}`)
203 }).catch(jqxhr => {
204 $('.purchase-button').removeClass('disabled')
205 $('.purchase-button').html($.i18n.t('premium_features.subscribe_now'))
206 return this.onSubscriptionError(jqxhr)
207 })
208 }
209
210 startStripeSubscribe () {
211 return this.startStripeSubscription(this.basicProduct)

Callers

nothing calls this directly

Calls 3

onSubscriptionErrorMethod · 0.95
trackEventMethod · 0.45
stringifyMethod · 0.45

Tested by

no test coverage detected