Created
December 5, 2020 11:23
-
-
Save panbanda/d4013239239c57c8adb6e8f7325305ab to your computer and use it in GitHub Desktop.
Migrating Stripe Subscriptions to Discourse Subscriptions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
::DiscourseSubscriptions::Subscription.all.each do |sub| | |
stripe_sub = ::Stripe::Subscription.retrieve(sub[:external_id]) | |
group_name = stripe_sub[:plan][:metadata][:group_name] | |
group = ::Group.find_by_name(group_name.downcase) | |
user = ::User.find(sub.customer.user_id) | |
group.add(user) if group | |
puts "#{group_name} #{group&.id} <- #{user.email}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment