adyen 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/adyen.gemspec +2 -2
  2. data/lib/adyen/soap.rb +190 -6
  3. metadata +2 -2
data/adyen.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'adyen'
3
- s.version = "0.3.4"
4
- s.date = "2010-01-06"
3
+ s.version = "0.3.5"
4
+ s.date = "2010-02-09"
5
5
 
6
6
  s.summary = "Integrate Adyen payment services in you Ruby on Rails application."
7
7
  s.description = <<-EOS
data/lib/adyen/soap.rb CHANGED
@@ -155,7 +155,7 @@ module Adyen
155
155
  def authorise(args = {})
156
156
  invoke_args = Adyen::SOAP.default_arguments.merge(args)
157
157
  invoke_args[:selected_recurring_detail_reference] ||= 'LATEST'
158
-
158
+
159
159
  response = invoke('payment:authorise') do |message|
160
160
  message.add('payment:paymentRequest') do |req|
161
161
  req.add('payment:selectedRecurringDetailReference', invoke_args[:selected_recurring_detail_reference])
@@ -173,21 +173,114 @@ module Adyen
173
173
  req.add('payment:shopperInteraction', 'ContAuth')
174
174
  end
175
175
  end
176
+
177
+ parse_authorise(response)
176
178
  end
177
-
178
- # Cancel or refund a payment.
179
+
180
+ # Capture a payment.
179
181
  #
180
- # @param [Hash] args The paramaters to use for this call. These will be marged by any default
182
+ # @param [Hash] args The paramaters to use for this call. These will be merged by any default
183
+ # parameters set using {Adyen::SOAP.default_arguments}. Note that every option defined below
184
+ # is required by the Adyen SOAP service, so please provide a value for all options.
185
+ # @option args [String] :merchant_account The merchant account to file this payment under.
186
+ # @option args [String] :currency The currency code (EUR, GBP, USD, etc).
187
+ # @option args [Integer] :value The value of the payment in cents.
188
+ # @option args [String] :original_reference The psp_reference of the payment to capture.
189
+ #
190
+ # @return [nil] This action returns nothing of interest.
191
+ #
192
+ # @see https://support.adyen.com/index.php?_m=downloads&_a=viewdownload&downloaditemid=1
193
+ # The Adyen integration manual
194
+ #
195
+ # @todo Parse response object and return something useful
196
+ def capture(args = {})
197
+ invoke_args = Adyen::SOAP.default_arguments.merge(args)
198
+ response = invoke('payment:capture') do |message|
199
+ message.add('payment:modificationRequest') do |req|
200
+ req.add('payment:merchantAccount', invoke_args[:merchant_account])
201
+ req.add('payment:modificationAmount') do |amount|
202
+ amount.add('common:currency', invoke_args[:currency])
203
+ amount.add('common:value', invoke_args[:value])
204
+ end
205
+ req.add('payment:originalReference', invoke_args[:original_reference])
206
+ end
207
+ end
208
+
209
+ parse_capture(response)
210
+ end
211
+
212
+ # Cancel a payment.
213
+ #
214
+ # @param [Hash] args The paramaters to use for this call. These will be merged by any default
181
215
  # parameters set using {Adyen::SOAP.default_arguments}. Note that every option defined below
182
216
  # is required by the Adyen SOAP service, so please provide a value for all options.
183
217
  # @option args [String] :merchant_account The merchant account to file this payment under.
184
218
  # @option args [String] :original_reference The psp_reference of the payment to cancel.
185
219
  #
186
- # @return [nil] This action returns nothing of interest. The result of the authorization
187
- # will be communicated using a {Adyen::Notification notification}.
220
+ # @return [nil] This action returns nothing of interest.
188
221
  #
189
222
  # @see https://support.adyen.com/index.php?_m=downloads&_a=viewdownload&downloaditemid=1
190
223
  # The Adyen integration manual
224
+ #
225
+ # @todo Parse response object and return something useful
226
+ def cancel(args = {})
227
+ invoke_args = Adyen::SOAP.default_arguments.merge(args)
228
+ response = invoke('payment:cancel') do |message|
229
+ message.add('payment:modificationRequest') do |req|
230
+ req.add('payment:merchantAccount', invoke_args[:merchant_account])
231
+ req.add('payment:originalReference', invoke_args[:original_reference])
232
+ end
233
+ end
234
+
235
+ parse_cancel(response)
236
+ end
237
+
238
+ # Refund a payment.
239
+ #
240
+ # @param [Hash] args The paramaters to use for this call. These will be merged by any default
241
+ # parameters set using {Adyen::SOAP.default_arguments}. Note that every option defined below
242
+ # is required by the Adyen SOAP service, so please provide a value for all options.
243
+ # @option args [String] :merchant_account The merchant account to file this payment under.
244
+ # @option args [String] :currency The currency code (EUR, GBP, USD, etc).
245
+ # @option args [Integer] :value The value of the refund in cents.
246
+ # @option args [String] :original_reference The psp_reference of the payment to refund.
247
+ #
248
+ # @return [nil] This action returns nothing of interest.
249
+ #
250
+ # @see https://support.adyen.com/index.php?_m=downloads&_a=viewdownload&downloaditemid=1
251
+ # The Adyen integration manual
252
+ #
253
+ # @todo Parse response object and return something useful
254
+ def refund(args = {})
255
+ invoke_args = Adyen::SOAP.default_arguments.merge(args)
256
+ response = invoke('payment:refund') do |message|
257
+ message.add('payment:modificationRequest') do |req|
258
+ req.add('payment:merchantAccount', invoke_args[:merchant_account])
259
+ req.add('payment:modificationAmount') do |amount|
260
+ amount.add('common:currency', invoke_args[:currency])
261
+ amount.add('common:value', invoke_args[:value])
262
+ end
263
+ req.add('payment:originalReference', invoke_args[:original_reference])
264
+ end
265
+ end
266
+
267
+ parse_refund(response)
268
+ end
269
+
270
+ # Cancel or refund a payment.
271
+ #
272
+ # @param [Hash] args The paramaters to use for this call. These will be merged by any default
273
+ # parameters set using {Adyen::SOAP.default_arguments}. Note that every option defined below
274
+ # is required by the Adyen SOAP service, so please provide a value for all options.
275
+ # @option args [String] :merchant_account The merchant account to file this payment under.
276
+ # @option args [String] :original_reference The psp_reference of the payment to cancel or refund.
277
+ #
278
+ # @return [nil] This action returns nothing of interest.
279
+ #
280
+ # @see https://support.adyen.com/index.php?_m=downloads&_a=viewdownload&downloaditemid=1
281
+ # The Adyen integration manual
282
+ #
283
+ # @todo Parse response object and return something useful
191
284
  def cancel_or_refund(args = {})
192
285
  invoke_args = Adyen::SOAP.default_arguments.merge(args)
193
286
  response = invoke('payment:cancelOrRefund') do |message|
@@ -196,7 +289,54 @@ module Adyen
196
289
  req.add('payment:originalReference', invoke_args[:original_reference])
197
290
  end
198
291
  end
292
+
293
+ parse_cancel_or_refund(response)
294
+ end
295
+
296
+ private
297
+
298
+ def parse_authorise(response)
299
+ response = response.xpath('//payment:authoriseResponse/payment:paymentResult')
300
+ {
301
+ :psp_reference => response.xpath('./payment:pspReference/text()').to_s,
302
+ :result_code => response.xpath('./payment:resultCode/text()').to_s,
303
+ :auth_code => response.xpath('./payment:authCode/text()').to_s,
304
+ :refusal_reason => response.xpath('./payment:refusalReason/text()').to_s
305
+ }
199
306
  end
307
+
308
+ def parse_capture(response)
309
+ response = response.xpath('//payment:captureResponse/payment:captureResult')
310
+ {
311
+ :psp_reference => response.xpath('./payment:pspReference/text()').to_s,
312
+ :response => response.xpath('./payment:response/text()').to_s
313
+ }
314
+ end
315
+
316
+ def parse_cancel(response)
317
+ response = response.xpath('//payment:cancelResponse/payment:cancelResult')
318
+ {
319
+ :psp_reference => response.xpath('./payment:pspReference/text()').to_s,
320
+ :response => response.xpath('./payment:response/text()').to_s
321
+ }
322
+ end
323
+
324
+ def parse_refund(response)
325
+ response = response.xpath('//payment:refundResponse/payment:refundResult')
326
+ {
327
+ :psp_reference => response.xpath('./payment:pspReference/text()').to_s,
328
+ :response => response.xpath('./payment:response/text()').to_s
329
+ }
330
+ end
331
+
332
+ def parse_cancel_or_refund(response)
333
+ response = response.xpath('//payment:cancelOrRefundResponse/payment:cancelOrRefundResult')
334
+ {
335
+ :psp_reference => response.xpath('./payment:pspReference/text()').to_s,
336
+ :response => response.xpath('./payment:response/text()').to_s
337
+ }
338
+ end
339
+
200
340
  end
201
341
 
202
342
  # SOAP client to interact with the recurring payment service of Adyen. This clients
@@ -227,6 +367,8 @@ module Adyen
227
367
 
228
368
  # Submits a recurring payment for a recurring contract to Adyen.
229
369
  #
370
+ # @deprecated This method has been replaced by {Adyen::SOAP::PaymentService.authorise}.
371
+ #
230
372
  # @example
231
373
  # Adyen::SOAP::RecurringService.submit(
232
374
  # :merchant_account => 'MyAccount',
@@ -280,6 +422,9 @@ module Adyen
280
422
  # @option args [String] :shopper_reference The refrence of the shopper. This should be
281
423
  # the same as the reference that was used to create the recurring contract.
282
424
  #
425
+ # @return [Hash] This method returns a hash representation of the
426
+ # listRecurringDetailsResponse.
427
+ #
283
428
  def list(args = {})
284
429
  invoke_args = Adyen::SOAP.default_arguments.merge(args)
285
430
  response = invoke('recurring:listRecurringDetails') do |message|
@@ -288,6 +433,8 @@ module Adyen
288
433
  req.add('recurring:shopperReference', invoke_args[:shopper_reference])
289
434
  end
290
435
  end
436
+
437
+ parse_list_recurring_details(response)
291
438
  end
292
439
 
293
440
  # Disables a recurring payment contract. Requires the following arguments:
@@ -316,10 +463,14 @@ module Adyen
316
463
  req.add('recurring:recurringDetailReference', invoke_args[:recurring_detail_reference])
317
464
  end
318
465
  end
466
+
467
+ parse_disable(response)
319
468
  end
320
469
 
321
470
  # Deactivates a recurring payment contract. Requires the following arguments:
322
471
  #
472
+ # @deprecated This method has been replaced by the {#disable} method.
473
+ #
323
474
  # @example
324
475
  # Adyen::SOAP::RecurringService.deactivate(
325
476
  # :merchant_account => 'MyAccount', :shopper_reference => user.id,
@@ -350,6 +501,39 @@ module Adyen
350
501
  end
351
502
  end
352
503
  end
504
+
505
+ private
506
+
507
+ def parse_list_recurring_details(response)
508
+ response = response.xpath('//recurring:listRecurringDetailsResponse/recurring:result')
509
+ {
510
+ :creation_date => response.xpath('./recurring:creationDate/text()').to_date,
511
+ :details => response.xpath('.//recurring:RecurringDetail').map { |node| parse_recurring_detail(node) },
512
+ :last_known_shopper_email => response.xpath('./recurring:lastKnownShopperEmail/text()').to_s,
513
+ :shopper_reference => response.xpath('./recurring:shopperReference/text()').to_s
514
+ }
515
+ end
516
+
517
+ # @todo add support for elv and bank
518
+ def parse_recurring_detail(node)
519
+ {
520
+ :recurring_detail_reference => node.xpath('./recurring:recurringDetailReference/text()').to_s,
521
+ :variant => node.xpath('./recurring:variant/text()').to_s,
522
+ :creation_date => node.xpath('./recurring:creationDate/text()').to_date,
523
+ :card => {
524
+ :expiry_date => Date.new(node.xpath('./recurring:card/payment:expiryYear/text()').to_i, node.xpath('recurring:card/payment:expiryMonth').to_i, -1),
525
+ :holder_name => node.xpath('./recurring:card/payment:holderName/text()').to_s,
526
+ :number => node.xpath('./recurring:card/payment:number/text()').to_s
527
+ }
528
+ }
529
+ end
530
+
531
+ def parse_disable(response)
532
+ response = response.xpath('//recurring:disableResponse/recurring:result')
533
+ {
534
+ :response => response.xpath('./recurring:response/text()').to_s
535
+ }
536
+ end
353
537
  end
354
538
  end
355
539
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adyen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Willem van Bergen
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-01-06 00:00:00 +01:00
13
+ date: 2010-02-09 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency