worldpay 1.2.7 → 1.2.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: 04ba198883106b578590c3c123785e6f27a9382d
4
- data.tar.gz: d11022746be5463e30af4feffc43bb90c103c90c
3
+ metadata.gz: 07921b21668dcab1eb895654f29f9a2b1e5a022c
4
+ data.tar.gz: 6293b0665af755ce4578af19ea3f88187cba4e49
5
5
  SHA512:
6
- metadata.gz: da3a6e09dcaa2e83ce4dab76ad58f9900a31db41a2f8f45a2d13120bfc09452bf70e34c9ed2c5994286ed38926e6cf43bf756f4f6261ea5be5b3d1744144600c
7
- data.tar.gz: ed5716b466076d10668658a43534c3fbdda895261f78bfd27ec20125f1bd9f8c6d61c59efe5097fb9329fb8c57ebeeb4e779c6b7cfccc1ee710facb655d41686
6
+ metadata.gz: ec447e561ddb4b5b9654c14667cdcec5b47a3e6ad4d1e289b5c7e1ebd9f92df736a4efe2f4bb0b227e2002b91ce68bbcff2717554eb81736b0a94b4d25e7330b
7
+ data.tar.gz: 8aa70abe84111a4ca22d1cee235d9014133a586e0d2f4ef2422a6d95e3879959d809f8e95dd5254a0317d3aba200be64a2a6f21f61211c2f536ad2efc3df67ac
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- worldpay (1.2.6)
4
+ worldpay (1.2.8)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/worldpay.rb CHANGED
@@ -12,14 +12,14 @@ class Worldpay
12
12
  @endpoint = ''
13
13
 
14
14
  @errors = {}
15
- @raise_errors = true
15
+ @raise_errors = false
16
16
 
17
17
  @version = '1.2.3'
18
18
 
19
19
  @orderTypes = ['ECOM','MOTO','RECURRING','APM']
20
20
 
21
21
 
22
- def initialize(service_key='', timeout=3, raise_errors=true)
22
+ def initialize(service_key='', timeout=3, raise_errors=false)
23
23
  if service_key.empty?
24
24
  raise "Please set a Service Key"
25
25
  else
@@ -30,35 +30,35 @@ class Worldpay
30
30
  @endpoint = 'https://api.worldpay.com'
31
31
 
32
32
  @errors = {
33
- 'ip' => 'Invalid parameters',
34
- 'cine' => 'php_curl was not found',
35
- 'to' => 'Request timed out',
36
- 'nf' => 'Not found',
37
- 'apierror' => 'API Error',
38
- 'uanv' => 'Worldpay is currently unavailable, please try again later',
39
- 'contact' => 'Error contacting Worldpay, please try again later',
40
- 'ssl' => 'You must enable SSL check in production mode',
41
- 'verify' => 'Worldpay not verifying SSL connection',
42
- 'orderInput' => {
43
- 'token' => 'No token found',
44
- 'orderCode' => 'No order_code entered',
45
- 'orderDescription' => 'No order_description found',
46
- 'amount' => 'No amount found, or it is not a whole number',
47
- 'currencyCode' => 'No currency_code found',
48
- 'name' => 'No name found',
49
- 'billingAddress' => 'No billing_address found'
50
- },
51
- 'notificationPost' => 'Notification Error: Not a post',
52
- 'notificationUnknown' => 'Notification Error: Cannot be processed',
53
- 'capture' => {
54
- 'ordercode' => 'No order code entered'
55
- },
56
- 'refund' => {
57
- 'ordercode' => 'No order code entered'
58
- },
59
- 'json' => 'JSON could not be decoded',
60
- 'key' => 'Please enter your service key',
61
- 'sslerror' => 'Worldpay SSL certificate could not be validated'
33
+ 'ip' => 'Invalid parameters',
34
+ 'cine' => 'php_curl was not found',
35
+ 'to' => 'Request timed out',
36
+ 'nf' => 'Not found',
37
+ 'apierror' => 'API Error',
38
+ 'uanv' => 'Worldpay is currently unavailable, please try again later',
39
+ 'contact' => 'Error contacting Worldpay, please try again later',
40
+ 'ssl' => 'You must enable SSL check in production mode',
41
+ 'verify' => 'Worldpay not verifying SSL connection',
42
+ 'orderInput' => {
43
+ 'token' => 'No token found',
44
+ 'orderCode' => 'No order_code entered',
45
+ 'orderDescription' => 'No order_description found',
46
+ 'amount' => 'No amount found, or it is not a whole number',
47
+ 'currencyCode' => 'No currency_code found',
48
+ 'name' => 'No name found',
49
+ 'billingAddress' => 'No billing_address found'
50
+ },
51
+ 'notificationPost' => 'Notification Error: Not a post',
52
+ 'notificationUnknown' => 'Notification Error: Cannot be processed',
53
+ 'capture' => {
54
+ 'ordercode' => 'No order code entered'
55
+ },
56
+ 'refund' => {
57
+ 'ordercode' => 'No order code entered'
58
+ },
59
+ 'json' => 'JSON could not be decoded',
60
+ 'key' => 'Please enter your service key',
61
+ 'sslerror' => 'Worldpay SSL certificate could not be validated'
62
62
  }
63
63
  @raise_errors = raise_errors
64
64
  end
@@ -85,7 +85,16 @@ class Worldpay
85
85
  if (@raise_errors)
86
86
  raise message.to_s
87
87
  else
88
- p message.to_s
88
+ if (code!=nil && httpStatusCode!=nil && description!=nil && customCode!=nil)
89
+ return {
90
+ 'message'=>message,
91
+ 'code'=>code,
92
+ 'httpStatusCode'=>httpStatusCode,
93
+ 'description'=>description,
94
+ 'customCode'=>customCode
95
+ }
96
+ end
97
+ return message.to_s
89
98
  end
90
99
  end
91
100
 
@@ -94,7 +103,7 @@ class Worldpay
94
103
  errors2 = []
95
104
 
96
105
  if (!order.any?)
97
- onError('ip')
106
+ return onError('ip')
98
107
  end
99
108
  if (order['token']==nil)
100
109
  errors2 << @errors['orderInput']['token']
@@ -116,7 +125,7 @@ class Worldpay
116
125
  end
117
126
 
118
127
  if (errors2.length > 0)
119
- onError('ip', errors2.join(', '))
128
+ return onError('ip', errors2.join(', '))
120
129
  end
121
130
  end
122
131
 
@@ -125,7 +134,7 @@ class Worldpay
125
134
  self.checkOrderInput(order)
126
135
 
127
136
  defaults = {
128
- 'orderType' => 'ECOM', #Order Type: ECOM/MOTO/RECURRING
137
+ 'orderType' => 'ECOM', #Order Type: ECOM/MOTO/RECURRING/APM
129
138
  'customerIdentifiers' => nil,
130
139
  'billingAddress' => nil,
131
140
  'deliveryAddress' => nil
@@ -169,11 +178,11 @@ class Worldpay
169
178
 
170
179
  response = sendRequest('orders', request.to_json, true)
171
180
 
172
- if (response['body']['orderCode'])
181
+ if (response['body'] && response['body']['orderCode'])
173
182
  #success
174
183
  return response
175
184
  else
176
- onError('apierror', response.to_s)
185
+ return {'response'=> response, 'error'=> onError('apierror', response.to_s)}
177
186
  end
178
187
 
179
188
  end
@@ -183,12 +192,12 @@ class Worldpay
183
192
  self.checkOrderInput(order)
184
193
 
185
194
  defaults = {
186
- 'deliveryAddress' => nil,
187
- 'billingAddress' => nil,
188
- 'successUrl' => nil,
189
- 'pendingUrl' => nil,
190
- 'failureUrl' => nil,
191
- 'cancelUrl' => nil
195
+ 'deliveryAddress' => nil,
196
+ 'billingAddress' => nil,
197
+ 'successUrl' => nil,
198
+ 'pendingUrl' => nil,
199
+ 'failureUrl' => nil,
200
+ 'cancelUrl' => nil
192
201
  }
193
202
 
194
203
  order = defaults.merge(order)
@@ -197,22 +206,22 @@ class Worldpay
197
206
  cost_cents = fmt.split('.').join('')
198
207
 
199
208
  request = {
200
- 'token' => order['token'],
201
- 'orderDescription' => order['orderDescription'],
202
- 'amount' => cost_cents,
203
- 'currencyCode' => order['currencyCode'],
204
- 'name' => order['name'],
205
- 'shopperEmailAddress' => order['shopperEmailAddress'],
206
- 'billingAddress' => order['billingAddress'],
207
- 'deliveryAddress' => order['deliveryAddress'],
208
- 'customerOrderCode' => order['customerOrderCode'],
209
- 'successUrl' => order['successUrl'],
210
- 'pendingUrl' => order['pendingUrl'],
211
- 'failureUrl' => order['failureUrl'],
212
- 'cancelUrl' => order['cancelUrl'],
213
- 'statementNarrative' => order['statementNarrative'],
214
- 'settlementCurrency' => order['settlementCurrency'],
215
- 'customerIdentifiers' => order['customerIdentifiers'].present? ? JSON.parse(order['customerIdentifiers']) : nil,
209
+ 'token' => order['token'],
210
+ 'orderDescription' => order['orderDescription'],
211
+ 'amount' => cost_cents,
212
+ 'currencyCode' => order['currencyCode'],
213
+ 'name' => order['name'],
214
+ 'shopperEmailAddress' => order['shopperEmailAddress'],
215
+ 'billingAddress' => order['billingAddress'],
216
+ 'deliveryAddress' => order['deliveryAddress'],
217
+ 'customerOrderCode' => order['customerOrderCode'],
218
+ 'successUrl' => order['successUrl'],
219
+ 'pendingUrl' => order['pendingUrl'],
220
+ 'failureUrl' => order['failureUrl'],
221
+ 'cancelUrl' => order['cancelUrl'],
222
+ 'statementNarrative' => order['statementNarrative'],
223
+ 'settlementCurrency' => order['settlementCurrency'],
224
+ 'customerIdentifiers' => order['customerIdentifiers'].present? ? JSON.parse(order['customerIdentifiers']) : nil,
216
225
  }
217
226
 
218
227
  response = sendRequest('orders', request.to_json, true)
@@ -221,7 +230,7 @@ class Worldpay
221
230
  #success
222
231
  return response
223
232
  else
224
- onError('apierror', response.to_s)
233
+ return onError('apierror', response.to_s)
225
234
  end
226
235
 
227
236
  end
@@ -230,22 +239,22 @@ class Worldpay
230
239
  authorize3DSOrder(orderCode, responseCode, threeDsInfo)
231
240
  end
232
241
  def authorize3DSOrder(orderCode, responseCode, threeDsInfo)
233
- request = {
234
- 'threeDSResponseCode' => responseCode,
235
- 'shopperSessionId' => threeDsInfo['shopperSessionId'],
236
- 'shopperAcceptHeader' => threeDsInfo['shopperAcceptHeader'],
237
- 'shopperUserAgent' => threeDsInfo['shopperUserAgent'],
238
- 'shopperIpAddress' => threeDsInfo['shopperIpAddress']
239
- }
242
+ request = {
243
+ 'threeDSResponseCode' => responseCode,
244
+ 'shopperSessionId' => threeDsInfo['shopperSessionId'],
245
+ 'shopperAcceptHeader' => threeDsInfo['shopperAcceptHeader'],
246
+ 'shopperUserAgent' => threeDsInfo['shopperUserAgent'],
247
+ 'shopperIpAddress' => threeDsInfo['shopperIpAddress']
248
+ }
240
249
 
241
- response = sendRequest('orders/'+orderCode, request.to_json, true, 'PUT')
250
+ response = sendRequest('orders/'+orderCode, request.to_json, true, 'PUT')
242
251
 
243
- if (response['body']['orderCode'])
244
- #success
245
- return response
246
- else
247
- onError('apierror', response.to_s)
248
- end
252
+ if (response['body']['orderCode'])
253
+ #success
254
+ return response
255
+ else
256
+ return onError('apierror', response.to_s)
257
+ end
249
258
  end
250
259
 
251
260
  #Capture Authorized Worldpay Order
@@ -256,7 +265,7 @@ class Worldpay
256
265
  if (orderCode || orderCode.is_a?(String))
257
266
  #
258
267
  else
259
- onError('ip', @errors['capture']['ordercode'])
268
+ return onError('ip', @errors['capture']['ordercode'])
260
269
  end
261
270
 
262
271
  if (amount && amount.is_a?(Integer))
@@ -274,7 +283,7 @@ class Worldpay
274
283
  if (orderCode || orderCode.is_a?(String))
275
284
  #
276
285
  else
277
- onError('ip', @errors['capture']['ordercode'])
286
+ return onError('ip', @errors['capture']['ordercode'])
278
287
  end
279
288
 
280
289
  sendRequest('orders/'+orderCode, false, false, 'DELETE')
@@ -283,7 +292,7 @@ class Worldpay
283
292
  #Refund Worldpay order
284
293
  def refundOrder(orderCode=false, amount=false)
285
294
  if (orderCode==false || orderCode!=orderCode.to_s)
286
- onError('ip', @errors['refund']['ordercode'])
295
+ return onError('ip', @errors['refund']['ordercode'])
287
296
  end
288
297
  if (amount!=false)
289
298
  json = {'refundAmount'=>amount}.to_json
@@ -339,35 +348,35 @@ class Worldpay
339
348
  end
340
349
 
341
350
  if (expectResponse && !response.present?)
342
- onError('uanv', @errors['json'], 503);
351
+ return onError('uanv', @errors['json'], 503);
343
352
  end
344
353
 
345
354
  if (response && response["httpStatusCode"].present?)
346
355
 
347
356
  if (response["httpStatusCode"] != '200')
348
- onError(
349
- false,
350
- response["message"],
351
- result.code,
352
- response['httpStatusCode'],
353
- response['description'],
354
- response['customCode']
355
- )
357
+ return onError(
358
+ false,
359
+ response["message"],
360
+ result.code,
361
+ response['httpStatusCode'],
362
+ response['description'],
363
+ response['customCode']
364
+ )
356
365
  end
357
366
  elsif (expectResponse && result.code != '200')
358
367
  # If we expect a result and we have an error
359
- onError('uanv', @errors['json'], 503)
368
+ return onError('uanv', @errors['json'], 503)
360
369
  elsif (!expectResponse)
361
- if (result.code != '200')
362
- onError('apierror', result.read_body, result.code)
363
- else
364
- response = true
365
- end
370
+ if (result.code != '200')
371
+ return onError('apierror', result.read_body, result.code)
372
+ else
373
+ response = true
374
+ end
366
375
  end
367
376
 
368
377
  return {
369
- "code"=>result.code,
370
- "body"=>response
378
+ "code"=>result.code,
379
+ "body"=>response
371
380
  }
372
381
 
373
382
  end
@@ -381,12 +390,11 @@ class Worldpay
381
390
  #Get card details from Worldpay token
382
391
  def getStoredCardDetails(token=false)
383
392
  if (token==false || token!=token.to_s)
384
- onError('ip', @errors['orderInput']['token'])
393
+ return onError('ip', @errors['orderInput']['token'])
385
394
  end
386
395
 
387
396
  response = sendRequest('tokens/'+token, false, true, 'GET')
388
397
 
389
-
390
398
  if (response['body']['paymentMethod'])
391
399
  return response['body']['paymentMethod']
392
400
  else
@@ -397,13 +405,13 @@ class Worldpay
397
405
 
398
406
  def getOrder(orderCode = false)
399
407
  if (orderCode==false || !orderCode.present?)
400
- onError('ip', @errors['orderInput']['orderCode']);
408
+ return onError('ip', @errors['orderInput']['orderCode']);
401
409
  end
402
410
 
403
411
  response = sendRequest('orders/' + orderCode, false, true, 'GET');
404
412
 
405
413
  if (!response['body']['orderCode'].present?)
406
- onError('apierror')
414
+ return onError('apierror')
407
415
  end
408
416
 
409
417
  return response
data/worldpay.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "worldpay"
7
- spec.version = "1.2.7"
7
+ spec.version = "1.2.8"
8
8
  spec.authors = ["Andrew Odendaal, Paul Beckford"]
9
9
  spec.email = ["andrew.odendaal@worldpay.com"]
10
10
  spec.summary = %q{online.worldpay.com ruby lib.}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: worldpay
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.7
4
+ version: 1.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Odendaal, Paul Beckford
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-06 00:00:00.000000000 Z
11
+ date: 2016-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -55,7 +55,6 @@ files:
55
55
  - lib/worldpay.rb
56
56
  - test/test_helper.rb
57
57
  - test/worldpay_test.rb
58
- - worldpay-1.2.5.gem
59
58
  - worldpay.gemspec
60
59
  homepage: https://online.worldpay.com
61
60
  licenses:
data/worldpay-1.2.5.gem DELETED
Binary file