expresscheckout 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb17eb629199e28e5e1d06a7b89b1014d51dbefe
4
- data.tar.gz: b153af53bf8a5924101dcc752e603447848876e0
3
+ metadata.gz: 3e17e1b1eae1db505a4a1736d67ad86dd1dbc041
4
+ data.tar.gz: 01d1b20963a6eda9943732c6f7f04634bceab984
5
5
  SHA512:
6
- metadata.gz: 916d9898e22517089726818a1c1bf143e6709b9704a15deaba13f5ee14e430191d4139b9ba3eb4e33ccf7d0803d69f945dd6256dd11c7309b2a96ef42fc5b7ab
7
- data.tar.gz: c5febc37f244ea47c169946c1b22907f0784fe8d1c82882124103e57816c9b426101fa050645dd35edb6479d7ca0da19203945a6f7bb67ec46ac91426de46b15
6
+ metadata.gz: b34fc9946b2e1c093645e44eb4cb085241014d12e85cbc272684ed4af12a17e18cb743d68ece906d4ccfe49e6a7f6e901614e8403185b0ab625a744ac52481ac
7
+ data.tar.gz: 50f67dfdc89175bb8740c6d5efe4a73d837e597900e3fb1f2f6feb95a7a1a215e4e5b9bfc7acd0128a1984c20148ebdc76a58a34b11e0928d4bb2ba0858fb088
data/CHANGELOG.md CHANGED
@@ -1,16 +1,25 @@
1
- Change Log
2
- [1.0.7]
3
- Added - 2016-11-10
1
+ # Change Log
4
2
 
5
- Added PaymentLinks.java class, which contains the payment links for an order.
6
- Added order_uuid in order creation response.
7
- Resolved dependency issue
3
+ ## [0.1.8] - 2017-02-27
4
+ ### Added
5
+ - Added payment_method and payment_method_type in order class.
6
+ - Added implementation for Wallet create, create_and_authenticate, authenticate, refresh_by_wallet_id, link & delink.
7
+ - Added implementation for get_payment_methods in Payments class.
8
+ - Added request parameters in error response.
9
+ - Added api version as 2016-07-19.
8
10
 
9
- [1.0.6] - 2016-08-24
10
- Added
11
+ ## [0.1.7] - 2016-11-10
12
+ ### Added
13
+ - PaymentLinks.java class, which contains the payment links for an order.
14
+ - Order uuid in order creation response with 'id' as field.
15
+ - Runtime dependency for unirest.
11
16
 
12
- Changed API implementation for Order create, update, list, status and refund.
13
- Changed API implementation for Transaction create.
14
- Changed API implementation for Card create, list and delete.
15
- Added API implementation for Customer create, update, and get.
16
- Added API implementation for Wallet list and refresh.
17
+ ## [0.1.6] - 2016-08-24
18
+ ### Added
19
+ - API implementation for Customer create, update, and get.
20
+ - API implementation for Wallet list and refresh.
21
+
22
+ ### Changed
23
+ - API implementation for Order create, update, list, status and refund.
24
+ - API implementation for Transaction create.
25
+ - API implementation for Card create, list and delete.
data/lib/Cards.rb CHANGED
@@ -40,7 +40,7 @@ class Cards
40
40
 
41
41
  def Cards.list(options={})
42
42
  customer_id = get_arg(options,:customer_id)
43
- if customer_id == NIL
43
+ if customer_id == NIL or customer_id == ''
44
44
  raise InvalidArguementError.new("ERROR: `customer_id` is a required parameter for Cards.list().")
45
45
  end
46
46
 
@@ -59,7 +59,7 @@ class Cards
59
59
 
60
60
  def Cards.delete(options={})
61
61
  card_token = get_arg(options,:card_token)
62
- if card_token == NIL
62
+ if card_token == NIL or card_token == ''
63
63
  raise InvalidArguementError.new("ERROR: `card_token` is a required parameter for Card.delete().")
64
64
  end
65
65
 
data/lib/Customers.rb CHANGED
@@ -61,7 +61,7 @@ class Customers
61
61
 
62
62
  def Customers.get(options={})
63
63
  customer_id = get_arg(options,:customer_id)
64
- if customer_id == NIL
64
+ if customer_id == NIL or customer_id == ''
65
65
  raise InvalidArguementError.new("ERROR: `customer_id` is a required parameter for Customers.get().")
66
66
  end
67
67
 
@@ -74,7 +74,7 @@ class Customers
74
74
 
75
75
  def Customers.update(options={})
76
76
  customer_id = get_arg(options,:customer_id)
77
- if customer_id == NIL
77
+ if customer_id == NIL or customer_id == ''
78
78
  raise InvalidArguementError.new("ERROR: `customer_id` is a required parameter for Customers.update().")
79
79
  end
80
80
 
data/lib/Orders.rb CHANGED
@@ -3,22 +3,10 @@ require_relative 'Cards'
3
3
 
4
4
  class Orders
5
5
 
6
- @all_input_params = Array[:order_id, :amount, :currency, :customer_id, :customer_email, :customer_phone,
7
- :description, :product_id, :gateway_id, :return_url, :billing_address_first_name,
8
- :billing_address_last_name, :billing_address_line1, :billing_address_line2,
9
- :billing_address_line3, :billing_address_city, :billing_address_state,
10
- :billing_address_country, :billing_address_postal_code, :billing_address_phone,
11
- :billing_address_country_code_iso, :shipping_address_first_name,
12
- :shipping_address_last_name, :shipping_address_line1, :shipping_address_line2,
13
- :shipping_address_line3, :shipping_address_city, :shipping_address_state,
14
- :shipping_address_country, :shipping_address_postal_code, :shipping_address_phone,
15
- :shipping_address_country_code_iso, :udf1, :udf2, :udf3, :udf4, :udf5, :udf6, :udf7,
16
- :udf8, :udf9, :udf10]
17
-
18
6
  # noinspection ALL
19
7
  class Order
20
8
 
21
- attr_reader :id, :order_id, :product_id, :billing_address, :udf10, :refunds, :return_url, :bank_error_code, :merchant_id, :amount, :shipping_address, :gateway_id, :customer_id, :gateway_response, :amount_refunded, :udf7, :customer_email, :udf8, :udf9, :txn_id, :udf3, :udf4, :description, :udf5, :bank_error_message, :udf6, :udf1, :udf2, :status, :customer_phone, :currency, :refunded, :status_id, :payment_links
9
+ attr_reader :id, :order_id, :product_id, :billing_address, :udf10, :refunds, :return_url, :bank_error_code, :merchant_id, :amount, :shipping_address, :gateway_id, :customer_id, :gateway_response, :amount_refunded, :udf7, :customer_email, :udf8, :udf9, :txn_id, :udf3, :udf4, :description, :udf5, :bank_error_message, :udf6, :udf1, :udf2, :status, :customer_phone, :currency, :refunded, :status_id, :payment_links, :payment_method_type, :payment_method
22
10
  class Address
23
11
 
24
12
  attr_reader :state, :line1, :country, :country_code_iso, :type, :line3, :postal_code, :line2, :first_name, :last_name, :city, :phone
@@ -117,12 +105,9 @@ class Orders
117
105
  refunds = nil
118
106
  end
119
107
 
120
- if get_arg(options,"payment_links") != nil
121
- payment_links = PaymentLink.new(get_arg(options, 'payment_links'))
122
- else
123
- payment_links = nil
124
- end
125
- @id = get_arg(options, "id")
108
+ payment_links = PaymentLink.new(get_arg(options, 'payment_links'))
109
+
110
+ @id = get_arg(options, 'id')
126
111
  @merchant_id = get_arg(options, 'merchant_id')
127
112
  @order_id = get_arg(options, 'order_id')
128
113
  @status = get_arg(options, 'status')
@@ -153,6 +138,8 @@ class Orders
153
138
  @bank_error_message = get_arg(options, 'bank_error_message')
154
139
  @refunded = get_arg(options, 'refunded')
155
140
  @amount_refunded = get_arg(options, 'amount_refunded')
141
+ @payment_method_type = get_arg(options, 'payment_method_type')
142
+ @payment_method = get_arg(options, 'payment_method')
156
143
  @card = card
157
144
  @gateway_response = gateway_response
158
145
  @refunds = refunds
@@ -162,8 +149,8 @@ class Orders
162
149
  end
163
150
 
164
151
  def Orders.create(options={})
165
- order = get_arg(options, :order_id)
166
- if order == NIL
152
+ order_id = get_arg(options, :order_id)
153
+ if order_id == NIL or order_id == ''
167
154
  raise InvalidArguementError.new("ERROR: `order_id` is required parameter for Orders.create()")
168
155
  end
169
156
 
@@ -175,8 +162,8 @@ class Orders
175
162
  end
176
163
 
177
164
  def Orders.status(options={})
178
- order = get_arg(options, :order_id)
179
- if order == NIL
165
+ order_id = get_arg(options, :order_id)
166
+ if order_id == NIL or order_id == ''
180
167
  raise InvalidArguementError.new("ERROR: `order_id` is required parameter for Orders.status()")
181
168
  end
182
169
 
@@ -203,8 +190,8 @@ class Orders
203
190
  end
204
191
 
205
192
  def Orders.update(options={})
206
- order = get_arg(options, :order_id)
207
- if order == NIL
193
+ order_id = get_arg(options, :order_id)
194
+ if order_id == NIL or order_id == ''
208
195
  raise InvalidArguementError.new("ERROR: `order_id` is required parameter for Orders.update()")
209
196
  end
210
197
 
@@ -216,10 +203,12 @@ class Orders
216
203
  end
217
204
 
218
205
  def Orders.refund(options={})
219
- order = get_arg(options, :order_id)
220
- unique_request = get_arg(options, :unique_request_id)
221
- if order == NIL or unique_request == NIL
222
- raise InvalidArguementError.new("ERROR: `order_id` & `unique_request_id` is required parameter for Orders.refund()")
206
+ order_id = get_arg(options, :order_id)
207
+ unique_request_id = get_arg(options, :unique_request_id)
208
+ if order_id == NIL or order_id == '' or
209
+ unique_request_id == NIL or unique_request_id == '' or
210
+ amount == NIL or amount == ''
211
+ raise InvalidArguementError.new("ERROR: `order_id`, `amount` & `unique_request_id` is required parameter for Orders.refund()")
223
212
  end
224
213
 
225
214
  method = 'POST'
data/lib/Payments.rb CHANGED
@@ -31,6 +31,17 @@ class Payments
31
31
 
32
32
  end
33
33
 
34
+ class PaymentMethod
35
+
36
+ attr_reader :payment_method_type, :payment_method, :description
37
+ def initialize(options={})
38
+ @payment_method_type = get_arg(options, 'payment_method_type')
39
+ @payment_method = get_arg(options, 'payment_method')
40
+ @description = get_arg(options, 'description')
41
+ end
42
+
43
+ end
44
+
34
45
  def Payments.create_card_payment(options={})
35
46
  method = 'POST'
36
47
  url = '/txns'
@@ -140,4 +151,25 @@ class Payments
140
151
  return payment
141
152
  end
142
153
 
154
+ def Payments.get_payment_methods(options={})
155
+ merchant = get_arg(options, :merchant_id)
156
+
157
+ if merchant == NIL
158
+ raise InvalidArguementError.new("ERROR: `merchant_id` is required parameter for Payments.get_payment_methods()")
159
+ end
160
+
161
+ url = "/merchants/#{merchant}/paymentmethods"
162
+
163
+ method = 'GET'
164
+ response = Array(request(method,url,{}).body['payment_methods'])
165
+ payment_methods = []
166
+ i=0
167
+ while i != response.count
168
+ payment_method = PaymentMethod.new(response[i])
169
+ payment_methods.push(payment_method)
170
+ i+=1
171
+ end
172
+ return payment_methods
173
+ end
174
+
143
175
  end
data/lib/Wallets.rb CHANGED
@@ -5,13 +5,14 @@ class Wallets
5
5
  # noinspection ALL
6
6
  class Wallet
7
7
 
8
- attr_reader :id, :wallet, :object, :token, :current_balance, :last_refresh
8
+ attr_reader :id, :wallet, :object, :token, :linked, :current_balance, :last_refresh
9
9
 
10
10
  def initialize(options = {})
11
11
  @id = get_arg(options, 'id')
12
12
  @object = get_arg(options, 'object')
13
13
  @wallet = get_arg(options, 'wallet')
14
14
  @token = get_arg(options, 'token')
15
+ @linked = get_arg(options, 'linked')
15
16
  @current_balance = get_arg(options, 'current_balance')
16
17
  @last_refresh = get_arg(options, 'last_refreshed')
17
18
  end
@@ -19,21 +20,56 @@ class Wallets
19
20
  end
20
21
 
21
22
  def Wallets.create(options={})
22
- raise "ERROR: Not Implemented"
23
+ customer_id = get_arg(options, :customer_id)
24
+ gateway = get_arg(options, :gateway)
25
+
26
+ if customer_id == NIL or customer_id == '' or gateway == NIL or gateway == ''
27
+ raise InvalidArguementError.new("ERROR: `customer_id` and `gateway` are required parameters for Wallets.create()")
28
+ end
29
+
30
+ url = "/customers/#{customer_id}/wallets"
31
+
32
+ method = 'POST'
33
+ parameters = {
34
+ :gateway => gateway
35
+ }
36
+ response = request(method,url,parameters)
37
+ wallet = Wallet.new(response.body)
38
+ return wallet
39
+ end
40
+
41
+ def Wallets.create_and_authenticate(options={})
42
+ customer_id = get_arg(options, :customer_id)
43
+ gateway = get_arg(options, :gateway)
44
+
45
+ if customer_id == NIL or customer_id == '' or gateway == NIL or gateway == ''
46
+ raise InvalidArguementError.new("ERROR: `customer_id` and `gateway` are required parameters for Wallets.create_and_authenticate()")
47
+ end
48
+
49
+ url = "/customers/#{customer_id}/wallets"
50
+
51
+ method = 'POST'
52
+ parameters = {
53
+ :command => 'authenticate',
54
+ :gateway => gateway
55
+ }
56
+ response = request(method,url,parameters)
57
+ wallet = Wallet.new(response.body)
58
+ return wallet
23
59
  end
24
60
 
25
61
  def Wallets.list(options={})
26
- order = get_arg(options, :order_id)
27
- customer = get_arg(options, :customer_id)
62
+ order_id = get_arg(options, :order_id)
63
+ customer_id = get_arg(options, :customer_id)
28
64
 
29
- if customer == NIL and order == NIL
65
+ if (customer_id == NIL or customer_id == '') and (order_id == NIL or order_id == '')
30
66
  raise InvalidArguementError.new("ERROR: `customer_id` or `order_id` is required parameter for Wallets.list()")
31
67
  end
32
68
 
33
- if customer
34
- url = "/customers/#{customer}/wallets"
69
+ if customer_id
70
+ url = "/customers/#{customer_id}/wallets"
35
71
  else
36
- url = "/orders/#{order}/wallets"
72
+ url = "/orders/#{order_id}/wallets"
37
73
  end
38
74
 
39
75
  method = 'GET'
@@ -49,13 +85,13 @@ class Wallets
49
85
  end
50
86
 
51
87
  def Wallets.refresh_balance(options={})
52
- customer = get_arg(options, :customer_id)
88
+ customer_id = get_arg(options, :customer_id)
53
89
 
54
- if customer == NIL
90
+ if customer_id == NIL or customer_id == ''
55
91
  raise InvalidArguementError.new("ERROR: `customer_id` is required parameter for Wallets.refresh_balance()")
56
92
  end
57
93
 
58
- url = "/customers/#{customer}/wallets/refresh-balances"
94
+ url = "/customers/#{customer_id}/wallets/refresh-balances"
59
95
  method = 'GET'
60
96
  response = Array(request(method,url,{}).body['list'])
61
97
  wallets = []
@@ -66,9 +102,80 @@ class Wallets
66
102
  i+=1
67
103
  end
68
104
  return wallets
69
- end
105
+ end
106
+
107
+ def Wallets.refresh_by_wallet_id(options={})
108
+ wallet_id = get_arg(options, :wallet_id)
109
+
110
+ if wallet_id == NIL or wallet_id == ''
111
+ raise InvalidArguementError.new("ERROR: `wallet_id` is required parameter for Wallets.refresh_by_wallet_id()")
112
+ end
113
+
114
+ url = "/wallets/#{wallet_id}"
115
+
116
+ method = 'GET'
117
+ parameters = {
118
+ :command => 'refresh'
119
+ }
120
+ response = request(method,url,parameters)
121
+ wallet = Wallet.new(response.body)
122
+ return wallet
123
+ end
124
+
125
+
126
+ def Wallets.authenticate(options={})
127
+ wallet_id = get_arg(options, :wallet_id)
128
+
129
+ if wallet_id == NIL or wallet_id == ''
130
+ raise InvalidArguementError.new("ERROR: `wallet_id` is required parameter for Wallets.authenticate()")
131
+ end
132
+
133
+ url = "/wallets/#{wallet_id}"
134
+
135
+ method = 'POST'
136
+ parameters = {
137
+ :command => 'authenticate'
138
+ }
139
+ response = request(method,url,parameters)
140
+ wallet = Wallet.new(response.body)
141
+ return wallet
142
+ end
143
+
144
+ def Wallets.link(options={})
145
+ wallet_id = get_arg(options, :wallet_id)
146
+ otp = get_arg(options, :otp)
147
+
148
+ if wallet_id == NIL or wallet_id == '' or otp == NIL or otp == ''
149
+ raise InvalidArguementError.new("ERROR: `wallet_id` and `otp` are required parameters for Wallets.link()")
150
+ end
151
+
152
+ url = "/wallets/#{wallet_id}"
153
+
154
+ method = 'POST'
155
+ parameters = {
156
+ :command => 'link',
157
+ :otp => otp
158
+ }
159
+ response = request(method,url,parameters)
160
+ wallet = Wallet.new(response.body)
161
+ return wallet
162
+ end
163
+
164
+ def Wallets.delink(options={})
165
+ wallet_id = get_arg(options, :wallet_id)
166
+
167
+ if wallet_id == NIL or wallet_id == ''
168
+ raise InvalidArguementError.new("ERROR: `wallet_id` is required parameter for Wallets.delink()")
169
+ end
170
+
171
+ url = "/wallets/#{wallet_id}"
70
172
 
71
- def Wallets.delete(options={})
72
- raise "ERROR: Not Implemented"
173
+ method = 'POST'
174
+ parameters = {
175
+ :command => 'delink'
176
+ }
177
+ response = request(method,url,parameters)
178
+ wallet = Wallet.new(response.body)
179
+ return wallet
73
180
  end
74
181
  end
@@ -1,14 +1,16 @@
1
1
  class JuspayError < StandardError
2
2
 
3
- def initialize(message=nil, http_status=nil, json_body=nil)
3
+ def initialize(message=nil, http_status=nil, json_body=nil, request_params=nil)
4
4
  @_message = message
5
5
  @http_status = http_status
6
6
  @json_body = json_body
7
+ @request_params = request_params
7
8
  end
8
9
 
9
10
  def to_s
10
11
  status_string = @http_status.nil? ? '' : "(Status #{@http_status})\n"
11
12
  json_string = @json_body.nil? ? '' : "(Response #{@json_body})\n"
12
- "\n#{status_string}#{json_string}#{@_message}\n"
13
+ request_params = @request_params.nil? ? '' : "(Request parameters : #{@request_params})\n"
14
+ "\n#{status_string}#{json_string}#{@_message}#{request_params}\n"
13
15
  end
14
16
  end
@@ -8,8 +8,8 @@ module Expresscheckout
8
8
  require_relative 'Wallets'
9
9
 
10
10
  $api_key = nil
11
- $environment = 'staging'
12
- $version= {:JuspayAPILibrary=>'Ruby v1.0'}
11
+ $environment = 'production'
12
+ $api_version= '2016-10-27'
13
13
  end
14
14
 
15
15
  require 'unirest'
@@ -1,3 +1,3 @@
1
1
  module Expresscheckout
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
data/lib/util.rb CHANGED
@@ -19,19 +19,23 @@ def request(method, url, parameters={})
19
19
  if $api_key == nil
20
20
  raise AuthenticationError.new("ERROR: API key missing. Please specify api_key.")
21
21
  end
22
+ $headers = {
23
+ 'version' => $api_version,
24
+ 'User-Agent' => "Ruby SDK #{Expresscheckout::VERSION}"
25
+ }
22
26
  if method == 'GET'
23
- response = Unirest.get $server+url, headers: $version, auth: {:user => $api_key, :password => ''}, parameters: parameters
27
+ response = Unirest.get $server+url, headers: $headers, auth: {:user => $api_key, :password => ''}, parameters: parameters
24
28
  else
25
- response = Unirest.post $server +url, headers: $version, auth: {:user => $api_key, :password => ''}, parameters: parameters
29
+ response = Unirest.post $server +url, headers: $headers, auth: {:user => $api_key, :password => ''}, parameters: parameters
26
30
  end
27
31
  if (response.code >= 200 && response.code < 300)
28
32
  return response
29
33
  elsif ([400, 404].include? response.code)
30
- raise InvalidRequestError.new('Invalid Request', response.code, response.body)
34
+ raise InvalidRequestError.new('Invalid Request', response.code, response.body, parameters)
31
35
  elsif (response.code == 401)
32
- raise AuthenticationError.new('Unauthenticated Request', response.code, response.body)
36
+ raise AuthenticationError.new('Unauthenticated Request', response.code, response.body, parameters)
33
37
  else
34
- raise APIError.new('Invalid Request', response.code, response.body)
38
+ raise APIError.new('Invalid Request', response.code, response.body, parameters)
35
39
  end
36
40
  rescue IOError
37
41
  raise APIConnectionError.new('Connection error')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expresscheckout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juspay
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-10 00:00:00.000000000 Z
11
+ date: 2017-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  version: '0'
131
131
  requirements: []
132
132
  rubyforge_project:
133
- rubygems_version: 2.5.1
133
+ rubygems_version: 2.6.8
134
134
  signing_key:
135
135
  specification_version: 4
136
136
  summary: Juspay ExpressCheckout's Ruby API