Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 12 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,12 @@ interface Event extends DS.Model { // eslint-disable-line ember-suave/no-direct-
identifier: string | null,
state: string,
name: string | null,
tickets: any[]
tickets: any[],
canPayByStripe: boolean,
stripeAuthorization:{
stripePublishableKey: boolean,
stripeAuthCode: boolean,
},
}

interface EventsViewPublishBarArgs {
Expand Down Expand Up @@ -58,6 +63,12 @@ export default class EventsViewPublishBar extends Component<EventsViewPublishBar
id: 'event_tickets'
});
return;
} else if (event.canPayByStripe && !(event.stripeAuthorization.stripeAuthCode || event.stripeAuthorization.stripePublishableKey)) {
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.canPayByStripe && !(this.data.event.stripeAuthorization.stripeAuthCode || this.data.event.stripeAuthorization.stripePublishableKey)) {
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.canPayByStripe && !(this.data.event.stripeAuthorization.stripeAuthCode || this.data.event.stripeAuthorization.stripePublishableKey)) {
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
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