mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-30 19:52:20 +01:00
task to reset the stripe payment methods in test mode
This commit is contained in:
parent
d0011a10f0
commit
28e41de9ad
@ -8,6 +8,8 @@
|
|||||||
- Improved the style of the titles of the subscription page
|
- Improved the style of the titles of the subscription page
|
||||||
- Check the status of the assets' compilation during the upgrade
|
- Check the status of the assets' compilation during the upgrade
|
||||||
- Footprints are now generated in a more reproductible way
|
- Footprints are now generated in a more reproductible way
|
||||||
|
- Task to reset the stripe payment methods in test mode
|
||||||
|
- Validate on server side the reservation of slots restricted to subscribers
|
||||||
- Fix a bug: build status badge is not working
|
- Fix a bug: build status badge is not working
|
||||||
- Fix a bug: unable to set date formats during installation
|
- Fix a bug: unable to set date formats during installation
|
||||||
- Fix a bug: unable to cancel the upgrade before it begins
|
- Fix a bug: unable to cancel the upgrade before it begins
|
||||||
|
@ -11,7 +11,7 @@ class SyncMembersOnStripeWorker
|
|||||||
User.online_payers.each_with_index do |member, index|
|
User.online_payers.each_with_index do |member, index|
|
||||||
logger.debug "#{index} / #{total}"
|
logger.debug "#{index} / #{total}"
|
||||||
begin
|
begin
|
||||||
stp_customer = member.payment_gateway_objects.gateway_object.retrieve
|
stp_customer = member.payment_gateway_object.gateway_object.retrieve
|
||||||
StripeWorker.new.create_stripe_customer(member.id) if stp_customer.nil? || stp_customer[:deleted]
|
StripeWorker.new.create_stripe_customer(member.id) if stp_customer.nil? || stp_customer[:deleted]
|
||||||
rescue Stripe::InvalidRequestError
|
rescue Stripe::InvalidRequestError
|
||||||
StripeWorker.new.create_stripe_customer(member.id)
|
StripeWorker.new.create_stripe_customer(member.id)
|
||||||
|
@ -78,6 +78,25 @@ namespace :fablab do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# in test, we may reach a point when the maximum number of payment methods attachable to a customer is reached.
|
||||||
|
# Use this task to reset them all and be able to run the test suite again.
|
||||||
|
desc 'remove cards payment methods from all customers'
|
||||||
|
task reset_cards: :environment do
|
||||||
|
unless Rails.env.test?
|
||||||
|
print "You're about to detach all payment cards from all customers. This was only made for test mode. Are you sure? (y/n) "
|
||||||
|
confirm = STDIN.gets.chomp
|
||||||
|
next unless confirm == 'y'
|
||||||
|
end
|
||||||
|
User.all.each do |user|
|
||||||
|
stp_customer = user.payment_gateway_object.gateway_object.retrieve
|
||||||
|
cards = Stripe::PaymentMethod.list({ customer: stp_customer, type: 'card' }, { api_key: Setting.get('stripe_secret_key') })
|
||||||
|
cards.each do |card|
|
||||||
|
pm = Stripe::PaymentMethod.retrieve(card.id, api_key: Setting.get('stripe_secret_key'))
|
||||||
|
pm.detach
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def print_on_line(str)
|
def print_on_line(str)
|
||||||
print "#{str}\r"
|
print "#{str}\r"
|
||||||
$stdout.flush
|
$stdout.flush
|
||||||
|
Loading…
x
Reference in New Issue
Block a user