mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-03-06 17:49:24 +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.
69 lines
1.4 KiB
JavaScript
69 lines
1.4 KiB
JavaScript
import componentTest from "helpers/component-test";
|
|
|
|
moduleForComponent("payment-plan", { integration: true });
|
|
|
|
componentTest("Payment plan subscription button rendered", {
|
|
template: `{{payment-plan
|
|
plan=plan
|
|
selectedPlan=selectedPlan
|
|
}}`,
|
|
|
|
beforeEach() {
|
|
this.set("plan", {
|
|
type: "recurring",
|
|
currency: "aud",
|
|
recurring: { interval: "year" },
|
|
amountDollars: "44.99"
|
|
});
|
|
},
|
|
|
|
async test(assert) {
|
|
assert.equal(
|
|
find(".btn-discourse-subscriptions-subscribe").length,
|
|
1,
|
|
"The payment button is shown"
|
|
);
|
|
|
|
assert.equal(
|
|
find(".btn-discourse-subscriptions-subscribe:first-child .interval")
|
|
.text()
|
|
.trim(),
|
|
"Yearly",
|
|
"The plan interval is shown -- Yearly"
|
|
);
|
|
|
|
assert.equal(
|
|
find(".btn-discourse-subscriptions-subscribe:first-child .amount")
|
|
.text()
|
|
.trim(),
|
|
"$AUD 44.99",
|
|
"The plan amount and currency is shown"
|
|
);
|
|
}
|
|
});
|
|
|
|
componentTest("Payment plan one-time-payment button rendered", {
|
|
template: `{{payment-plan
|
|
plan=plan
|
|
selectedPlan=selectedPlan
|
|
}}`,
|
|
|
|
beforeEach() {
|
|
this.set("plan", {
|
|
type: "one_time",
|
|
currency: "USD",
|
|
amountDollars: "3.99"
|
|
});
|
|
},
|
|
|
|
async test(assert) {
|
|
assert.equal(
|
|
find(".btn-discourse-subscriptions-subscribe:first-child .interval")
|
|
.text()
|
|
.trim(),
|
|
"One-Time Payment",
|
|
"Shown as one time payment"
|
|
);
|
|
}
|
|
});
|