worldpay 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e92644d37cb8da4444775fd15e0baa0499324e37
4
- data.tar.gz: 05d4eb59966c00ca06031043c3afe56f398a2454
3
+ metadata.gz: 035b83919e61de6a530c882706c513391dd2fa9a
4
+ data.tar.gz: 8d4c3e3d0226219f72464e4305ac3495dc9e8143
5
5
  SHA512:
6
- metadata.gz: 4d768380d5dd922350c15793d05d91e0c8aaf38fe19f44a6617c6a76b9627301cdf4e4987e408b37c47e0c0ef5438cf941c48b161d59e35396535839e6933558
7
- data.tar.gz: 027ffd22c1f2ab8e4af06c5891c12f53bc0439cf2a3b875e48d89b2fd7b5855aea6457e64740af1ca5643dd0acd2c3f18542e4e5614c4f042787455ea8a23391
6
+ metadata.gz: 97ac464d180ba7b8963f54f1081f24039cb3832fce88b97e5532f0dc134ef63419680fc9c23344867d2b5c87aae057ca969dabc73d3719b363975911dabd219b
7
+ data.tar.gz: 9ed4b54692604b6b5c21f7f44cf25ebc597fcdd3fe9df24eb992a0cfd2c1da56e9189ce7e75442fb4568aa15b25044343f1064bafe67b005c2a03f6d28ce6e32
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- worldpay (1.0.4)
4
+ worldpay (1.0.6)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/worldpay.rb CHANGED
@@ -14,7 +14,9 @@ class Worldpay
14
14
  @errors = {}
15
15
  @raise_errors = true
16
16
 
17
- @version = '1.0.5'
17
+ @version = '1.0.6'
18
+
19
+ @orderTypes = ['ECOM','MOTO','RECURRING']
18
20
 
19
21
 
20
22
  def initialize(service_key='', timeout=3, raise_errors=true)
@@ -47,6 +49,9 @@ class Worldpay
47
49
  },
48
50
  'notificationPost' => 'Notification Error: Not a post',
49
51
  'notificationUnknown' => 'Notification Error: Cannot be processed',
52
+ 'capture' => {
53
+ 'ordercode' => 'No order code entered'
54
+ },
50
55
  'refund' => {
51
56
  'ordercode' => 'No order code entered'
52
57
  },
@@ -80,13 +85,6 @@ class Worldpay
80
85
  def onError(error, message=false, code=nil, httpStatusCode=nil, description=nil, customCode=nil)
81
86
 
82
87
 
83
-
84
- =begin
85
- if (message)
86
- message = ' - '+message
87
- end
88
- =end
89
-
90
88
  if (@raise_errors)
91
89
  raise message.to_s
92
90
  else
@@ -134,7 +132,7 @@ class Worldpay
134
132
  self.checkOrderInput(order)
135
133
 
136
134
  defaults = {
137
- 'orderType' => 'ECOM',
135
+ 'orderType' => 'ECOM', #Order Type: ECOM/MOTO/RECURRING
138
136
  'customerIdentifiers' => nil,
139
137
  'billingAddress' => nil
140
138
  }
@@ -151,7 +149,8 @@ class Worldpay
151
149
  'is3DSOrder' => order['3DS'],
152
150
  'currencyCode' => order['currencyCode'],
153
151
  'name' => order['name'],
154
- 'orderType' => order['orderType'],
152
+ 'orderType' => order['orderType'] && @orderTypes ? (@orderTypes.include?(order['orderType']) ? order['orderType'] : 'ECOM') : 'ECOM',
153
+ 'authorizeOnly' => order['authoriseOnly'] ? true : false,
155
154
  'billingAddress' => order['billingAddress'],
156
155
  'customerOrderCode' => order['customerOrderCode'],
157
156
  'customerIdentifiers' => order['customerIdentifiers']
@@ -197,6 +196,33 @@ class Worldpay
197
196
  end
198
197
  end
199
198
 
199
+ #Capture Authorized Worldpay Order
200
+ def captureAuthorisedOrder(orderCode=false, amount=false)
201
+ if (orderCode || orderCode.is_a?(String))
202
+ #
203
+ else
204
+ onError('ip', @errors['capture']['ordercode'])
205
+ end
206
+
207
+ if (amount && amount.is_a?(Integer))
208
+ json = {'captureAmount'=>amount}.to_json
209
+ end
210
+
211
+ sendRequest('orders/'+orderCode+'/capture', (json||false))
212
+ end
213
+
214
+ #Cancel Authorized Worldpay Order
215
+ def cancelAuthorisedOrder(orderCode=false)
216
+ if (orderCode || orderCode.is_a?(String))
217
+ #
218
+ else
219
+ onError('ip', @errors['capture']['ordercode'])
220
+ end
221
+
222
+ sendRequest('orders/'+orderCode, false, false, 'DELETE')
223
+ end
224
+
225
+
200
226
  #Refund Worldpay order
201
227
  def refundOrder(orderCode=false, amount=false)
202
228
  if (orderCode==false || orderCode!=orderCode.to_s)
@@ -224,8 +250,12 @@ class Worldpay
224
250
  request = Net::HTTP::Get.new('/v1/'+action)
225
251
  elsif (method=="PUT")
226
252
  request = Net::HTTP::Put.new('/v1/'+action)
253
+ elsif (method=="DELETE")
254
+ request = Net::HTTP::Delete.new('/v1/'+action)
227
255
  end
228
256
 
257
+ # ? request = Net::HTTP::Put.new('/v1/'+action)
258
+
229
259
  net.use_ssl = true
230
260
  net.verify_mode = @disable_ssl ? OpenSSL::SSL::VERIFY_NONE : OpenSSL::SSL::VERIFY_PEER
231
261
 
@@ -247,8 +277,6 @@ class Worldpay
247
277
  response = net.start do |http|
248
278
  http.request(request)
249
279
  end
250
- #puts response.code
251
- #puts response.read_body
252
280
 
253
281
  return {
254
282
  "code"=>response.code,
Binary file
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.0.5"
7
+ spec.version = "1.0.6"
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.0.5
4
+ version: 1.0.6
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: 2015-02-09 00:00:00.000000000 Z
11
+ date: 2015-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -63,6 +63,7 @@ files:
63
63
  - worldpay-1.0.2.gem
64
64
  - worldpay-1.0.3.gem
65
65
  - worldpay-1.0.4.gem
66
+ - worldpay-1.0.5.gem
66
67
  - worldpay.gemspec
67
68
  homepage: https://online.worldpay.com
68
69
  licenses: