validate plan
This commit is contained in:
parent
86bc9bb3e6
commit
ff1740d035
|
@ -15,6 +15,20 @@ export default Ember.Controller.extend({
|
|||
actions: {
|
||||
stripePaymentHandler() {
|
||||
this.set("loading", true);
|
||||
const plan = this.get("model.plans")
|
||||
.filterBy("selected")
|
||||
.get("firstObject");
|
||||
|
||||
if (!plan) {
|
||||
bootbox.alert(
|
||||
I18n.t(
|
||||
"discourse_subscriptions.transactions.payment.validate.plan.required"
|
||||
)
|
||||
);
|
||||
|
||||
this.set("loading", false);
|
||||
return;
|
||||
}
|
||||
|
||||
this.stripe.createToken(this.get("cardElement")).then(result => {
|
||||
if (result.error) {
|
||||
|
@ -31,11 +45,10 @@ export default Ember.Controller.extend({
|
|||
}).then(customer => {
|
||||
const subscription = this.get("model.subscription");
|
||||
|
||||
subscription.set("customer", customer.id);
|
||||
|
||||
if (subscription.get("plan") === undefined) {
|
||||
subscription.set("plan", this.get("model.plans.firstObject.id"));
|
||||
}
|
||||
subscription.setProperties({
|
||||
customer: customer.id,
|
||||
plan: plan.get("id")
|
||||
});
|
||||
|
||||
subscription
|
||||
.save()
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
|
||||
<button class="btn btn-primary">
|
||||
Purchase a subscription
|
||||
{{i18n "discourse_subscriptions.plans.purchase"}}
|
||||
</button>
|
||||
<button class="btn">
|
||||
{{!-- <button class="btn">
|
||||
Make just one payment
|
||||
</button>
|
||||
</button> --}}
|
||||
|
||||
<hr>
|
||||
|
||||
<p>Select subscription period</p>
|
||||
<p>
|
||||
{{i18n "discourse_subscriptions.plans.select"}}
|
||||
</p>
|
||||
|
||||
<div id="subscribe-buttons">
|
||||
{{#each plans as |plan|}}
|
||||
|
|
|
@ -21,11 +21,16 @@ en:
|
|||
transactions:
|
||||
payment:
|
||||
success: Your payment was successful
|
||||
validate:
|
||||
plan:
|
||||
required: Please select a subscription plan.
|
||||
navigation:
|
||||
subscriptions: Subscriptions
|
||||
subscribe: Subscribe
|
||||
billing: Billing
|
||||
plans:
|
||||
select: Select subscription period
|
||||
purchase: Purchase a subscription
|
||||
interval:
|
||||
adverb:
|
||||
week: Weekly
|
||||
|
|
Loading…
Reference in New Issue