mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2026-01-26 08:26:42 +00:00
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.
44 lines
988 B
JavaScript
44 lines
988 B
JavaScript
import componentTest from "helpers/component-test";
|
|
|
|
moduleForComponent("payment-options", { integration: true });
|
|
|
|
componentTest("Discourse Subscriptions payment options have no plans", {
|
|
template: `{{payment-options plans=plans}}`,
|
|
|
|
async test(assert) {
|
|
this.set("plans", false);
|
|
|
|
assert.equal(
|
|
find(".btn-discourse-subscriptions-subscribe").length,
|
|
0,
|
|
"The plan buttons are not shown"
|
|
);
|
|
}
|
|
});
|
|
|
|
componentTest("Discourse Subscriptions payment options has content", {
|
|
template: `{{payment-options
|
|
plans=plans
|
|
selectedPlan=selectedPlan
|
|
}}`,
|
|
|
|
beforeEach() {
|
|
this.set("plans", [
|
|
{
|
|
currency: "aud",
|
|
recurring: { interval: "year" },
|
|
amountDollars: "44.99"
|
|
},
|
|
{
|
|
currency: "gdp",
|
|
recurring: { interval: "month" },
|
|
amountDollars: "9.99"
|
|
}
|
|
]);
|
|
},
|
|
|
|
async test(assert) {
|
|
assert.equal(this.selectedPlan, null, "No plans are selected by default");
|
|
}
|
|
});
|