rails-gp-webpay 0.2.4 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/changelog.md +6 -0
- data/lib/gp_webpay/configuration.rb +1 -2
- data/lib/gp_webpay/mock/spec_helper.rb +34 -22
- data/lib/gp_webpay/version.rb +1 -1
- data/lib/gp_webpay/ws/base_signed_request.rb +10 -2
- data/lib/gp_webpay/ws/services/process_capture_reverse.rb +1 -0
- 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: a0f327b8f7b609ff6a7a62d97bf0d0a182cfd6513145d2aa8d224600d4daf7e6
|
4
|
+
data.tar.gz: 045ed7d32e3f2289cbf27f93c8ad7e9fee677a6cd4e2be9c2f47324f271ef5fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 203e91a7fe8952ccc3f58924048fc5e57f028c86b19a9217a22b13000911470b55813e77ec5bce4a8dfea3be9b19bd0deb4d325f946e351e03c42a15a77232c5
|
7
|
+
data.tar.gz: 9ccc0518abb878d34a533af017c60b85efe5c0b6b36f2c63bc1ee882d436f11e946d93039bfda4f73b938ecf0968425030f0793e32d09b49930ea3d25154a908
|
data/changelog.md
CHANGED
@@ -21,8 +21,7 @@ module GpWebpay
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def find_configuration_by_merchant_number(merchant_number)
|
24
|
-
|
25
|
-
config = @configurations.find { |_key, value| puts _key;value.merchant_number.to_s == merchant_number.to_s }
|
24
|
+
config = @configurations.find { |_key, value| value.merchant_number.to_s == merchant_number.to_s }
|
26
25
|
return nil if config.blank?
|
27
26
|
|
28
27
|
config[-1]
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'savon/mock/spec_helper'
|
2
|
-
|
2
|
+
# rubocop:disable Metrics/ParameterLists
|
3
3
|
module GpWebpay
|
4
4
|
module SpecHelper
|
5
5
|
class Interface
|
@@ -24,20 +24,28 @@ module GpWebpay
|
|
24
24
|
def stub_card_token(token, status: 'VERIFIED', success: true, valid: true)
|
25
25
|
allow(GpWebpay::Ws::Services::GetTokenStatus)
|
26
26
|
.to receive(:call).with(hash_including(token_data: token, message_id: anything))
|
27
|
-
.and_return(instance_double(GpWebpay::Ws::WsResponse,
|
27
|
+
.and_return(instance_double(GpWebpay::Ws::WsResponse,
|
28
|
+
valid?: valid, success?: success, status: status,
|
29
|
+
pr_code: (success ? '0' : '123'), sr_code: (success ? '0' : '4'),
|
30
|
+
original_response: { pr_code: 0, sr_code: 0 }))
|
28
31
|
end
|
29
32
|
|
30
33
|
def stub_master_payment_status(payment_number, status: 'OK', success: true, valid: true)
|
31
34
|
allow(GpWebpay::Ws::Services::GetMasterPaymentStatus)
|
32
35
|
.to receive(:call).with(hash_including(payment_number: payment_number, message_id: anything))
|
33
|
-
.and_return(instance_double(GpWebpay::Ws::WsResponse,
|
36
|
+
.and_return(instance_double(GpWebpay::Ws::WsResponse,
|
37
|
+
valid?: valid, success?: success, status: status,
|
38
|
+
pr_code: (success ? '0' : '123'), sr_code: (success ? '0' : '4'),
|
39
|
+
original_response: { pr_code: 0, sr_code: 0 }))
|
34
40
|
end
|
35
41
|
|
36
|
-
def stub_payment_status(payment_number, status: 'VERIFIED', sub_status: 'SETTLED', success: true, valid: true)
|
42
|
+
def stub_payment_status(payment_number, merchant_number: nil, status: 'VERIFIED', sub_status: 'SETTLED', success: true, valid: true)
|
37
43
|
allow(GpWebpay::Ws::Services::GetPaymentStatus)
|
38
|
-
.to receive(:call).with(hash_including(payment_number: payment_number, message_id: anything))
|
44
|
+
.to receive(:call).with(hash_including(payment_number: payment_number, message_id: anything), merchant_number: merchant_number)
|
39
45
|
.and_return(instance_double(GpWebpay::Ws::WsResponse,
|
40
46
|
valid?: valid, success?: success, status: status,
|
47
|
+
pr_code: success ? '0' : '123', sr_code: success ? '0' : '4',
|
48
|
+
original_response: { pr_code: 0, sr_code: 0 },
|
41
49
|
params: { sub_status: sub_status }))
|
42
50
|
end
|
43
51
|
|
@@ -45,55 +53,58 @@ module GpWebpay
|
|
45
53
|
allow(GpWebpay::Ws::Services::ProcessUsageBasedPayment)
|
46
54
|
.to receive(:call).with(
|
47
55
|
hash_including(
|
48
|
-
{
|
49
|
-
message_id: anything,
|
56
|
+
{ message_id: anything,
|
50
57
|
payment_number: anything,
|
51
58
|
order_number: anything,
|
52
59
|
currency_code: anything,
|
53
|
-
capture_flag: '1'
|
54
|
-
}.merge(attributes)
|
60
|
+
capture_flag: '1' }.merge(attributes)
|
55
61
|
),
|
56
|
-
merchant_number: merchant_number
|
62
|
+
merchant_number: merchant_number
|
57
63
|
).and_return(instance_double(GpWebpay::Ws::WsResponse,
|
58
64
|
valid?: valid, success?: success, status: status, result_text: result_text,
|
59
65
|
pr_code: success ? '0' : '123', sr_code: success ? '0' : '4',
|
66
|
+
original_response: { pr_code: 0, sr_code: 0 },
|
60
67
|
params: { token_data: response_token_data || attributes[:token_data] }))
|
61
68
|
end
|
62
69
|
|
63
|
-
def stub_token_revoke(token, valid: true, success: true, status: 'REVOKED', result_text: 'OK')
|
70
|
+
def stub_token_revoke(token, merchant_number: nil, valid: true, success: true, status: 'REVOKED', result_text: 'OK')
|
64
71
|
allow(GpWebpay::Ws::Services::ProcessTokenRevoke)
|
65
72
|
.to receive(:call).with(
|
66
|
-
hash_including({ message_id: anything }.merge(token_data: token))
|
73
|
+
hash_including({ message_id: anything }.merge(token_data: token)), merchant_number: merchant_number
|
67
74
|
).and_return(instance_double(GpWebpay::Ws::WsResponse,
|
68
75
|
valid?: valid, success?: success, status: status, result_text: result_text,
|
69
|
-
pr_code: success ? '0' : '123', sr_code: success ? '0' : '4')
|
76
|
+
pr_code: (success ? '0' : '123'), sr_code: (success ? '0' : '4'),
|
77
|
+
original_response: { pr_code: 0, sr_code: 0 }))
|
70
78
|
end
|
71
79
|
|
72
|
-
def stub_refund_payment(attributes, valid: true, success: true, status: '', result_text: 'OK')
|
80
|
+
def stub_refund_payment(attributes, merchant_number: nil, valid: true, success: true, status: '', result_text: 'OK')
|
73
81
|
allow(GpWebpay::Ws::Services::ProcessRefundPayment)
|
74
82
|
.to receive(:call).with(
|
75
|
-
hash_including({ message_id: anything }.merge(attributes))
|
83
|
+
hash_including({ message_id: anything }.merge(attributes)), merchant_number: merchant_number
|
76
84
|
).and_return(instance_double(GpWebpay::Ws::WsResponse,
|
77
85
|
valid?: valid, success?: success, status: status, result_text: result_text,
|
78
|
-
pr_code: success ? '0' : '123', sr_code: success ? '0' : '4'
|
86
|
+
pr_code: success ? '0' : '123', sr_code: success ? '0' : '4',
|
87
|
+
original_response: { pr_code: 0, sr_code: 0 }))
|
79
88
|
end
|
80
89
|
|
81
|
-
def stub_capture_reverse(attributes, valid: true, success: true, status: '', result_text: 'OK')
|
90
|
+
def stub_capture_reverse(attributes, merchant_number: nil, valid: true, success: true, status: '', result_text: 'OK')
|
82
91
|
allow(GpWebpay::Ws::Services::ProcessCaptureReverse)
|
83
92
|
.to receive(:call).with(
|
84
|
-
hash_including({ message_id: anything }.merge(attributes))
|
93
|
+
hash_including({ message_id: anything }.merge(attributes)), merchant_number: merchant_number
|
85
94
|
).and_return(instance_double(GpWebpay::Ws::WsResponse,
|
86
95
|
valid?: valid, success?: success, status: status, result_text: result_text,
|
87
|
-
pr_code: success ? '0' : '123', sr_code: success ? '0' : '4'
|
96
|
+
pr_code: success ? '0' : '123', sr_code: success ? '0' : '4',
|
97
|
+
original_response: { pr_code: 0, sr_code: 0 }))
|
88
98
|
end
|
89
99
|
|
90
|
-
def stub_cancel_capture(attributes, valid: true, success: true, status: '', result_text: 'OK')
|
100
|
+
def stub_cancel_capture(attributes, merchant_number: nil, valid: true, success: true, status: '', result_text: 'OK')
|
91
101
|
allow(GpWebpay::Ws::Services::ProcessCancelCapture)
|
92
102
|
.to receive(:call).with(
|
93
|
-
hash_including({ message_id: anything }.merge(attributes))
|
103
|
+
hash_including({ message_id: anything }.merge(attributes)), merchant_number: merchant_number
|
94
104
|
).and_return(instance_double(GpWebpay::Ws::WsResponse,
|
95
105
|
valid?: valid, success?: success, status: status, result_text: result_text,
|
96
|
-
pr_code: success ? '0' : '123', sr_code: success ? '0' : '4'
|
106
|
+
pr_code: success ? '0' : '123', sr_code: success ? '0' : '4',
|
107
|
+
original_response: { pr_code: 0, sr_code: 0 }))
|
97
108
|
end
|
98
109
|
end
|
99
110
|
|
@@ -102,3 +113,4 @@ module GpWebpay
|
|
102
113
|
end
|
103
114
|
end
|
104
115
|
end
|
116
|
+
# rubocop:enable Metrics/ParameterLists
|
data/lib/gp_webpay/version.rb
CHANGED
@@ -23,6 +23,7 @@ module GpWebpay
|
|
23
23
|
RESPONSE_NAME = 'override_me'.freeze
|
24
24
|
RESPONSE_ENTITY_NAME = 'override_me'.freeze
|
25
25
|
SERVICE_EXCEPTION = :service_exception
|
26
|
+
DEFAULT_ATTRIBUTES = {}.freeze
|
26
27
|
|
27
28
|
def initialize(attributes, merchant_number: :default)
|
28
29
|
@attributes = attributes
|
@@ -32,9 +33,10 @@ module GpWebpay
|
|
32
33
|
end
|
33
34
|
|
34
35
|
def call
|
35
|
-
attrs = WsRequest.new(
|
36
|
+
attrs = WsRequest.new(final_attributes).to_gpwebpay
|
36
37
|
|
37
|
-
|
38
|
+
Rails.logger.debug([self.class::OPERATION_NAME, { message: { self.class::REQUEST_NAME => attributes_with_signature(attrs) } }])
|
39
|
+
res = client.call(self.class::OPERATION_NAME, { message: { self.class::REQUEST_NAME => attributes_with_signature(attrs) } })
|
38
40
|
WsResponse.from_success(res.body, self.class::RESPONSE_NAME, self.class::RESPONSE_ENTITY_NAME, config.merchant_number)
|
39
41
|
rescue Savon::HTTPError => e
|
40
42
|
rescue_from_http(e)
|
@@ -44,6 +46,12 @@ module GpWebpay
|
|
44
46
|
|
45
47
|
protected
|
46
48
|
|
49
|
+
def final_attributes
|
50
|
+
{}.merge(self.class::DEFAULT_ATTRIBUTES,
|
51
|
+
attributes,
|
52
|
+
{ provider: config.provider, merchant_number: config.merchant_number })
|
53
|
+
end
|
54
|
+
|
47
55
|
def digest_text(attrs)
|
48
56
|
attrs.values.join('|')
|
49
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-gp-webpay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lubomir Vnenk
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|