billing/subscriptions
This commit is contained in:
parent
87c83abcd3
commit
5a7097b774
|
@ -21,6 +21,8 @@ module DiscoursePatrons
|
||||||
group.add(current_user)
|
group.add(current_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
DiscoursePatrons::Customer.create(user_id: current_user.id, customer_id: params[:customer])
|
||||||
|
|
||||||
render_json_dump @subscription
|
render_json_dump @subscription
|
||||||
|
|
||||||
rescue ::Stripe::InvalidRequestError => e
|
rescue ::Stripe::InvalidRequestError => e
|
||||||
|
|
|
@ -3,5 +3,6 @@ export default {
|
||||||
path: "users/:username",
|
path: "users/:username",
|
||||||
map() {
|
map() {
|
||||||
this.route("billing");
|
this.route("billing");
|
||||||
|
this.route("subscriptions");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,6 +2,13 @@
|
||||||
<h3>{{i18n 'discourse_patrons.user.billing.title'}}</h3>
|
<h3>{{i18n 'discourse_patrons.user.billing.title'}}</h3>
|
||||||
|
|
||||||
{{#if model}}
|
{{#if model}}
|
||||||
|
<p class="btn-right">
|
||||||
|
{{#link-to 'user.subscriptions' class="btn btn-primary"}}
|
||||||
|
{{d-icon "credit-card"}}
|
||||||
|
<span>{{i18n 'discourse_patrons.user.subscriptions.title'}}</span>
|
||||||
|
{{/link-to}}
|
||||||
|
</p>
|
||||||
|
|
||||||
<table class="topic-list">
|
<table class="topic-list">
|
||||||
<thead>
|
<thead>
|
||||||
<th>{{i18n 'discourse_patrons.user.billing.invoices.amount'}}</th>
|
<th>{{i18n 'discourse_patrons.user.billing.invoices.amount'}}</th>
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
<h3>{{i18n 'discourse_patrons.user.subscriptions.title'}}</h3>
|
|
@ -21,6 +21,8 @@ en:
|
||||||
subscribe: Subscribe
|
subscribe: Subscribe
|
||||||
billing: Billing
|
billing: Billing
|
||||||
user:
|
user:
|
||||||
|
subscriptions:
|
||||||
|
title: Subscriptions
|
||||||
billing_help: We couldn't find a customer identifier in our system.
|
billing_help: We couldn't find a customer identifier in our system.
|
||||||
billing:
|
billing:
|
||||||
title: Billing
|
title: Billing
|
||||||
|
|
|
@ -20,6 +20,15 @@ module DiscoursePatrons
|
||||||
)
|
)
|
||||||
post "/patrons/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
|
post "/patrons/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "creates a customer" do
|
||||||
|
::Stripe::Plan.expects(:retrieve).returns(metadata: {})
|
||||||
|
::Stripe::Subscription.expects(:create).returns(status: 'active')
|
||||||
|
|
||||||
|
expect {
|
||||||
|
post "/patrons/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
|
||||||
|
}.to change { DiscoursePatrons::Customer.count }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "user groups" do
|
describe "user groups" do
|
||||||
|
|
Loading…
Reference in New Issue