effective_orders 4.0.2 → 4.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b5a91a9aee45dd22835d990a8a86debf6f6bb93
4
- data.tar.gz: 9f246825aef174e7796f65a3d7f8a7d156cd8bbb
3
+ metadata.gz: 0d4870a5fe33fa214673827989e18d0fffb52025
4
+ data.tar.gz: e2eee7d058341602182405e8e527dff323a4eed9
5
5
  SHA512:
6
- metadata.gz: 290d57dfbef5bd79dcedc48d55a64d16583e9dafdc912e09656baa9c7a4fda2e49bef8fc11e8526fe9532f22b6dde363516f01e70e6aefa0f446dc2c13844dbb
7
- data.tar.gz: 4f4fa278897534b968aa8abcec312f67f4fbfc74b06b2c75cc9c536e0eeff59158e1fb792d72a575895ac14e84c75951b0945d1a1906f1947895d422101b2af7
6
+ metadata.gz: e5028380b88bd4f21802ecb2bf34ea25edd1de4a798110605a67d1bee00f27970c568152add9165d4469ea41b5ee03c818adc834c731d3b56b007d64bc0f529e
7
+ data.tar.gz: a6b792c03e03954cf3d30eb99368ccdc9afa05adec843b0b5b001a84e400592f17e2327523b193fac1014a6b3ae12c424ac175b4d6d6312f69315e4d7fa629e8
@@ -17,13 +17,14 @@ module Effective
17
17
 
18
18
  def stripe
19
19
  @event = (Stripe::Webhook.construct_event(request.body.read, request.env['HTTP_STRIPE_SIGNATURE'], EffectiveOrders.subscriptions[:webhook_secret]) rescue nil)
20
+ (head(:ok) and return) if request.get? && @event.blank?
20
21
  (head(:bad_request) and return) unless @event
21
22
 
22
23
  unless EffectiveOrders.subscriptions[:ignore_livemode]
23
24
  (head(:bad_request) and return) if (params[:livemode] == false && Rails.env.production?)
24
25
  end
25
26
 
26
- Rails.logger.info "[STRIPE] webhook received: #{@event.type} for #{customer || 'unknown customer'}" # Customer must be called here
27
+ Rails.logger.info "[STRIPE] webhook received: #{@event.type} for #{customer || 'no customer'}"
27
28
 
28
29
  Effective::Customer.transaction do
29
30
  case @event.type
@@ -58,7 +59,7 @@ module Effective
58
59
  when 'customer.subscription.updated'
59
60
  send_email(:subscription_updated, customer)
60
61
  else
61
- Rails.logger.info "[STRIPE] webhook unhandled event type: #{@event.type}"
62
+ Rails.logger.info "[STRIPE] successful event: #{@event.type}. Nothing to do."
62
63
  end
63
64
  end
64
65
 
@@ -74,7 +75,7 @@ module Effective
74
75
  stripe_customer_id = @event.data.object.customer if @event.data.object.respond_to?(:customer)
75
76
  stripe_customer_id = @event.data.object.id if @event.data.object.object == 'customer'
76
77
 
77
- Effective::Customer.where(stripe_customer_id: stripe_customer_id || 'unknown').first!
78
+ Effective::Customer.where(stripe_customer_id: stripe_customer_id || 'none').first
78
79
  )
79
80
  end
80
81
 
@@ -84,7 +85,7 @@ module Effective
84
85
  end
85
86
 
86
87
  def run_subscribable_buyer_callbacks!
87
- return if @event.blank? || @customer.blank?
88
+ return true if (@event.blank? || @customer.blank?)
88
89
 
89
90
  name = ('after_' + @event.type.to_s.gsub('.', '_')).to_sym
90
91
  buyer = @customer.user
data/config/routes.rb CHANGED
@@ -29,7 +29,7 @@ EffectiveOrders::Engine.routes.draw do
29
29
 
30
30
  match 'customer/settings', to: 'customers#edit', as: :customer_settings, via: [:get]
31
31
  match 'customer/settings', to: 'customers#update', via: [:patch, :put, :post]
32
- match 'webhooks/stripe', to: 'webhooks#stripe', via: [:post, :put]
32
+ match 'webhooks/stripe', to: 'webhooks#stripe', via: [:get, :post, :put]
33
33
  end
34
34
 
35
35
  match 'cart', to: 'carts#show', as: 'cart', via: :get
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '4.0.2'.freeze
2
+ VERSION = '4.0.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_orders
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.2
4
+ version: 4.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-25 00:00:00.000000000 Z
11
+ date: 2018-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails