avangate 0.2.2 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -0
- data/lib/avangate.rb +75 -33
- data/lib/avangate/errors.rb +1 -0
- data/lib/avangate/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: b886c3978f5213168be5a7fdfe9bd22f0731a949
|
4
|
+
data.tar.gz: 635d0feb131998e549802d9f251763958fab33b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb9bffd522fe3de4f651d0ecabf504958c33c8830b5708028623863e3cdfa7dfdb052c4b74f06aa7ff04f5b77448158509fb119cf33f1b57f98f161cac44deca
|
7
|
+
data.tar.gz: f15e211c860a83df6c9e35fb91486c5b8035353348cebd984657d95a1d0c4b6d58f2b58a5c7e806de0b9e5ea00b64e991aed751333f6e021431c7516ef70446e
|
data/README.md
CHANGED
@@ -6,6 +6,7 @@ Current methods implemented:
|
|
6
6
|
|
7
7
|
#login
|
8
8
|
#addProduct
|
9
|
+
#setBillingDetails
|
9
10
|
|
10
11
|
## Installation
|
11
12
|
|
@@ -36,6 +37,17 @@ Inside you can and set up:
|
|
36
37
|
|
37
38
|
@sessionId = Avangate::SOAP.login
|
38
39
|
Avangate::SOAP.add_product({session_id: @sessionId, product_id: 423221})
|
40
|
+
Avangate::SOAP.set_billing_details({
|
41
|
+
session_id: @sessionId,
|
42
|
+
address: '4 street',
|
43
|
+
city: 'dream city',
|
44
|
+
country: 'US',
|
45
|
+
email: 'john.doe@example.com',
|
46
|
+
first_name: 'John',
|
47
|
+
last_name: 'Doe',
|
48
|
+
postal_code: '12333',
|
49
|
+
state: 'Alabama'
|
50
|
+
})
|
39
51
|
|
40
52
|
## Development
|
41
53
|
|
data/lib/avangate.rb
CHANGED
@@ -19,48 +19,67 @@ module Avangate
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.add_product(options={})
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
sessionID: options[:session_id],
|
27
|
-
ProductId: options[:product_id],
|
28
|
-
Quantity: quantity
|
29
|
-
|
30
|
-
}
|
31
|
-
response = client.call :add_product, message: params
|
22
|
+
@options = options
|
23
|
+
require_session_id
|
24
|
+
require_product_id
|
25
|
+
response = client.call :add_product, message: add_product_params
|
32
26
|
return response.body.first[1].first[1]
|
33
27
|
end
|
34
28
|
|
35
29
|
def self.set_billing_details(options={})
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
billing_details['Country'] = options[:country]
|
49
|
-
billing_details['Email'] = options[:email]
|
50
|
-
billing_details['FirstName'] = options[:first_name]
|
51
|
-
billing_details['LastName'] = options[:last_name]
|
52
|
-
billing_details['PostalCode'] = options[:postal_code]
|
53
|
-
billing_details['State'] = options[:state]
|
54
|
-
params = {
|
55
|
-
sessionID: options[:session_id],
|
56
|
-
BillingDetails: billing_details
|
57
|
-
}
|
58
|
-
response = client.call :set_billing_details, message: params
|
30
|
+
@options = options
|
31
|
+
require_session_id
|
32
|
+
require_set_billing_details_params
|
33
|
+
response = client.call :set_billing_details, message: set_billing_details_params
|
34
|
+
return response.body.first[1].first[1]
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.get_product_by_code(options={})
|
38
|
+
@options = options
|
39
|
+
require_session_id
|
40
|
+
require_product_code
|
41
|
+
response = client.call :get_product_by_code, message: get_product_by_code_params
|
59
42
|
return response.body.first[1].first[1]
|
60
43
|
end
|
61
44
|
|
62
45
|
private
|
63
46
|
|
47
|
+
def self.require_session_id
|
48
|
+
raise MissingSessionId, "missing param session_id" unless @options[:session_id]
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.require_product_id
|
52
|
+
raise MissingProductId, "missing param product_id" unless @options[:product_id]
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.require_product_code
|
56
|
+
raise MissingProductCode, "missing param product_code" unless @options[:product_code]
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.require_set_billing_details_params
|
60
|
+
raise MissingAddress, "missing param address" unless @options[:address]
|
61
|
+
raise MissingCity, "missing param city" unless @options[:city]
|
62
|
+
raise MissingCountry, "missing param country" unless @options[:country]
|
63
|
+
raise MissingEmail, "missing param email" unless @options[:email]
|
64
|
+
raise MissingFirstName, "missing param first_name" unless @options[:first_name]
|
65
|
+
raise MissingLastName, "missing param last_name" unless @options[:last_name]
|
66
|
+
raise MissingPostalCode, "missing param postal_code" unless @options[:postal_code]
|
67
|
+
raise MissingState, "missing param state" unless @options[:state] or !STATE_REQUIRED_COUNTRIES.include? @options[:country]
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.billing_details
|
71
|
+
billing_details = {}
|
72
|
+
billing_details['Address'] = @options[:address]
|
73
|
+
billing_details['City'] = @options[:city]
|
74
|
+
billing_details['Country'] = @options[:country]
|
75
|
+
billing_details['Email'] = @options[:email]
|
76
|
+
billing_details['FirstName'] = @options[:first_name]
|
77
|
+
billing_details['LastName'] = @options[:last_name]
|
78
|
+
billing_details['PostalCode'] = @options[:postal_code]
|
79
|
+
billing_details['State'] = @options[:state]
|
80
|
+
billing_details
|
81
|
+
end
|
82
|
+
|
64
83
|
def self.client
|
65
84
|
@client ||= Savon.client(wsdl: END_POINT)
|
66
85
|
end
|
@@ -73,6 +92,29 @@ module Avangate
|
|
73
92
|
}
|
74
93
|
end
|
75
94
|
|
95
|
+
def self.add_product_params
|
96
|
+
quantity = @options[:quantity] ? @options[:quantity] : 1
|
97
|
+
{
|
98
|
+
sessionID: @options[:session_id],
|
99
|
+
ProductId: @options[:product_id],
|
100
|
+
Quantity: quantity
|
101
|
+
}
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.set_billing_details_params
|
105
|
+
{
|
106
|
+
sessionID: @options[:session_id],
|
107
|
+
BillingDetails: billing_details
|
108
|
+
}
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.get_product_by_code_params
|
112
|
+
{
|
113
|
+
sessionID: @options[:session_id],
|
114
|
+
ProductCode: @options[:product_code]
|
115
|
+
}
|
116
|
+
end
|
117
|
+
|
76
118
|
def self.merchant_code
|
77
119
|
Avangate::Base.merchant_code
|
78
120
|
end
|
data/lib/avangate/errors.rb
CHANGED
data/lib/avangate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avangate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|