ravelin 0.1.6 → 0.1.7
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 +4 -4
- data/lib/ravelin.rb +1 -0
- data/lib/ravelin/event.rb +29 -33
- data/lib/ravelin/transaction.rb +31 -20
- data/lib/ravelin/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c386b1036368c92c7f077bbefccf8e42addf9b6
|
4
|
+
data.tar.gz: 5129f6ff9570d295569498722cc0ce7f3488588d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dad24150d4298d44d139f696f4c9f608d968e21aef21e572e299ec73a65b87b213e29ed4eb65d768b8927de70978dfe405c7871207ffbbc38bbba5acae2eec49
|
7
|
+
data.tar.gz: 655c9c5577f278fa94777bc5dbc2e146fe0fb016bea995167688d82498076a1a1dc993ccf7898db50030bc5934a92dc48d081fdfd57bd8135d6ae988b4a34652
|
data/lib/ravelin.rb
CHANGED
data/lib/ravelin/event.rb
CHANGED
@@ -11,7 +11,7 @@ module Ravelin
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def serializable_hash
|
14
|
-
payload_hash = hash_map(
|
14
|
+
payload_hash = hash_map(payload) do |k, v|
|
15
15
|
k = Ravelin.camelize(k)
|
16
16
|
|
17
17
|
if v.is_a?(Ravelin::RavelinObject)
|
@@ -33,7 +33,7 @@ module Ravelin
|
|
33
33
|
order: Order,
|
34
34
|
payment_method: PaymentMethod,
|
35
35
|
voucher_redemption: VoucherRedemption,
|
36
|
-
transaction:
|
36
|
+
transaction: name == :pretransaction ? PreTransaction : Transaction,
|
37
37
|
label: Label,
|
38
38
|
voucher: Voucher,
|
39
39
|
}
|
@@ -44,56 +44,52 @@ module Ravelin
|
|
44
44
|
def validate_top_level_payload_params
|
45
45
|
validate_customer_id_presence_on :order, :paymentmethod,
|
46
46
|
:pretransaction, :transaction, :label
|
47
|
-
case
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
47
|
+
case name
|
48
|
+
when :customer
|
49
|
+
validate_payload_inclusion_of :customer
|
50
|
+
when :voucher
|
51
|
+
validate_payload_inclusion_of :voucher
|
52
|
+
when :'paymentmethod/voucher'
|
53
|
+
validate_payload_inclusion_of :'voucher_redemption'
|
54
|
+
when :pretransaction, :transaction
|
55
|
+
validate_payload_must_include_one_of(
|
56
|
+
:payment_method_id, :payment_method
|
57
|
+
)
|
58
|
+
validate_payload_inclusion_of :order_id
|
59
|
+
when :login
|
60
|
+
validate_payload_inclusion_of :customer_id
|
61
|
+
when :checkout
|
62
|
+
validate_payload_inclusion_of :customer, :order,
|
63
|
+
:payment_method, :transaction
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
def validate_customer_id_presence_on(*events)
|
68
|
-
if events.include?(
|
69
|
-
raise ArgumentError
|
70
|
-
new(%q{payload missing customer_id or temp_customer_id parameter})
|
68
|
+
if events.include?(name) && !payload_customer_reference_present?
|
69
|
+
raise ArgumentError, 'payload missing customer_id or temp_customer_id parameter'
|
71
70
|
end
|
72
71
|
end
|
73
72
|
|
74
73
|
def validate_payload_inclusion_of(*required_keys)
|
75
|
-
missing = required_keys -
|
74
|
+
missing = required_keys - payload.keys
|
76
75
|
|
77
76
|
if missing.any?
|
78
|
-
raise ArgumentError.
|
79
|
-
new(%Q{payload missing parameters: #{missing.join(', ')}})
|
77
|
+
raise ArgumentError, "payload missing parameters: #{missing.join(', ')}"
|
80
78
|
end
|
81
79
|
end
|
82
80
|
|
83
81
|
def validate_payload_must_include_one_of(*mutually_exclusive_keys)
|
84
|
-
intersection = mutually_exclusive_keys &
|
82
|
+
intersection = mutually_exclusive_keys & payload.keys
|
85
83
|
|
86
84
|
if intersection.size > 1
|
87
|
-
raise ArgumentError
|
88
|
-
|
89
|
-
|
90
|
-
raise ArgumentError
|
91
|
-
.new(%Q{payload must include one of: #{mutually_exclusive_keys.join(', ')}})
|
85
|
+
raise ArgumentError, "parameters are mutally exclusive: #{mutually_exclusive_keys.join(', ')}"
|
86
|
+
elsif intersection.empty?
|
87
|
+
raise ArgumentError, "payload must include one of: #{mutually_exclusive_keys.join(', ')}"
|
92
88
|
end
|
93
89
|
end
|
94
90
|
|
95
91
|
def payload_customer_reference_present?
|
96
|
-
|
92
|
+
payload.keys.any? { |k| %i[customer_id temp_customer_id].include? k }
|
97
93
|
end
|
98
94
|
|
99
95
|
def convert_to_epoch(val)
|
@@ -102,7 +98,7 @@ module Ravelin
|
|
102
98
|
elsif val.is_a?(Integer)
|
103
99
|
val
|
104
100
|
else
|
105
|
-
raise TypeError
|
101
|
+
raise TypeError, 'timestamp requires a Time or epoch Integer'
|
106
102
|
end
|
107
103
|
end
|
108
104
|
|
data/lib/ravelin/transaction.rb
CHANGED
@@ -1,27 +1,38 @@
|
|
1
1
|
module Ravelin
|
2
2
|
class Transaction < RavelinObject
|
3
3
|
attr_accessor :transaction_id,
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
4
|
+
:email,
|
5
|
+
:currency,
|
6
|
+
:debit,
|
7
|
+
:credit,
|
8
|
+
:gateway,
|
9
|
+
:custom,
|
10
|
+
:success,
|
11
|
+
:auth_code,
|
12
|
+
:decline_code,
|
13
|
+
:gateway_reference,
|
14
|
+
:avs_result_code,
|
15
|
+
:cvv_result_code,
|
16
|
+
:type,
|
17
|
+
:time,
|
18
|
+
:three_d_secure
|
18
19
|
|
19
20
|
attr_required :transaction_id,
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
:currency,
|
22
|
+
:debit,
|
23
|
+
:credit,
|
24
|
+
:gateway,
|
25
|
+
:gateway_reference,
|
26
|
+
:success
|
27
|
+
|
28
|
+
def initialize(params)
|
29
|
+
three_d_secure_data = params['3ds']
|
30
|
+
unless three_d_secure_data.nil?
|
31
|
+
self.three_d_secure = three_d_secure_data
|
32
|
+
params.delete('3ds')
|
33
|
+
end
|
34
|
+
|
35
|
+
super(params)
|
36
|
+
end
|
26
37
|
end
|
27
38
|
end
|
data/lib/ravelin/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ravelin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Levy
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date: 2017-
|
14
|
+
date: 2017-07-10 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: faraday
|