1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-17 11:54:22 +01:00

remove reference to stripe in user creation workflow

This commit is contained in:
Sylvain 2021-06-14 15:14:14 +02:00
parent 7cfa2ca2c7
commit 27ac345588
4 changed files with 13 additions and 3 deletions

View File

@ -53,7 +53,7 @@ class User < ApplicationRecord
end
before_create :assign_default_role
after_commit :create_stripe_customer, on: [:create]
after_commit :create_gateway_customer, on: [:create]
after_commit :notify_admin_when_user_is_created, on: :create
after_create :init_dependencies
after_update :notify_group_changed, if: :saved_change_to_group_id?
@ -366,8 +366,8 @@ class User < ApplicationRecord
errors.add(:cgu, I18n.t('activerecord.errors.messages.empty')) if cgu == '0'
end
def create_stripe_customer
StripeWorker.perform_async(:create_stripe_customer, id)
def create_gateway_customer
PaymentGatewayService.new.create_user(id)
end
def send_devise_notification(notification, *args)

View File

@ -23,6 +23,10 @@ class PaymentGatewayService
@gateway.create_subscription(payment_schedule, gateway_object_id)
end
def create_user(user_id)
@gateway.create_user(user_id)
end
def create_coupon(coupon_id)
@gateway.create_coupon(coupon_id)
end

View File

@ -8,6 +8,8 @@ module Payment; end
class Payment::Service
def create_subscription(_payment_schedule, _gateway_object_id); end
def create_user(_user_id); end
def create_coupon(_coupon_id); end
def delete_coupon(_coupon_id); end

View File

@ -49,6 +49,10 @@ class Stripe::Service < Payment::Service
pgo.save!
end
def create_user(user_id)
StripeWorker.perform_async(:create_stripe_customer, user_id)
end
def create_coupon(coupon_id)
coupon = Coupon.find(coupon_id)
stp_coupon = { id: coupon.code }