Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion app/components/events/view/publish-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ interface Event extends DS.Model { // eslint-disable-line ember-suave/no-direct-
identifier: string | null,
state: string,
name: string | null,
tickets: any[]
tickets: any[],
isStripeConnectionValid: boolean
}

interface EventsViewPublishBarArgs {
Expand Down Expand Up @@ -58,6 +59,12 @@ export default class EventsViewPublishBar extends Component<EventsViewPublishBar
id: 'event_tickets'
});
return;
} else if (event.isStripeConnectionValid) {
this.notify.error(this.l10n.t('You need to connect to your Stripe account, if you choose Stripe as a payment gateway.'),
{
id: 'event_stripe'
});
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate logic. Move in the event model

}
}
this.isLoading = true;
Expand Down
14 changes: 11 additions & 3 deletions app/mixins/event-wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,22 @@ export default Mixin.create(MutableArray, CustomFormMixin, {
saveDraft() {
this.onValid(() => {
preSaveActions.call(this);
this.set('data.event.state', 'draft');
this.sendAction('save');
if (this.data.event.isStripeConnectionValid) {
this.notify.error('You need to connect to your Stripe account, if you choose Stripe as a payment gateway.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the connection is valid, show an error?

} else {
this.set('data.event.state', 'draft');
this.sendAction('save');
}
});
},
saveForm() {
this.onValid(() => {
preSaveActions.call(this);
this.sendAction('save', this.data);
if (this.data.event.isStripeConnectionValid) {
this.notify.error('You need to connect to your Stripe account, if you choose Stripe as a payment gateway.');
} else {
this.sendAction('save', this.data);
}
});
},
move(direction) {
Expand Down
4 changes: 4 additions & 0 deletions app/models/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ export default class Event extends ModelBase.extend(CustomPrimaryKeyMixin, {

sessionsByState: computed('sessions', function() {
return groupBy(this.sessions.toArray(), 'data.state');
}),

isStripeConnectionValid: computed('canPayByStripe', 'stripeAuthorization.stripeAuthCode', 'stripeAuthorization.stripePublishableKey', function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is isStripeConnectionValid and returns true when the connection is invalid 😲

return this.canPayByStripe && !(this.stripeAuthorization.stripeAuthCode || this.stripeAuthorization.stripePublishableKey);
})

}) {}
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@
@checked={{this.data.event.canPayByStripe}} />
<label for="payment_by_stripe">
<span>{{t 'YES, accept payment through Stripe'}}</span>
<div class="ui hidden divider"></div>
<br>
<span class="text muted">
{{t 'Stripe accepts Visa, Master and Amex. Find out more about Stripe '}}
<a href="https://stripe.com/docs" target="_blank" rel="noopener noreferrer">{{t 'here'}}</a>.
Expand Down