active_paypal_adaptive_payment 0.3.13 → 0.3.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,21 +1,28 @@
1
- ## 0 0.3.12 (2012-05-18)
2
- - Added option displayMaxTotalAmount to build_preapproval_payment to display amount with paypal on payment (04b37c9) by eldoy
1
+ ## 0.3.14 (2012-07-06)
3
2
 
4
- ## 0 0.3.12 (2012-05-02)
3
+ - Expose raw and request objects for easier logging / debugging (pull req #25) by saizai
4
+ - rm unusued refund fields (pull req #25) by saizai
5
+ - Also added: receiver_list is optional for refunds (refunds everything on that paykey if not specified) (pull req #25) by saizai
6
+
7
+ ## 0.3.12 (2012-05-18)
8
+
9
+ - Added option displayMaxTotalAmount to build_preapproval_payment to display amount with paypal on payment (04b37c9) by eldoy
10
+
11
+ ## 0.3.12 (2012-05-02)
5
12
 
6
13
  - Add displayOptions and receiverOptions support to
7
14
  SetPaymentOptionsRequest (Niels Ganser) by 597ecad
8
15
 
9
- ## 0 0.3.11 (2012-04-28)
16
+ ## 0.3.11 (2012-04-28)
10
17
 
11
18
  - Added option :action_type to build_adaptive_payment_pay_request to enable delayed chained payments (3df6948) by eldoy
12
19
 
13
20
 
14
- ## 0 0.3.10 (2012-03-30)
21
+ ## 0.3.10 (2012-03-30)
15
22
 
16
23
  - Added referrerCode in SetPaymentOptions request (by njvitto)
17
24
 
18
- ## 0 0.3.3 (16/Nov/11)
25
+ ## 0.3.3 (16/Nov/11)
19
26
 
20
27
  - add functionality to allow a user to redirect to the correct URL
21
28
  when creating a pre-approval request. In addition, the
data/README.md CHANGED
@@ -181,6 +181,7 @@ xml request, raw json response and the URL of the endpoint.
181
181
  * Nicola Junior Vitto (<https://github.com/njvitto>)
182
182
  * Vidar Eldøy (https://github.com/eldoy)
183
183
  * Niels Ganser (https://github.com/Nielsomat)
184
+ * saizai (Sai) (https://github.com/saizai)
184
185
 
185
186
  ## Other previous contributors where some code was taken from.
186
187
 
@@ -33,9 +33,9 @@ module ActiveMerchant
33
33
  self.homepage_url = 'http://x.com/'
34
34
  self.display_name = 'Paypal Adaptive Payments'
35
35
 
36
- def initialize(config = {})
37
- requires!(config, :login, :password, :signature, :appid)
38
- @config = config.dup
36
+ def initialize(options = {})
37
+ requires!(options, :login, :password, :signature, :appid)
38
+ @options = options.dup
39
39
  super
40
40
  end
41
41
 
@@ -92,7 +92,7 @@ module ActiveMerchant
92
92
  end
93
93
 
94
94
  def debug
95
- "Url: #{@url}\n\n Request: #{@xml} \n\n Response: #{@response.json}"
95
+ {:url => @url, :request => @xml, :response => @response.json}
96
96
  end
97
97
 
98
98
  private
@@ -261,28 +261,21 @@ module ActiveMerchant
261
261
  x.errorLanguage options[:error_language] ||= 'en_US'
262
262
  end
263
263
  x.actionType 'REFUND'
264
- if options[:pay_key]
265
- x.payKey options[:pay_key]
266
- end
267
- if options[:transaction_id]
268
- x.payKey options[:transaction_id]
269
- end
270
- if options[:tracking_id]
271
- x.trackingId options[:tracking_id]
272
- end
273
- x.cancelUrl options[:cancel_url]
274
- x.returnUrl options[:return_url]
264
+ x.payKey options[:pay_key] if options[:pay_key]
265
+ x.payKey options[:transaction_id] if options[:transaction_id]
266
+ x.trackingId options[:tracking_id] if options[:tracking_id]
275
267
  x.currencyCode options[:currency_code] ||= 'USD'
276
268
  x.receiverList do |x|
277
269
  options[:receiver_list].each do |receiver|
278
270
  x.receiver do |x|
279
271
  x.amount receiver[:amount]
280
- x.paymentType receiver[:payment_type] ||= 'GOODS'
281
- x.invoiceId receiver[:invoice_id] if receiver[:invoice_id]
272
+ # x.paymentType receiver[:payment_type] ||= 'GOODS' # API specifies "not used"
273
+ # x.invoiceId receiver[:invoice_id] if receiver[:invoice_id] # API specifies "not used"
282
274
  x.email receiver[:email]
275
+ x.primary receiver[:primary] if receiver.key?(:primary)
283
276
  end
284
277
  end
285
- end
278
+ end if options[:receiver_list]
286
279
  x.feesPayer options[:fees_payer] ||= 'EACHRECEIVER'
287
280
  end
288
281
  end
@@ -377,17 +370,17 @@ module ActiveMerchant
377
370
  end
378
371
 
379
372
  def commit(action, data)
380
- @response = AdaptivePaymentResponse.new(post_through_ssl(action, data))
373
+ @response = AdaptivePaymentResponse.new(post_through_ssl(action, data), data, action)
381
374
  end
382
375
 
383
376
  def post_through_ssl(action, parameters = {})
384
377
  headers = {
385
378
  "X-PAYPAL-REQUEST-DATA-FORMAT" => "XML",
386
379
  "X-PAYPAL-RESPONSE-DATA-FORMAT" => "JSON",
387
- "X-PAYPAL-SECURITY-USERID" => @config[:login],
388
- "X-PAYPAL-SECURITY-PASSWORD" => @config[:password],
389
- "X-PAYPAL-SECURITY-SIGNATURE" => @config[:signature],
390
- "X-PAYPAL-APPLICATION-ID" => @config[:appid],
380
+ "X-PAYPAL-SECURITY-USERID" => @options[:login],
381
+ "X-PAYPAL-SECURITY-PASSWORD" => @options[:password],
382
+ "X-PAYPAL-SECURITY-SIGNATURE" => @options[:signature],
383
+ "X-PAYPAL-APPLICATION-ID" => @options[:appid],
391
384
  }
392
385
  action_url(action)
393
386
  request = Net::HTTP::Post.new(@url.path)
@@ -396,6 +389,10 @@ module ActiveMerchant
396
389
  request.content_type = 'text/xml'
397
390
  server = Net::HTTP.new(@url.host, 443)
398
391
  server.use_ssl = true
392
+ # OSX: sudo port install curl-ca-bundle
393
+ server.verify_mode = OpenSSL::SSL::VERIFY_PEER
394
+ server.ca_path = '/etc/ssl/certs' if File.exists?('/etc/ssl/certs') # Ubuntu
395
+ server.ca_file = '/opt/local/share/curl/curl-ca-bundle.crt' if File.exists?('/opt/local/share/curl/curl-ca-bundle.crt') # Mac OS X
399
396
  server.start { |http| http.request(request) }.body
400
397
  end
401
398
 
@@ -404,7 +401,7 @@ module ActiveMerchant
404
401
  end
405
402
 
406
403
  def test?
407
- @config[:test] || Base.gateway_mode == :test
404
+ @options[:test] || Base.gateway_mode == :test
408
405
  end
409
406
 
410
407
  def action_url(action)
@@ -1,4 +1,4 @@
1
- require 'multi_json'
1
+ require 'multi_json'
2
2
  require 'hashie'
3
3
 
4
4
  module ActiveMerchant
@@ -7,16 +7,20 @@ module ActiveMerchant
7
7
 
8
8
  SUCCESS = 'Success'.freeze
9
9
 
10
- attr_reader :json
10
+ attr_reader :json, :request, :action, :response, :xml_request
11
11
  alias :raw :json
12
+ alias :raw_request :xml_request
12
13
 
13
- def initialize(json)
14
+ def initialize(json, xml_request = nil, action = nil)
14
15
  @json = json
15
- @response_rash = Hashie::Rash.new(MultiJson.decode(json))
16
+ @response = Hashie::Rash.new(MultiJson.decode(json))
17
+ @xml_request = xml_request
18
+ @request = Hashie::Rash.from_xml(xml_request)
19
+ @action = action
16
20
  end
17
21
 
18
22
  def method_missing(method, *args, &block)
19
- @response_rash.send(method, *args, &block)
23
+ @response.send(method, *args, &block)
20
24
  end
21
25
 
22
26
  # def redirect_url_for
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_paypal_adaptive_payment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.13
4
+ version: 0.3.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-17 00:00:00.000000000 Z
12
+ date: 2012-07-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemerchant
16
- requirement: &88363450 !ruby/object:Gem::Requirement
16
+ requirement: &86350740 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.5.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *88363450
24
+ version_requirements: *86350740
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: multi_json
27
- requirement: &88363210 !ruby/object:Gem::Requirement
27
+ requirement: &86350500 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *88363210
35
+ version_requirements: *86350500
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: hashie
38
- requirement: &88362970 !ruby/object:Gem::Requirement
38
+ requirement: &86366660 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.2.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *88362970
46
+ version_requirements: *86366660
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: money
49
- requirement: &88362730 !ruby/object:Gem::Requirement
49
+ requirement: &86366420 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 3.6.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *88362730
57
+ version_requirements: *86366420
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: mocha
60
- requirement: &88362490 !ruby/object:Gem::Requirement
60
+ requirement: &86366180 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: 0.10.0
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *88362490
68
+ version_requirements: *86366180
69
69
  description: ! ' This library is meant to interface with PayPal''s Adaptive Payment
70
70
  Gateway.
71
71