Skip to content

Commit b1658f4

Browse files
authored
Fix stripe (#3034)
1 parent 1b784ae commit b1658f4

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

app/components/forms/wizard/basic-details-step.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,6 @@ export default Component.extend(FormMixin, EventWizardMixin, {
114114
if (!this.isCreate && this.get('data.event.copyright') && !this.get('data.event.copyright.content')) {
115115
this.set('data.event.copyright', this.store.createRecord('event-copyright'));
116116
}
117-
if (!this.isCreate && this.get('data.event.stripeAuthorization') && !this.get('data.event.stripeAuthorization.content')) {
118-
this.set('data.event.stripeAuthorization', this.store.createRecord('stripe-authorization'));
119-
}
120117
},
121118

122119
getValidationRules() {
@@ -328,17 +325,24 @@ export default Component.extend(FormMixin, EventWizardMixin, {
328325

329326
actions: {
330327
connectStripe() {
331-
this.get('data.event.stripeAuthorization.content') || this.set('data.event.stripeAuthorization', this.store.createRecord('stripe-authorization'));
332328
this.torii.open('stripe')
333329
.then(authorization => {
334-
this.set('data.event.stripeAuthorization.stripeAuthCode', authorization.authorizationCode);
330+
this.set('data.event.stripeAuthorization', this.store.createRecord('stripe-authorization', {
331+
stripeAuthCode : authorization.authorizationCode,
332+
stripePublishableKey : this.settings.stripePublishableKey
333+
}));
335334
})
336335
.catch(error => {
337336
this.notify.error(this.l10n.t(`${error.message}. Please try again`));
338337
});
339338
},
340-
disconnectStripe() {
341-
this.get('data.event.stripeAuthorization.content').destroyRecord();
339+
async disconnectStripe() {
340+
let stripeAuthorization = await this.get('data.event.stripeAuthorization');
341+
stripeAuthorization.destroyRecord()
342+
.then(() => {
343+
this.notify.success(this.l10n.t('Stripe disconnected successfully'));
344+
});
345+
342346
},
343347
addTicket(type, position) {
344348
const event = this.get('data.event');

app/mixins/event-wizard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default Mixin.create(MutableArray, CustomFormMixin, {
4747
try {
4848
data[property] = await event.get(property);
4949
} catch (e) {
50-
if (!(e.errors && e.errors.length && e.errors.length > 0 && e.errors[status] === 404)) {
50+
if (!(e.errors && e.errors.length && e.errors.length > 0 && e.errors[0].status === 404)) {
5151
// Lets just ignore any 404s that might occur. And throw the rest for the caller fn to catch
5252
throw e;
5353
}

0 commit comments

Comments
 (0)