monri 0.1.0 → 0.3.0
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/Gemfile +3 -2
- data/LICENCE +21 -0
- data/README.md +3 -1
- data/{bin → exe}/byebug +1 -1
- data/{bin → exe}/coderay +1 -1
- data/{bin → exe}/rake +1 -1
- data/extensions/x86_64-darwin-19/2.6.0/byebug-11.1.3/byebug/byebug.bundle +0 -0
- data/extensions/x86_64-darwin-19/2.6.0/byebug-11.1.3/gem_make.out +3 -2
- data/lib/monri/access_tokens/create_response.rb +37 -0
- data/lib/monri/access_tokens.rb +29 -12
- data/lib/monri/client.rb +49 -4
- data/lib/monri/customers/create_response.rb +97 -0
- data/lib/monri/customers.rb +11 -9
- data/lib/monri/errors.rb +7 -1
- data/lib/monri/http_client.rb +22 -11
- data/lib/monri/payment_methods.rb +2 -2
- data/lib/monri/payments/create_response.rb +36 -0
- data/lib/monri/payments/payment_result.rb +52 -0
- data/lib/monri/payments/status_response.rb +45 -0
- data/lib/monri/payments.rb +11 -8
- data/lib/monri/response.rb +13 -24
- data/lib/monri/tokens/ephemeral_card_token_response.rb +46 -0
- data/lib/monri/tokens.rb +68 -0
- data/lib/monri/transactions/secure_message.rb +30 -0
- data/lib/monri/transactions/transaction.rb +131 -0
- data/lib/monri/transactions/transaction_response.rb +59 -0
- data/lib/monri/transactions.rb +117 -0
- data/lib/monri/validate_callback.rb +47 -0
- data/lib/monri.rb +13 -1
- data/monri.gemspec +1 -2
- metadata +24 -47
- data/lib/monri/transaction.rb +0 -14
- data/specifications/addressable-2.8.1.gemspec +0 -40
- data/specifications/ast-2.4.2.gemspec +0 -50
- data/specifications/byebug-11.1.3.gemspec +0 -39
- data/specifications/coderay-1.1.3.gemspec +0 -25
- data/specifications/crack-0.4.5.gemspec +0 -32
- data/specifications/hashdiff-1.0.1.gemspec +0 -46
- data/specifications/jaro_winkler-1.5.4.gemspec +0 -44
- data/specifications/m-1.6.0.gemspec +0 -49
- data/specifications/metaclass-0.0.4.gemspec +0 -19
- data/specifications/method_source-1.0.0.gemspec +0 -35
- data/specifications/minitest-5.16.2.gemspec +0 -41
- data/specifications/mocha-0.13.3.gemspec +0 -43
- data/specifications/parallel-1.22.1.gemspec +0 -21
- data/specifications/parser-3.1.2.1.gemspec +0 -63
- data/specifications/power_assert-2.0.2.gemspec +0 -54
- data/specifications/pry-0.14.1.gemspec +0 -39
- data/specifications/pry-byebug-3.8.0.gemspec +0 -38
- data/specifications/public_suffix-5.0.0.gemspec +0 -24
- data/specifications/rack-3.0.0.gemspec +0 -45
- data/specifications/rainbow-3.1.1.gemspec +0 -33
- data/specifications/rake-13.0.6.gemspec +0 -26
- data/specifications/rexml-3.2.5.gemspec +0 -42
- data/specifications/rubocop-0.80.0.gemspec +0 -59
- data/specifications/ruby-progressbar-1.11.0.gemspec +0 -43
- data/specifications/test-unit-3.5.5.gemspec +0 -48
- data/specifications/unicode-display_width-1.6.1.gemspec +0 -39
- data/specifications/webmock-3.18.1.gemspec +0 -85
- /data/{bin → exe}/m +0 -0
- /data/{bin → exe}/pry +0 -0
- /data/{bin → exe}/rubocop +0 -0
- /data/{bin → exe}/ruby-parse +0 -0
- /data/{bin → exe}/ruby-rewrite +0 -0
data/lib/monri/response.rb
CHANGED
@@ -1,40 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Monri
|
4
|
-
class Response
|
5
|
-
# @return [Object]
|
6
|
-
attr_accessor :result
|
7
|
-
# @return [Exception]
|
8
|
-
attr_accessor :exception
|
4
|
+
class Response < Hash
|
9
5
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
def initialize(params = {})
|
7
|
+
if params.has_key?(:exception)
|
8
|
+
self[:exception] = params[:exception]
|
9
|
+
end
|
10
|
+
self.merge!(params)
|
11
|
+
end
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
# @return [Exception, NilClass]
|
14
|
+
def exception
|
15
|
+
self[:exception]
|
18
16
|
end
|
19
17
|
|
20
|
-
|
21
|
-
|
18
|
+
# @param [Exception] val
|
19
|
+
def exception=(val)
|
20
|
+
self[:exception] = val
|
22
21
|
end
|
23
22
|
|
24
23
|
def failed?
|
25
24
|
exception != nil
|
26
25
|
end
|
27
26
|
|
28
|
-
def self.create
|
29
|
-
raise ArgumentError, 'Provide a block' unless block_given?
|
30
|
-
|
31
|
-
begin
|
32
|
-
result(yield)
|
33
|
-
rescue StandardError => e
|
34
|
-
exception(e)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
27
|
# @param [Exception] exception
|
39
28
|
def self.exception(exception)
|
40
29
|
rv = Response.new
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Monri
|
2
|
+
class Tokens
|
3
|
+
class EphemeralCardTokenResponse < Response
|
4
|
+
|
5
|
+
def approved?
|
6
|
+
status == 'approved'
|
7
|
+
end
|
8
|
+
|
9
|
+
# @return [String]
|
10
|
+
def id
|
11
|
+
self[:id]
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [String]
|
15
|
+
def status
|
16
|
+
self[:status]
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [String]
|
20
|
+
def masked_pan
|
21
|
+
self[:masked_pan]
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [String]
|
25
|
+
def cc_type
|
26
|
+
self[:cc_type]
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [String]
|
30
|
+
def cc_issuer
|
31
|
+
self[:cc_issuer]
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [EphemeralCardTokenResponse]
|
35
|
+
def self.create
|
36
|
+
raise ArgumentError, 'Provide a block' unless block_given?
|
37
|
+
|
38
|
+
begin
|
39
|
+
EphemeralCardTokenResponse.new(yield)
|
40
|
+
rescue StandardError => e
|
41
|
+
EphemeralCardTokenResponse.new(exception: e)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/monri/tokens.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
module Monri
|
2
|
+
class Tokens
|
3
|
+
|
4
|
+
# @return [Monri::Config]
|
5
|
+
attr_accessor :config
|
6
|
+
|
7
|
+
# @return [Monri::HttpClient]
|
8
|
+
attr_accessor :http_client
|
9
|
+
|
10
|
+
TEMP_TOKENIZE_REQUIRED_FIELDS = [:cvv, :type, :pan, :expiration_date, :temp_card_id, :digest, :timestamp]
|
11
|
+
|
12
|
+
# @note Create ephemeral (lasting for a very short time - 15minutes in this case) - token to replace card details.
|
13
|
+
# Required fields are: pan, expiration_date(YYMM), cvv, type (card). Optional fields are: tokenize_pan: bool
|
14
|
+
# @param [Hash] params
|
15
|
+
def create_ephemeral_card_token(params)
|
16
|
+
|
17
|
+
EphemeralCardTokenResponse.create do
|
18
|
+
ensure_configured!
|
19
|
+
|
20
|
+
# If there's no temp-card-id, create one
|
21
|
+
unless params.has_key?(:temp_card_id)
|
22
|
+
params.merge!(create_card_token)
|
23
|
+
end
|
24
|
+
|
25
|
+
missing_keys = TEMP_TOKENIZE_REQUIRED_FIELDS.reject { |k| params.has_key?(k) }
|
26
|
+
|
27
|
+
params[:authenticity_token] = config.authenticity_token
|
28
|
+
|
29
|
+
if missing_keys.length > 0
|
30
|
+
raise Monri::Errors::InvalidArgumentsError.new("Missing required keys=#{missing_keys.join(', ')}")
|
31
|
+
end
|
32
|
+
|
33
|
+
# TODO: assert if merchant has PCI-DSS certificate - request pci-dss access token
|
34
|
+
http_response = http_client.post('/v2/temp-tokenize', params)
|
35
|
+
if http_response.failed?
|
36
|
+
raise http_response.exception
|
37
|
+
elsif http_response.success?
|
38
|
+
http_response.body
|
39
|
+
else
|
40
|
+
# TODO: handle this case
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def ensure_configured!
|
48
|
+
if config == nil || http_client == nil
|
49
|
+
raise Monri::Errors::InvalidArgumentsError.new('Configuration error, config or http client not set')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# @param [Hash] params
|
54
|
+
# @return [Hash]
|
55
|
+
def create_card_token(params = {})
|
56
|
+
ensure_configured!
|
57
|
+
|
58
|
+
token = params.has_key?(:temp_card_id) ? params.delete(:temp_card_id) : SecureRandom.hex
|
59
|
+
timestamp = Time.now.iso8601
|
60
|
+
{
|
61
|
+
timestamp: timestamp,
|
62
|
+
temp_card_id: token,
|
63
|
+
digest: Digest::SHA512.hexdigest("#{config.merchant_key}#{token}#{timestamp}")
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Monri
|
2
|
+
class Transactions
|
3
|
+
class SecureMessage < Hash
|
4
|
+
# @param [Hash] params
|
5
|
+
def initialize(params)
|
6
|
+
self.merge!(params)
|
7
|
+
end
|
8
|
+
|
9
|
+
# @return [String]
|
10
|
+
def id
|
11
|
+
self[:id]
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [String]
|
15
|
+
def acs_url
|
16
|
+
self[:acs_url]
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [String]
|
20
|
+
def pareq
|
21
|
+
self[:pareq]
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [String]
|
25
|
+
def authenticity_token
|
26
|
+
self[:authenticity_token]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
module Monri
|
2
|
+
class Transactions
|
3
|
+
class Transaction < Hash
|
4
|
+
|
5
|
+
# @param [Hash] params
|
6
|
+
def initialize(params)
|
7
|
+
self.merge!(params)
|
8
|
+
end
|
9
|
+
|
10
|
+
# @return [String]
|
11
|
+
def id
|
12
|
+
self[:id]
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [String]
|
16
|
+
def acquirer
|
17
|
+
self[:acquirer]
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [String]
|
21
|
+
def order_number
|
22
|
+
self[:order_number]
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [String]
|
26
|
+
def amount
|
27
|
+
self[:amount]
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [String]
|
31
|
+
def currency
|
32
|
+
self[:currency]
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [String]
|
36
|
+
def outgoing_amount
|
37
|
+
self[:outgoing_amount]
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [String]
|
41
|
+
def outgoing_currency
|
42
|
+
self[:outgoing_currency]
|
43
|
+
end
|
44
|
+
|
45
|
+
# @return [String]
|
46
|
+
def approval_code
|
47
|
+
self[:approval_code]
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [String]
|
51
|
+
def response_code
|
52
|
+
self[:response_code]
|
53
|
+
end
|
54
|
+
|
55
|
+
# @return [String]
|
56
|
+
def response_message
|
57
|
+
self[:response_message]
|
58
|
+
end
|
59
|
+
|
60
|
+
# @return [String]
|
61
|
+
def reference_number
|
62
|
+
self[:reference_number]
|
63
|
+
end
|
64
|
+
|
65
|
+
# @return [String]
|
66
|
+
def systan
|
67
|
+
self[:systan]
|
68
|
+
end
|
69
|
+
|
70
|
+
# @return [String]
|
71
|
+
def eci
|
72
|
+
self[:eci]
|
73
|
+
end
|
74
|
+
|
75
|
+
# @return [String]
|
76
|
+
def xid
|
77
|
+
self[:xid]
|
78
|
+
end
|
79
|
+
|
80
|
+
# @return [String]
|
81
|
+
def acsv
|
82
|
+
self[:acsv]
|
83
|
+
end
|
84
|
+
|
85
|
+
# @return [String]
|
86
|
+
def cc_type
|
87
|
+
self[:cc_type]
|
88
|
+
end
|
89
|
+
|
90
|
+
# @return [String]
|
91
|
+
def status
|
92
|
+
self[:status]
|
93
|
+
end
|
94
|
+
|
95
|
+
# @return [String]
|
96
|
+
def created_at
|
97
|
+
self[:created_at]
|
98
|
+
end
|
99
|
+
|
100
|
+
# @return [String]
|
101
|
+
def transaction_type
|
102
|
+
self[:transaction_type]
|
103
|
+
end
|
104
|
+
|
105
|
+
# @return [String]
|
106
|
+
def enrollment
|
107
|
+
self[:enrollment]
|
108
|
+
end
|
109
|
+
|
110
|
+
# @return [String]
|
111
|
+
def authentication
|
112
|
+
self[:authentication]
|
113
|
+
end
|
114
|
+
|
115
|
+
# @return [String]
|
116
|
+
def pan_token
|
117
|
+
self[:pan_token]
|
118
|
+
end
|
119
|
+
|
120
|
+
# @return [String]
|
121
|
+
def issuer
|
122
|
+
self[:issuer]
|
123
|
+
end
|
124
|
+
|
125
|
+
# @return [String]
|
126
|
+
def three_ds_version
|
127
|
+
self[:three_ds_version]
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Monri
|
2
|
+
class Transactions
|
3
|
+
class TransactionResponse < Response
|
4
|
+
|
5
|
+
# @param [Hash] params
|
6
|
+
def initialize(params)
|
7
|
+
if params.has_key?(:errors)
|
8
|
+
self[:errors] = params.delete(:errors)
|
9
|
+
end
|
10
|
+
|
11
|
+
if params.has_key?(:transaction)
|
12
|
+
self[:transaction] = Monri::Transactions::Transaction.new(params.delete(:transaction))
|
13
|
+
end
|
14
|
+
|
15
|
+
if params.has_key?(:secure_message)
|
16
|
+
self[:secure_message] = Monri::Transactions::SecureMessage.new(params.delete(:secure_message))
|
17
|
+
end
|
18
|
+
super(params)
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [TrueClass, FalseClass]
|
22
|
+
def failed?
|
23
|
+
errors != nil && errors.length > 0 || super
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [Array]
|
27
|
+
def errors
|
28
|
+
self[:errors]
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [Monri::Transactions::TransactionResponse]
|
32
|
+
def transaction
|
33
|
+
self[:transaction]
|
34
|
+
end
|
35
|
+
|
36
|
+
# @return [Monri::Transactions::SecureMessage]
|
37
|
+
def secure_message
|
38
|
+
self[:secure_message]
|
39
|
+
end
|
40
|
+
|
41
|
+
# @return [TransactionResponse]
|
42
|
+
def self.create
|
43
|
+
raise ArgumentError, 'Provide a block' unless block_given?
|
44
|
+
|
45
|
+
begin
|
46
|
+
TransactionResponse.new(yield)
|
47
|
+
rescue StandardError => e
|
48
|
+
params = { exception: e }
|
49
|
+
if e.is_a?(Monri::Errors::HttpRequestError) && e.body != nil
|
50
|
+
body = JSON.parse(e.body, symbolize_names: true) rescue {}
|
51
|
+
params.merge!(body)
|
52
|
+
end
|
53
|
+
TransactionResponse.new(params)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
module Monri
|
2
|
+
class Transactions
|
3
|
+
|
4
|
+
# @return [Monri::Config]
|
5
|
+
attr_writer :config
|
6
|
+
|
7
|
+
# @return [Monri::HttpClient]
|
8
|
+
attr_writer :http_client
|
9
|
+
|
10
|
+
REQUIRED_FIELDS = [
|
11
|
+
:transaction_type,
|
12
|
+
:amount,
|
13
|
+
:ip,
|
14
|
+
:order_info,
|
15
|
+
:ch_address,
|
16
|
+
:ch_city,
|
17
|
+
:ch_country,
|
18
|
+
:ch_email,
|
19
|
+
:ch_full_name,
|
20
|
+
:ch_phone,
|
21
|
+
:ch_zip,
|
22
|
+
:currency,
|
23
|
+
:order_number,
|
24
|
+
:language
|
25
|
+
].freeze
|
26
|
+
|
27
|
+
REQUIRED_TRX_MANAGEMENT_FIELDS = [
|
28
|
+
:amount,
|
29
|
+
:currency,
|
30
|
+
:order_number
|
31
|
+
].freeze
|
32
|
+
|
33
|
+
# @param [Hash] params
|
34
|
+
# @return [Monri::Transactions::TransactionResponse]
|
35
|
+
def transaction(params)
|
36
|
+
TransactionResponse.create do
|
37
|
+
unless params.is_a?(Hash)
|
38
|
+
raise Monri::Errors::InvalidArgumentsError.new('First parameter - params, should be a Hash')
|
39
|
+
end
|
40
|
+
|
41
|
+
missing_keys = REQUIRED_FIELDS.reject { |k| params.has_key?(k) }
|
42
|
+
if missing_keys.length > 0
|
43
|
+
raise Monri::Errors::InvalidArgumentsError.new("Missing required keys=#{missing_keys.join(', ')}")
|
44
|
+
end
|
45
|
+
|
46
|
+
params[:authenticity_token] = @config.authenticity_token
|
47
|
+
digest_parts = [@config.merchant_key, params[:order_number], params[:amount], params[:currency]]
|
48
|
+
params[:digest] = Digest::SHA512.hexdigest(digest_parts.join)
|
49
|
+
|
50
|
+
req = { transaction: params }
|
51
|
+
|
52
|
+
rv = @http_client.post('/v2/transaction', req)
|
53
|
+
if rv.failed?
|
54
|
+
raise rv.exception
|
55
|
+
elsif rv.success?
|
56
|
+
rv.body
|
57
|
+
else
|
58
|
+
raise "Unhandled state, exception=#{rv.exception}, failed=#{rv.failed?}, success=#{rv.success?}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def void(params)
|
64
|
+
unless params.is_a?(Hash)
|
65
|
+
raise Monri::Errors::InvalidArgumentsError.new('First parameter - params, should be a Hash')
|
66
|
+
end
|
67
|
+
trx_management(params.merge(transaction_type: 'void'))
|
68
|
+
end
|
69
|
+
|
70
|
+
def refund(params)
|
71
|
+
unless params.is_a?(Hash)
|
72
|
+
raise Monri::Errors::InvalidArgumentsError.new('First parameter - params, should be a Hash')
|
73
|
+
end
|
74
|
+
trx_management(params.merge(transaction_type: 'refund'))
|
75
|
+
end
|
76
|
+
|
77
|
+
def capture(params)
|
78
|
+
unless params.is_a?(Hash)
|
79
|
+
raise Monri::Errors::InvalidArgumentsError.new('First parameter - params, should be a Hash')
|
80
|
+
end
|
81
|
+
trx_management(params.merge(transaction_type: 'capture'))
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
# @param [Hash] params
|
87
|
+
# @return [Monri::Transactions::TransactionResponse]
|
88
|
+
def trx_management(params)
|
89
|
+
TransactionResponse.create do
|
90
|
+
unless params.is_a?(Hash)
|
91
|
+
raise Monri::Errors::InvalidArgumentsError.new('First parameter - params, should be a Hash')
|
92
|
+
end
|
93
|
+
|
94
|
+
missing_keys = REQUIRED_TRX_MANAGEMENT_FIELDS.reject { |k| params.has_key?(k) }
|
95
|
+
if missing_keys.length > 0
|
96
|
+
raise Monri::Errors::InvalidArgumentsError.new("Missing required keys=#{missing_keys.join(', ')}")
|
97
|
+
end
|
98
|
+
|
99
|
+
params[:authenticity_token] = @config.authenticity_token
|
100
|
+
digest_parts = [@config.merchant_key, params[:order_number], params[:amount], params[:currency]]
|
101
|
+
params[:digest] = Digest::SHA512.hexdigest(digest_parts.join)
|
102
|
+
|
103
|
+
req = { transaction: params }
|
104
|
+
|
105
|
+
rv = @http_client.post('/v2/trx-management', req)
|
106
|
+
if rv.failed?
|
107
|
+
raise rv.exception
|
108
|
+
elsif rv.success?
|
109
|
+
rv.body
|
110
|
+
else
|
111
|
+
raise "Unhandled state, exception=#{rv.exception}, failed=#{rv.failed?}, success=#{rv.success?}"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Monri
|
2
|
+
class ValidateCallback
|
3
|
+
|
4
|
+
# @return [Monri::Config]
|
5
|
+
attr_accessor :config
|
6
|
+
|
7
|
+
# @param [String] header
|
8
|
+
# @param [String] body
|
9
|
+
# @param [Hash] options
|
10
|
+
# @return [Hash{Symbol->String | TrueClass | FalseClass}]
|
11
|
+
def validate(header, body, options = {})
|
12
|
+
|
13
|
+
unless header.is_a?(String)
|
14
|
+
raise Monri::Errors::InvalidArgumentsError.new('First parameter - authorization header, should be a String')
|
15
|
+
end
|
16
|
+
|
17
|
+
unless body.is_a?(String)
|
18
|
+
raise Monri::Errors::InvalidArgumentsError.new('Second parameter - body, should be a String')
|
19
|
+
end
|
20
|
+
|
21
|
+
unless options.is_a?(Hash)
|
22
|
+
raise Monri::Errors::InvalidArgumentsError.new('Third parameter - options, should be a Hash')
|
23
|
+
end
|
24
|
+
|
25
|
+
version = options.delete(:version) || '2'
|
26
|
+
|
27
|
+
if version == 'v2'
|
28
|
+
expected_digest = Digest::SHA512.hexdigest("#{config.merchant_key}#{body}")
|
29
|
+
elsif version == '1'
|
30
|
+
unless options.has_key?(:order_number)
|
31
|
+
raise Monri::Errors::InvalidArgumentsError.new('For version=1 provide order-number')
|
32
|
+
end
|
33
|
+
order_number = options.delete(:order_number)
|
34
|
+
expected_digest = Digest::SHA1.hexdigest("#{config.merchant_key}#{order_number}")
|
35
|
+
else
|
36
|
+
raise Monri::Errors::InvalidArgumentsError.new("Version option, value='#{version}' is not supported")
|
37
|
+
end
|
38
|
+
|
39
|
+
expected_header = "WP3-callback #{expected_digest}"
|
40
|
+
{
|
41
|
+
header: header,
|
42
|
+
expected_header: expected_header,
|
43
|
+
valid: header == expected_header
|
44
|
+
}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/monri.rb
CHANGED
@@ -11,13 +11,25 @@ require 'monri/config'
|
|
11
11
|
require 'monri/client'
|
12
12
|
require 'monri/errors'
|
13
13
|
require 'monri/http_client'
|
14
|
-
require 'monri/transaction'
|
15
14
|
require 'monri/payments'
|
16
15
|
require 'monri/payment_methods'
|
17
16
|
require 'monri/access_tokens'
|
18
17
|
require 'monri/customers'
|
19
18
|
require 'monri/response'
|
20
19
|
require 'monri/api_http_response'
|
20
|
+
require 'monri/validate_callback'
|
21
|
+
require 'monri/tokens'
|
22
|
+
require 'monri/transactions'
|
23
|
+
require 'monri/transactions/transaction'
|
24
|
+
require 'monri/transactions/transaction_response'
|
25
|
+
require 'monri/transactions/secure_message'
|
26
|
+
require 'monri/payments/create_response'
|
27
|
+
require 'monri/payments/status_response'
|
28
|
+
require 'monri/payments/payment_result'
|
29
|
+
require 'monri/tokens/ephemeral_card_token_response'
|
30
|
+
require 'monri/customers/create_response'
|
31
|
+
require 'monri/access_tokens/create_response'
|
32
|
+
require 'time'
|
21
33
|
|
22
34
|
module Monri
|
23
35
|
end
|
data/monri.gemspec
CHANGED
@@ -2,8 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'monri'
|
5
|
-
|
6
|
-
s.version = '0.1.0'
|
5
|
+
s.version = '0.3.0'
|
7
6
|
s.required_ruby_version = '>= 2.3.0'
|
8
7
|
s.summary = 'Ruby bindings for the Monri API'
|
9
8
|
s.description = 'Your voyage through payment experience starts here. Learn more about how Monri helps to power your business.' \
|
metadata
CHANGED
@@ -1,42 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Monri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Your voyage through payment experience starts here. Learn more about
|
14
14
|
how Monri helps to power your business.See https://monri.com for details.
|
15
15
|
email: support@monri.com
|
16
|
-
executables:
|
17
|
-
- byebug
|
18
|
-
- coderay
|
19
|
-
- m
|
20
|
-
- pry
|
21
|
-
- rake
|
22
|
-
- rubocop
|
23
|
-
- ruby-parse
|
24
|
-
- ruby-rewrite
|
16
|
+
executables: []
|
25
17
|
extensions: []
|
26
18
|
extra_rdoc_files: []
|
27
19
|
files:
|
28
20
|
- CHANGELOG.md
|
29
21
|
- Gemfile
|
22
|
+
- LICENCE
|
30
23
|
- README.md
|
31
24
|
- Rakefile
|
32
|
-
-
|
33
|
-
-
|
34
|
-
-
|
35
|
-
-
|
36
|
-
-
|
37
|
-
-
|
38
|
-
-
|
39
|
-
-
|
25
|
+
- exe/byebug
|
26
|
+
- exe/coderay
|
27
|
+
- exe/m
|
28
|
+
- exe/pry
|
29
|
+
- exe/rake
|
30
|
+
- exe/rubocop
|
31
|
+
- exe/ruby-parse
|
32
|
+
- exe/ruby-rewrite
|
40
33
|
- extensions/x86_64-darwin-19/2.6.0/byebug-11.1.3/byebug/byebug.bundle
|
41
34
|
- extensions/x86_64-darwin-19/2.6.0/byebug-11.1.3/gem.build_complete
|
42
35
|
- extensions/x86_64-darwin-19/2.6.0/byebug-11.1.3/gem_make.out
|
@@ -45,44 +38,28 @@ files:
|
|
45
38
|
- extensions/x86_64-darwin-19/2.6.0/jaro_winkler-1.5.4/jaro_winkler/jaro_winkler_ext.bundle
|
46
39
|
- lib/monri.rb
|
47
40
|
- lib/monri/access_tokens.rb
|
41
|
+
- lib/monri/access_tokens/create_response.rb
|
48
42
|
- lib/monri/api_http_response.rb
|
49
43
|
- lib/monri/client.rb
|
50
44
|
- lib/monri/config.rb
|
51
45
|
- lib/monri/customers.rb
|
46
|
+
- lib/monri/customers/create_response.rb
|
52
47
|
- lib/monri/errors.rb
|
53
48
|
- lib/monri/http_client.rb
|
54
49
|
- lib/monri/payment_methods.rb
|
55
50
|
- lib/monri/payments.rb
|
51
|
+
- lib/monri/payments/create_response.rb
|
52
|
+
- lib/monri/payments/payment_result.rb
|
53
|
+
- lib/monri/payments/status_response.rb
|
56
54
|
- lib/monri/response.rb
|
57
|
-
- lib/monri/
|
55
|
+
- lib/monri/tokens.rb
|
56
|
+
- lib/monri/tokens/ephemeral_card_token_response.rb
|
57
|
+
- lib/monri/transactions.rb
|
58
|
+
- lib/monri/transactions/secure_message.rb
|
59
|
+
- lib/monri/transactions/transaction.rb
|
60
|
+
- lib/monri/transactions/transaction_response.rb
|
61
|
+
- lib/monri/validate_callback.rb
|
58
62
|
- monri.gemspec
|
59
|
-
- specifications/addressable-2.8.1.gemspec
|
60
|
-
- specifications/ast-2.4.2.gemspec
|
61
|
-
- specifications/byebug-11.1.3.gemspec
|
62
|
-
- specifications/coderay-1.1.3.gemspec
|
63
|
-
- specifications/crack-0.4.5.gemspec
|
64
|
-
- specifications/hashdiff-1.0.1.gemspec
|
65
|
-
- specifications/jaro_winkler-1.5.4.gemspec
|
66
|
-
- specifications/m-1.6.0.gemspec
|
67
|
-
- specifications/metaclass-0.0.4.gemspec
|
68
|
-
- specifications/method_source-1.0.0.gemspec
|
69
|
-
- specifications/minitest-5.16.2.gemspec
|
70
|
-
- specifications/mocha-0.13.3.gemspec
|
71
|
-
- specifications/parallel-1.22.1.gemspec
|
72
|
-
- specifications/parser-3.1.2.1.gemspec
|
73
|
-
- specifications/power_assert-2.0.2.gemspec
|
74
|
-
- specifications/pry-0.14.1.gemspec
|
75
|
-
- specifications/pry-byebug-3.8.0.gemspec
|
76
|
-
- specifications/public_suffix-5.0.0.gemspec
|
77
|
-
- specifications/rack-3.0.0.gemspec
|
78
|
-
- specifications/rainbow-3.1.1.gemspec
|
79
|
-
- specifications/rake-13.0.6.gemspec
|
80
|
-
- specifications/rexml-3.2.5.gemspec
|
81
|
-
- specifications/rubocop-0.80.0.gemspec
|
82
|
-
- specifications/ruby-progressbar-1.11.0.gemspec
|
83
|
-
- specifications/test-unit-3.5.5.gemspec
|
84
|
-
- specifications/unicode-display_width-1.6.1.gemspec
|
85
|
-
- specifications/webmock-3.18.1.gemspec
|
86
63
|
homepage: https://github.com/MonriPayments/monri-ruby
|
87
64
|
licenses:
|
88
65
|
- MIT
|