billing/subscriptions
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -3,5 +3,6 @@ export default {
|
||||
path: "users/:username",
|
||||
map() {
|
||||
this.route("billing");
|
||||
this.route("subscriptions");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
<h3>{{i18n 'discourse_patrons.user.subscriptions.title'}}</h3>
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user