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