add user data to subscription metadata

This commit is contained in:
Rimian Perkins 2019-11-13 10:19:49 +11:00
parent 59638daad9
commit 84fd12a9a3
2 changed files with 4 additions and 2 deletions

View File

@ -30,7 +30,8 @@ module DiscoursePatrons
@subscription = ::Stripe::Subscription.create(
customer: params[:customer],
items: [ { plan: params[:plan] } ]
items: [ { plan: params[:plan] } ],
metadata: { username_lower: current_user.username_lower },
)
group = plan_group(plan)

View File

@ -24,7 +24,8 @@ module DiscoursePatrons
::Stripe::Plan.expects(:retrieve).returns(metadata: { group_name: 'awesome' })
::Stripe::Subscription.expects(:create).with(
customer: 'cus_1234',
items: [ plan: 'plan_1234' ]
items: [ plan: 'plan_1234' ],
metadata: { username_lower: user.username_lower },
)
post "/patrons/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
end