wbase 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e2739df0eaa1ab969f5c463f520feb70aa730378
4
- data.tar.gz: 354338695deda37ee45eb2535729e24efb571cec
3
+ metadata.gz: 0da7673bb1b93eca136794b6eaec45f62fff95d9
4
+ data.tar.gz: c0e114f804348b08d1c46b81ccc9b25caf28cdbd
5
5
  SHA512:
6
- metadata.gz: adbf153e28673b2c44226fbe85c73bf19f180aba1f8f1da6726ec2c3b25b0cba9c7b0c50fee5e7e23db9fb39acd3fd9e137c28c3886c14938c014171807cbca5
7
- data.tar.gz: 8a2b057dc77b05da316c3203184d236045bbc859a74e5d0b8cc7de5cdb26e64280f5d1a2e719a356a3d47687db08fd1e41342093149e1f23b894d218934f9900
6
+ metadata.gz: 84fcbbf0757cc61f81e6aedc655c94bddb9437d330df94805610049a7f136a652a999f40d3dd90e3dbdbeb121dc4004324181f07abaeff8723164c1e7c831783
7
+ data.tar.gz: 5f570dae875931a11bfba65ec73dfa2e127fa03d7d8be49913eb8f373beb9a0f4fd0732a57c6cdf7a5823ca0ab238a2fbbdbceffa83a846922ab46f2719a5673
@@ -8,6 +8,7 @@ module Wbase
8
8
  @event = StripeWebhook.new(event_params)
9
9
 
10
10
  if @event.save
11
+ @event.process!
11
12
  render json: @event
12
13
  else
13
14
  render json: @event.errors.full_messages, status: :unprocessable_entity
@@ -18,5 +18,23 @@
18
18
 
19
19
  module Wbase
20
20
  class StripeWebhook < ActiveRecord::Base
21
+ def process!
22
+ if external_type == 'customer.subscription.updated'
23
+ subscription = Subscription.find_by(stripe_id: customer_stripe_id)
24
+ subscription.update(paid_thru: Time.at(paid_thru))
25
+ end
26
+ end
27
+
28
+ def customer_stripe_id
29
+ get("customer")
30
+ end
31
+
32
+ def paid_thru
33
+ data.fetch("object", {}).fetch("current_period_end")
34
+ end
35
+
36
+ def get(key)
37
+ data.fetch("object", {}).fetch(key)
38
+ end
21
39
  end
22
40
  end
data/lib/wbase/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wbase
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - CJ Avilla
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-08 00:00:00.000000000 Z
11
+ date: 2016-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails