billing/subscriptions

This commit is contained in:
Rimian Perkins 2019-10-28 14:48:59 +11:00
parent 87c83abcd3
commit 5a7097b774
7 changed files with 23 additions and 0 deletions

View File

@ -21,6 +21,8 @@ module DiscoursePatrons
group.add(current_user)
end
DiscoursePatrons::Customer.create(user_id: current_user.id, customer_id: params[:customer])
render_json_dump @subscription
rescue ::Stripe::InvalidRequestError => e

View File

@ -3,5 +3,6 @@ export default {
path: "users/:username",
map() {
this.route("billing");
this.route("subscriptions");
}
};

View File

@ -2,6 +2,13 @@
<h3>{{i18n 'discourse_patrons.user.billing.title'}}</h3>
{{#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">
<thead>
<th>{{i18n 'discourse_patrons.user.billing.invoices.amount'}}</th>

View File

@ -0,0 +1,2 @@
<h3>{{i18n 'discourse_patrons.user.subscriptions.title'}}</h3>

View File

@ -21,6 +21,8 @@ en:
subscribe: Subscribe
billing: Billing
user:
subscriptions:
title: Subscriptions
billing_help: We couldn't find a customer identifier in our system.
billing:
title: Billing

View File

@ -20,6 +20,15 @@ module DiscoursePatrons
)
post "/patrons/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
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
describe "user groups" do