active_paypal_adaptive_payment 0.2.3 → 0.2.4

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.
@@ -1,3 +1,9 @@
1
+ ## 0.2.4
2
+
3
+ - renamed the pay method to setup_purchase, again, more like active_merchant.
4
+ - added paypal_adaptive_payment_common.rb for handling the redirects more like active_merchant
5
+ - removed the autoloads, they look kind of messy
6
+
1
7
  ## 0.2.3
2
8
 
3
9
  - `autoload` the helper libs.
data/README.md CHANGED
@@ -28,13 +28,13 @@ See [iAuction: An Adaptive Payments Tutorial Featuring Parallel Payments](https:
28
28
 
29
29
  ### Init
30
30
 
31
- @gateway =
32
- ActiveMerchant::Billing::PaypalAdaptivePayment.new(
33
- :login => "acutio_1313133342_biz_api1.gmail.com",
34
- :password => "1255043567",
35
- :signature => "Abg0gYcQlsdkls2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf",
36
- :appid => "APP-80W284485P519543T"
37
- )
31
+ gateway =
32
+ ActiveMerchant::Billing::PaypalAdaptivePayment.new(
33
+ :login => "acutio_1313133342_biz_api1.gmail.com",
34
+ :password => "1255043567",
35
+ :signature => "Abg0gYcQlsdkls2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf",
36
+ :appid => "APP-80W284485P519543T"
37
+ )
38
38
 
39
39
  ### Pre-approved paymen
40
40
 
@@ -1,17 +1,15 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'money'
3
+ require File.dirname(__FILE__) + '/paypal_adaptive_payments/ext'
4
+ require File.dirname(__FILE__) + '/paypal_adaptive_payment_common'
5
+ require File.dirname(__FILE__) + '/paypal_adaptive_payments/exceptions'
6
+ require File.dirname(__FILE__) + '/paypal_adaptive_payments/adaptive_payment_response'
3
7
 
4
8
  module ActiveMerchant #:nodoc:
5
9
  module Billing #:nodoc:
6
10
 
7
- autoload :AdaptivePaymentResponse,
8
- File.dirname(__FILE__) + '/paypal_adaptive_payments/adaptive_payment_response'
9
-
10
- class PaypalAdaptivePayment < Gateway # :nodoc:
11
-
12
- d = File.dirname(__FILE__) + '/paypal_adaptive_payments/'
13
- autoload :PaypalAdaptivePaymentsApiError, d + 'exception'
14
- autoload :HTTPHeader, d + 'ext'
11
+ class PaypalAdaptivePayment < Gateway # :nodoc
12
+ include PaypalAdaptivePaymentCommon
15
13
 
16
14
  TEST_URL = 'https://svcs.sandbox.paypal.com/AdaptivePayments/'
17
15
  LIVE_URL = 'https://svcs.paypal.com/AdaptivePayments/'
@@ -29,13 +27,9 @@ module ActiveMerchant #:nodoc:
29
27
  TYPES.each { |pt| const_set(pt, pt) }
30
28
  end
31
29
 
32
- # The countries the gateway supports merchants from as 2 digit ISO country codes
30
+ self.test_redirect_url= "https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey="
33
31
  self.supported_countries = ['US']
34
-
35
- # The homepage URL of the gateway
36
32
  self.homepage_url = 'http://x.com/'
37
-
38
- # The name of the gateway
39
33
  self.display_name = 'Paypal Adaptive Payments'
40
34
 
41
35
  def initialize(config = {})
@@ -44,7 +38,7 @@ module ActiveMerchant #:nodoc:
44
38
  super
45
39
  end
46
40
 
47
- def pay(options)
41
+ def setup_purchase(options)
48
42
  commit('Pay', build_adaptive_payment_pay_request(options))
49
43
  end
50
44
 
@@ -95,6 +89,7 @@ module ActiveMerchant #:nodoc:
95
89
  end
96
90
 
97
91
  private
92
+
98
93
  def build_adaptive_payment_pay_request(opts)
99
94
  @xml = ''
100
95
  xml = Builder::XmlMarkup.new :target => @xml, :indent => 2
@@ -272,7 +267,7 @@ module ActiveMerchant #:nodoc:
272
267
  "X-PAYPAL-SECURITY-USERID" => @config[:login],
273
268
  "X-PAYPAL-SECURITY-PASSWORD" => @config[:password],
274
269
  "X-PAYPAL-SECURITY-SIGNATURE" => @config[:signature],
275
- "X-PAYPAL-APPLICATION-ID" => @config[:appid]
270
+ "X-PAYPAL-APPLICATION-ID" => @config[:appid],
276
271
  }
277
272
  action_url(action)
278
273
  request = Net::HTTP::Post.new(@url.path)
@@ -0,0 +1,19 @@
1
+ module ActiveMerchant
2
+ module Billing
3
+ module PaypalAdaptivePaymentCommon
4
+ def self.included(base)
5
+ base.cattr_accessor :test_redirect_url
6
+ base.cattr_accessor :live_redirect_url
7
+ base.live_redirect_url = 'https://www.paypal.com/webscr?cmd=_ap-payment&paykey='
8
+ end
9
+
10
+ def redirect_url
11
+ test? ? test_redirect_url : live_redirect_url
12
+ end
13
+
14
+ def redirect_url_for(token)
15
+ redirect_url + token
16
+ end
17
+ end
18
+ end
19
+ end
@@ -4,10 +4,7 @@ require 'rash'
4
4
 
5
5
  module ActiveMerchant
6
6
  module Billing
7
- class AdaptivePaymentResponse
8
-
9
- REDIRECT_URL = 'https://www.paypal.com/webscr?cmd=_ap-payment&paykey='
10
- TEST_REDIRECT_URL = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey='
7
+ class AdaptivePaymentResponse < Response
11
8
 
12
9
  SUCCESS = 'Success'.freeze
13
10
 
@@ -23,9 +20,9 @@ module ActiveMerchant
23
20
  @response_rash.send(method, *args, &block)
24
21
  end
25
22
 
26
- def redirect_url_for
27
- Base.gateway_mode == :test ? (TEST_REDIRECT_URL + pay_key) : (REDIRECT_URL + pay_key)
28
- end
23
+ # def redirect_url_for
24
+ # Base.gateway_mode == :test ? (TEST_REDIRECT_URL + pay_key) : (REDIRECT_URL + pay_key)
25
+ # end
29
26
 
30
27
  def ack
31
28
  response_envelope.ack
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.2.3
4
+ version: 0.2.4
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: 2011-08-16 00:00:00.000000000Z
12
+ date: 2011-08-23 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemerchant
16
- requirement: &14390140 !ruby/object:Gem::Requirement
16
+ requirement: &13313940 !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: *14390140
24
+ version_requirements: *13313940
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: multi_json
27
- requirement: &14389660 !ruby/object:Gem::Requirement
27
+ requirement: &13313400 !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: *14389660
35
+ version_requirements: *13313400
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rash
38
- requirement: &14389180 !ruby/object:Gem::Requirement
38
+ requirement: &13312880 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.3.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *14389180
46
+ version_requirements: *13312880
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: money
49
- requirement: &14388700 !ruby/object:Gem::Requirement
49
+ requirement: &13312280 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 3.6.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *14388700
57
+ version_requirements: *13312280
58
58
  description: ! ' This library is meant to interface with PayPal''s Adaptive Payment
59
59
  Gateway.
60
60
 
@@ -66,6 +66,7 @@ extensions: []
66
66
  extra_rdoc_files: []
67
67
  files:
68
68
  - lib/active_paypal_adaptive_payment.rb
69
+ - lib/active_merchant/billing/gateways/paypal_adaptive_payment_common.rb
69
70
  - lib/active_merchant/billing/gateways/paypal_adaptive_payments/exceptions.rb
70
71
  - lib/active_merchant/billing/gateways/paypal_adaptive_payments/adaptive_payment_response.rb
71
72
  - lib/active_merchant/billing/gateways/paypal_adaptive_payments/ext.rb
@@ -93,9 +94,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
94
  version: 1.3.6
94
95
  requirements: []
95
96
  rubyforge_project:
96
- rubygems_version: 1.8.7
97
+ rubygems_version: 1.8.8
97
98
  signing_key:
98
99
  specification_version: 3
99
100
  summary: ActiveMercant PayPal Adaptive Payment Library
100
101
  test_files: []
101
- has_rdoc: