Files
astuto/app/workflows/create_stripe_customer.rb
Riccardo Graziosi f0346a73ec Add tour and other improvements (#348)
* Add tour
* Add instructions to set password for OAuth users
* Tenant signup improvement
* Fix bug on user soft delete
* Slighlty darken background color
* Add a stronger confirmation for board deletion
2024-05-21 19:10:18 +02:00

19 lines
462 B
Ruby

require 'stripe'
class CreateStripeCustomer
def run
tenant = Current.tenant_or_raise! # check that Current Tenant is set
owner = User.find_by(role: 'owner')
customer = Stripe::Customer.create({
email: owner.email,
name: owner.full_name,
metadata: {
site_name: tenant.site_name,
subdomain: tenant.subdomain,
},
})
tb = TenantBilling.first_or_create
tb.update!(customer_id: customer.id)
end
end