create a customer when a payment happens

This commit is contained in:
Rimian Perkins
2019-12-17 10:03:00 +11:00
parent 92f6569f9f
commit fcfd2be41b
2 changed files with 17 additions and 2 deletions
+11 -1
View File
@@ -11,12 +11,22 @@ module DiscourseSubscriptions
def create
begin
customer = ::Stripe::Customer.create(
email: current_user.email,
)
DiscourseSubscriptions::Customer.create(
user_id: current_user.id,
customer_id: customer[:id],
)
payment = ::Stripe::PaymentIntent.create(
payment_method_types: ['card'],
payment_method: params[:payment_method],
amount: params[:amount],
currency: params[:currency],
confirm: true
confirm: true,
customer: customer[:id],
)
render_json_dump payment