1
0
mirror of synced 2026-08-03 21:56:54 +00:00

fix trial period

This commit is contained in:
Rimian Perkins
2019-10-23 10:16:17 +11:00
parent 296d5eff1b
commit c6bf9ca4d3
8 changed files with 16 additions and 22 deletions
+2 -1
View File
@@ -24,7 +24,8 @@ module DiscoursePatrons
nickname: params[:nickname],
amount: params[:amount],
interval: params[:interval],
product: params[:product_id],
product: params[:product],
trial_period_days: params[:trial_period_days],
currency: SiteSetting.discourse_patrons_currency,
)
@@ -11,7 +11,7 @@ export default Ember.Controller.extend({
},
createPlan() {
const product_id = this.get('model.plan.product_id');
const product_id = this.get('model.plan.product');
this.get('model.plan').save().then(result => this.redirect(product_id));
}
}
@@ -6,13 +6,6 @@ export default {
this.route("discourse-patrons", function() {
this.route("dashboard");
// this.route("products", function() {
// this.route("plans", { path: "/:product-id/plans" }, function() {
// this.route("show", { path: ":plan-id" });
// });
// this.route("show", { path: "/:product-id" });
// });
this.route("products", function() {
this.route("show", { path: "/:product-id" }, function() {
this.route("plans", function() {
@@ -21,10 +14,6 @@ export default {
});
});
// this.route("plans", function() {
// this.route("show", { path: "/:plan-id" });
// });
this.route("subscriptions");
});
}
@@ -21,7 +21,8 @@ const AdminPlan = Discourse.Model.extend({
nickname: this.nickname,
interval: this.interval,
amount: this.amount,
product_id: this.product_id
trial_period_days: this.trial_period_days,
product: this.product
};
return ajax("/patrons/admin/plans", { method: "post", data });
@@ -8,7 +8,7 @@ export default Discourse.Route.extend({
let plan;
if(id === 'new') {
plan = AdminPlan.create({ product_id: product.get('id') });
plan = AdminPlan.create({ product: product.get('id') });
}
else {
plan = AdminPlan.find(id);
@@ -4,8 +4,6 @@ import Group from "discourse/models/group";
export default Discourse.Route.extend({
model(params) {
console.log('products show', params);
const product_id = params['product-id'];
let product;
let plans = [];
@@ -22,7 +22,7 @@
{{i18n 'discourse_patrons.admin.plans.plan.trial'}}
({{i18n 'discourse_patrons.optional'}})
</label>
{{input type="text" name="trial" value=model.plan.trial}}
{{input type="text" name="trial" value=model.plan.trial_period_days}}
<div class="control-instructions">
{{i18n 'discourse_patrons.admin.plans.plan.trial_help'}}
</div>
@@ -38,12 +38,12 @@
<section>
<hr>
<div class="control-instructions">
<p class="control-instructions">
{{i18n 'discourse_patrons.admin.plans.operations.create_help'}}
</div>
</p>
<div class="pull-right">
{{d-button label="cancel" action=(action "cancelPlan" model.plan.product_id) icon="times"}}
{{d-button label="cancel" action=(action "cancelPlan" model.plan.product) icon="times"}}
{{d-button label="discourse_patrons.admin.plans.operations.create" action="createPlan" icon="plus" class="btn btn-primary"}}
</div>
+6 -1
View File
@@ -98,9 +98,14 @@ module DiscoursePatrons
post "/patrons/admin/plans.json", params: { amount: '102' }
end
it "creates a plan with a trial period" do
::Stripe::Plan.expects(:create).with(has_entry(:trial_period_days, '14'))
post "/patrons/admin/plans.json", params: { trial_period_days: '14' }
end
it "creates a plan with a product" do
::Stripe::Plan.expects(:create).with(has_entry(product: 'prod_walterwhite'))
post "/patrons/admin/plans.json", params: { product_id: 'prod_walterwhite' }
post "/patrons/admin/plans.json", params: { product: 'prod_walterwhite' }
end
end