FEATURE: Allow one-time purchases on products (#18)
Building off the foundation of using the Prices API, this PR adds the ability to create a one-time purchase plan for any product, which then can add a user to the specified plan group.
Some things to be aware of:
One-time purchases cannot have trials.
One-time purchases use the Invoice API instead of Subscriptions. Invoices are created then charged immediately.
Users should receive emails for these invoices directly from Stripe just like subscriptions.
This commit is contained in:
@@ -1,22 +1,9 @@
|
||||
import { equal } from "@ember/object/computed";
|
||||
import Component from "@ember/component";
|
||||
|
||||
export default Component.extend({
|
||||
planButtonSelected: equal("planTypeIsSelected", true),
|
||||
paymentButtonSelected: equal("planTypeIsSelected", false),
|
||||
|
||||
actions: {
|
||||
selectPlans() {
|
||||
this.set("planTypeIsSelected", true);
|
||||
},
|
||||
|
||||
selectPayments() {
|
||||
this.set("planTypeIsSelected", false);
|
||||
},
|
||||
|
||||
clickPlan(plan) {
|
||||
this.plans.map(p => p.set("selected", false));
|
||||
plan.set("selected", true);
|
||||
this.set("selectedPlan", plan.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import Component from "@ember/component";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
|
||||
const RECURRING = "recurring";
|
||||
|
||||
export default Component.extend({
|
||||
@discourseComputed("selectedPlan")
|
||||
selected(planId) {
|
||||
return planId === this.plan.id;
|
||||
},
|
||||
|
||||
@discourseComputed("plan.type")
|
||||
recurringPlan(type) {
|
||||
return type === RECURRING;
|
||||
},
|
||||
|
||||
actions: {
|
||||
planClick() {
|
||||
this.clickPlan(this.plan);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user