debitech_soap 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/Gemfile.lock +1 -1
- data/lib/debitech_soap.rb +25 -17
- data/lib/debitech_soap/string_extensions.rb +1 -1
- data/lib/debitech_soap/version.rb +1 -1
- data/spec/debitech_soap_spec.rb +9 -1
- metadata +3 -3
data/CHANGELOG
CHANGED
data/Gemfile.lock
CHANGED
data/lib/debitech_soap.rb
CHANGED
@@ -8,20 +8,24 @@ module DebitechSoap
|
|
8
8
|
|
9
9
|
RETURN_DATA = %w{aCSUrl acquirerAddress acquirerAuthCode acquirerAuthResponseCode acquirerCity acquirerConsumerLimit acquirerErrorDescription acquirerFirstName acquirerLastName acquirerMerchantLimit acquirerZipCode amount errorMsg infoCode infoDescription pAReqMsg resultCode resultText verifyID}
|
10
10
|
|
11
|
-
PARAMS = {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
11
|
+
PARAMS = { %w(settle) => ["verifyID", "transID", "amount", "extra"],
|
12
|
+
%w(subscribeAndSettle subscribe_and_settle) \
|
13
|
+
=> ["verifyID", "transID", "data", "ip", "extra"],
|
14
|
+
%w(authorize) => ["billingFirstName", "billingLastName", "billingAddress", "billingCity",
|
15
|
+
"billingCountry", "cc", "expM", "expY", "eMail", "ip", "data", "currency", "transID", "extra"],
|
16
|
+
%w(authorizeAndSettle3DS authorize_and_settle_3ds) \
|
17
|
+
=> ["verifyID", "paRes", "extra"],
|
18
|
+
%w(refund) => ["verifyID", "transID", "amount", "extra"],
|
19
|
+
%w(askIf3DSEnrolled ask_if_3ds_enrolled) \
|
20
|
+
=> ["billingFirstName", "billingLastName", "billingAddress", "billingCity",
|
21
|
+
"billingCountry", "cc", "expM", "expY", "eMail", "ip", "data", "currency", "transID",
|
22
|
+
"httpAcceptHeader", "httpUserAgentHeader", "method", "referenceNo", "extra"],
|
23
|
+
%w(authReversal auth_reversal) => ["verifyID", "amount", "transID", "extra"],
|
24
|
+
%w(authorize3DS authorize_3ds) => ["verifyID", "paRes", "extra"],
|
25
|
+
%w(subscribe) => ["verifyID", "transID", "data", "ip", "extra"],
|
26
|
+
%w(authorizeAndSettle authorize_and_settle) \
|
27
|
+
=> ["billingFirstName", "billingLastName", "billingAddress", "billingCity", "billingCountry",
|
28
|
+
"cc", "expM", "expY", "eMail", "ip", "data", "currency", "transID", "extra"] }
|
25
29
|
|
26
30
|
def initialize(opts = {})
|
27
31
|
@api_credentials = {}
|
@@ -45,7 +49,7 @@ module DebitechSoap
|
|
45
49
|
private
|
46
50
|
|
47
51
|
def define_java_wrapper_methods!
|
48
|
-
PARAMS.keys.each { |method|
|
52
|
+
PARAMS.keys.flatten.each { |method|
|
49
53
|
(class << self; self; end).class_eval do # Doc:
|
50
54
|
define_method(method) do |*args| # def refund(*args)
|
51
55
|
attributes = @api_credentials.clone
|
@@ -53,13 +57,13 @@ module DebitechSoap
|
|
53
57
|
if args.first.is_a?(Hash)
|
54
58
|
attributes.merge!(args.first)
|
55
59
|
else
|
56
|
-
parameter_order =
|
60
|
+
parameter_order = api_signature(method).last
|
57
61
|
args.each_with_index { |argument, i|
|
58
62
|
attributes[parameter_order[i].to_sym] = argument
|
59
63
|
}
|
60
64
|
end
|
61
65
|
|
62
|
-
return_data @client.send(method, attributes).return
|
66
|
+
return_data @client.send(api_signature(method).first.first, attributes).return
|
63
67
|
end # end
|
64
68
|
end
|
65
69
|
}
|
@@ -95,5 +99,9 @@ module DebitechSoap
|
|
95
99
|
end
|
96
100
|
end
|
97
101
|
|
102
|
+
def api_signature(method)
|
103
|
+
PARAMS.find {|key,value| key.include?(method.to_s) }
|
104
|
+
end
|
105
|
+
|
98
106
|
end
|
99
107
|
end
|
@@ -18,7 +18,7 @@ module DebitechSoap
|
|
18
18
|
if first_letter_in_uppercase
|
19
19
|
self.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
|
20
20
|
else
|
21
|
-
self.to_s[0].chr.downcase +
|
21
|
+
self.to_s[0].chr.downcase + self.camelcase[1..-1]
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
data/spec/debitech_soap_spec.rb
CHANGED
@@ -50,7 +50,15 @@ describe DebitechSoap::API, "calling a method with java-style arguments" do
|
|
50
50
|
and_return(MockSoapResult.new)
|
51
51
|
api.refund(1234567, 23456, 100, "extra")
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
|
+
it "should camel case method names" do
|
55
|
+
api = DebitechSoap::API.new(:merchant => "merchant_name", :username => "api_user_name", :password => "api_user_password")
|
56
|
+
@client.should_receive("authorize3DS").with(:verifyID => 1234567, :paRes => "RES", :extra => "extra",
|
57
|
+
:shopName => "merchant_name", :userName => "api_user_name", :password => "api_user_password").
|
58
|
+
and_return(MockSoapResult.new)
|
59
|
+
api.authorize_3ds(1234567, "RES", "extra")
|
60
|
+
end
|
61
|
+
|
54
62
|
it "should not keep old attributes when making subsequent api calls" do
|
55
63
|
api = DebitechSoap::API.new(:merchant => "merchant_name", :username => "api_user_name", :password => "api_user_password")
|
56
64
|
@client.should_receive("refund").with(:verifyID => 1234567, :transID => 23456, :amount => 100, :extra => "extra",
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debitech_soap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Joakim Kolsj\xC3\xB6"
|