compensated 0.1.0.pre3 → 0.1.0.pre4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/compensated/gumroad/event_parser.rb +10 -1
- data/lib/compensated/stripe/event_parser.rb +51 -4
- data/lib/compensated/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac2ec14d09df8e16e45e2d6dbbdd0568eea83ad4e19c386f2b2b4a413093c893
|
4
|
+
data.tar.gz: a09cbd7eb77b776ab13aa363674554ebbbb59281096bb782ad89469b75d296ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db258bc5034fed17c0e0e0983898c77b8eabc8f81cd049247ee99998abaddb3b6a9cbfde2bbdb548a35621ad493cea26b38d0c9cffb1f1d23409c0df1dd614a7
|
7
|
+
data.tar.gz: 0b88d6ff66324262a2b912ad1e9382d4e5184acdf111ece2c353fd801ca7fce9bdd73cb7db52f39d25dd3bb719a6af2fb6df3e1b4154580ebb345059579aed86
|
data/Gemfile.lock
CHANGED
@@ -20,7 +20,16 @@ module Compensated
|
|
20
20
|
raw_body: body,
|
21
21
|
raw_event_type: request.data["resource_name"].to_sym,
|
22
22
|
raw_event_id: nil,
|
23
|
-
payment_processor: :gumroad
|
23
|
+
payment_processor: :gumroad,
|
24
|
+
amount: {
|
25
|
+
paid: request.data["price"].to_i,
|
26
|
+
currency: request.data["currency"].upcase,
|
27
|
+
},
|
28
|
+
customer: {
|
29
|
+
id: request.data["purchaser_id"].to_s,
|
30
|
+
email: request.data["email"],
|
31
|
+
name: request.data["full_name"],
|
32
|
+
},
|
24
33
|
}
|
25
34
|
end
|
26
35
|
end
|
@@ -7,14 +7,61 @@ module Compensated
|
|
7
7
|
SUPPORTED_EVENTS.include?(request.data[:type])
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def normalize(data)
|
11
|
+
data = Compensated.json_adapter.parse(data) unless data.respond_to?(:key)
|
11
12
|
{
|
12
|
-
raw_body: Compensated.json_adapter.dump(
|
13
|
-
raw_event_type:
|
14
|
-
raw_event_id:
|
13
|
+
raw_body: Compensated.json_adapter.dump(data),
|
14
|
+
raw_event_type: data[:type].to_sym,
|
15
|
+
raw_event_id: data[:id],
|
15
16
|
payment_processor: :stripe,
|
17
|
+
amount: amount(data),
|
18
|
+
customer: customer(data),
|
16
19
|
}
|
17
20
|
end
|
21
|
+
|
22
|
+
def parse(request)
|
23
|
+
normalize(request.data)
|
24
|
+
end
|
25
|
+
|
26
|
+
private def customer(data)
|
27
|
+
if invoice?(data)
|
28
|
+
{
|
29
|
+
email: data[:data][:object][:customer_email],
|
30
|
+
name: data[:data][:object][:customer_name],
|
31
|
+
id: data[:data][:object][:customer],
|
32
|
+
}.compact
|
33
|
+
else
|
34
|
+
{
|
35
|
+
id: data[:data][:object][:customer],
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
private def amount(data)
|
41
|
+
{
|
42
|
+
currency: data[:data][:object][:currency].upcase,
|
43
|
+
due: due(data),
|
44
|
+
paid: paid(data),
|
45
|
+
remaining: remaining(data),
|
46
|
+
}.compact
|
47
|
+
end
|
48
|
+
|
49
|
+
private def paid(data)
|
50
|
+
return data[:data][:object][:amount_paid] if invoice?(data)
|
51
|
+
data[:data][:object][:amount]
|
52
|
+
end
|
53
|
+
|
54
|
+
private def remaining(data)
|
55
|
+
data.fetch(:data, {}).fetch(:object, {}).fetch(:amount_remaining, nil)
|
56
|
+
end
|
57
|
+
|
58
|
+
private def due(data)
|
59
|
+
data.fetch(:data, {}).fetch(:object, {}).fetch(:amount_due, nil)
|
60
|
+
end
|
61
|
+
|
62
|
+
private def invoice?(data)
|
63
|
+
data[:data][:object][:object] == "invoice"
|
64
|
+
end
|
18
65
|
end
|
19
66
|
end
|
20
67
|
|
data/lib/compensated/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compensated
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.pre4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zee
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|