mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-10-30 18:47:51 +00:00 
			
		
		
		
	cleanup code
This commit is contained in:
		| @@ -32,10 +32,6 @@ class Enterprise::Webhooks::StripeController < ActionController::API | |||||||
|     %w[ |     %w[ | ||||||
|       billing.credit_grant.created |       billing.credit_grant.created | ||||||
|       billing.credit_grant.expired |       billing.credit_grant.expired | ||||||
|       invoice.payment_failed |  | ||||||
|       invoice.payment_succeeded |  | ||||||
|       billing.alert.triggered |  | ||||||
|       v2.billing.pricing_plan_subscription.servicing_activated |  | ||||||
|     ].include?(event.type) |     ].include?(event.type) | ||||||
|   end |   end | ||||||
|  |  | ||||||
| @@ -52,32 +48,12 @@ class Enterprise::Webhooks::StripeController < ActionController::API | |||||||
|  |  | ||||||
|   def extract_customer_id(event) |   def extract_customer_id(event) | ||||||
|     data = event.data.object |     data = event.data.object | ||||||
|     candidate = customer_id_from_reader(data) || |  | ||||||
|                 customer_id_from_hash(data) || |  | ||||||
|                 customer_id_from_alert(data) |  | ||||||
|     candidate.presence |  | ||||||
|   end |  | ||||||
|  |  | ||||||
|   def customer_id_from_reader(data) |     # Credit grants have customer field | ||||||
|     return unless data.respond_to?(:customer) |     if data.respond_to?(:customer) | ||||||
|     return if data.customer.blank? |       data.customer | ||||||
|  |     elsif data.respond_to?(:[]) | ||||||
|     data.customer |       data['customer'] | ||||||
|   end |     end | ||||||
|  |  | ||||||
|   def customer_id_from_hash(data) |  | ||||||
|     return unless data.respond_to?(:[]) |  | ||||||
|  |  | ||||||
|     value = data['customer'] |  | ||||||
|     (value.presence) |  | ||||||
|   end |  | ||||||
|  |  | ||||||
|   def customer_id_from_alert(data) |  | ||||||
|     return unless data.respond_to?(:[]) |  | ||||||
|  |  | ||||||
|     customer = data.dig('credit_balance_threshold', 'customer') |  | ||||||
|     return unless customer.is_a?(Hash) |  | ||||||
|  |  | ||||||
|     customer['id'] |  | ||||||
|   end |   end | ||||||
| end | end | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Tanmay Sharma
					Tanmay Sharma