active_paypal_adaptive_payment 0.3.2 → 0.3.3

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.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## 0 0.3.3 (16/Nov/11)
2
+
3
+ - add functionality to allow a user to redirect to the correct URL
4
+ when creating a pre-approval request. In addition, the
5
+ setup_purchase now allows for the preapproval_key to be submitted
6
+ and passed along to paypal. (LeviRosol (<https://github.com/LeviRosol>))
7
+
8
+ ## 0.3.2
9
+
10
+ - build_adaptive_payment_details_request pay_key fix.
11
+
12
+ ## 0.3.1
13
+
14
+ - Add Support of ExecutePayment.
15
+
1
16
  ## 0.3.0
2
17
 
3
18
  - IPN implemeted
data/README.md CHANGED
@@ -104,6 +104,8 @@ xml request, raw json response and the URL of the endpoint.
104
104
  * Jose Pablo Barrantes (<http://jpablobr.com/>)
105
105
  * Zarne Dravitzki (<http://github.com/zarno>)
106
106
  * LeviRosol (<https://github.com/LeviRosol>)
107
+ * Florian95 (<https://github.com/Florian95>)
108
+ * akichatov (<https://github.com/akichatov>)
107
109
 
108
110
  ## Other previous contributors where some code was taken from.
109
111
 
@@ -28,6 +28,7 @@ module ActiveMerchant #:nodoc:
28
28
  end
29
29
 
30
30
  self.test_redirect_url= "https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey="
31
+ self.test_redirect_pre_approval_url= "https://www.sandbox.paypal.com/webscr?cmd=_ap-preapproval&preapprovalkey="
31
32
  self.supported_countries = ['US']
32
33
  self.homepage_url = 'http://x.com/'
33
34
  self.display_name = 'Paypal Adaptive Payments'
@@ -54,19 +55,6 @@ module ActiveMerchant #:nodoc:
54
55
  commit('ExecutePayment', build_adaptive_execute_payment_request(options))
55
56
  end
56
57
 
57
- # Send a preapproval request to pay pal
58
- #
59
- # ==== Options
60
- #
61
- # * +:end_date+ - _xs:datetime_ The ending date
62
- # * +:start_date+ - _xs:datetime_ The start date (defaults: current)
63
- # * +:max_amount+ - _xs:decimal_ The preapproved maximum total amount of all payments.
64
- # * +:currency_code+ - The currency code (defaults: USD)
65
- # * +:cancel_url+ - URL to redirect the sender’s browser to after canceling the preapproval
66
- # * +:return_url+ - URL to redirect the sender’s browser to after the sender has logged into PayPal and confirmed the preapproval
67
- # * +:notify_url+ - The URL to which you want all IPN messages for this preapproval to be sent. (Optional)
68
- #
69
- # To get more details on fields see +Paypal PreApproval API+ at https://www.x.com/docs/DOC-1419
70
58
  def preapprove_payment(options)
71
59
  commit('Preapproval', build_preapproval_payment(options))
72
60
  end
@@ -87,7 +75,6 @@ module ActiveMerchant #:nodoc:
87
75
  test? ? EMBEDDED_FLOW_TEST_URL : EMBEDDED_FLOW_LIVE_URL
88
76
  end
89
77
 
90
- #debug method, provides an easy to use debug method for the class
91
78
  def debug
92
79
  "Url: #{@url}\n\n Request: #{@xml} \n\n Response: #{@response.json}"
93
80
  end
@@ -104,10 +91,12 @@ module ActiveMerchant #:nodoc:
104
91
  x.errorLanguage opts[:error_language] ||= 'en_US'
105
92
  end
106
93
  x.actionType 'PAY'
94
+ x.preapprovalKey opts[:preapproval_key] if opts.key?(:preapproval_key)
107
95
  x.senderEmail opts[:sender_email] if opts.key?(:sender_email)
108
96
  x.cancelUrl opts[:cancel_url]
109
97
  x.returnUrl opts[:return_url]
110
- x.ipnNotificationUrl opts[:ipn_notification_url] if opts[:ipn_notification_url]
98
+ x.ipnNotificationUrl opts[:ipn_notification_url] if
99
+ opts[:ipn_notification_url]
111
100
  x.memo opts[:memo] if opts.key?(:memo)
112
101
  x.custom opts[:custom] if opts.key?(:custom)
113
102
  x.feesPayer opts[:fees_payer] if opts[:fees_payer]
@@ -119,12 +108,15 @@ module ActiveMerchant #:nodoc:
119
108
  x.email receiver[:email]
120
109
  x.amount receiver[:amount].to_s
121
110
  x.primary receiver[:primary] if receiver.key?(:primary)
122
- x.paymentType receiver[:payment_type] if receiver.key?(:payment_type)
123
- x.invoiceId receiver[:invoice_id] if receiver.key?(:invoice_id)
111
+ x.paymentType receiver[:payment_type] if
112
+ receiver.key?(:payment_type)
113
+ x.invoiceId receiver[:invoice_id] if
114
+ receiver.key?(:invoice_id)
124
115
  end
125
116
  end
126
117
  end
127
- x.reverseAllParallelPaymentsOnError opts[:reverse_all_parallel_payments_on_error] || 'false'
118
+ x.reverseAllParallelPaymentsOnError(
119
+ opts[:reverse_all_parallel_payments_on_error] || 'false')
128
120
  x.trackingId opts[:tracking_id] if opts[:tracking_id]
129
121
  end
130
122
  end
@@ -206,20 +198,24 @@ module ActiveMerchant #:nodoc:
206
198
  x.requestEnvelope do |x|
207
199
  x.detailLevel 'ReturnAll'
208
200
  x.errorLanguage opts[:error_language] ||= 'en_US'
209
- x.senderEmail opts[:senderEmail]
201
+ x.senderEmail opts[:senderEmail] if opts.has_key?(:senderEmail)
210
202
  end
211
203
 
212
204
  # required preapproval fields
213
205
  x.endingDate opts[:end_date].strftime("%Y-%m-%dT%H:%M:%S")
214
206
  x.startingDate opts[:start_date].strftime("%Y-%m-%dT%H:%M:%S")
215
207
  x.maxTotalAmountOfAllPayments opts[:max_amount]
216
- x.maxNumberOfPayments opts[:maxNumberOfPayments] if opts.has_key?(:maxNumberOfPayments)
208
+ x.maxAmountPerPayment opts[:maxAmountPerPayment] if opts.has_key?(:maxAmountPerPayment)
209
+ x.memo opts[:memo] if opts.has_key?(:memo)
210
+ x.maxNumberOfPayments opts[:maxNumberOfPayments] if
211
+ opts.has_key?(:maxNumberOfPayments)
217
212
  x.currencyCode options[:currency_code]
218
213
  x.cancelUrl opts[:cancel_url]
219
214
  x.returnUrl opts[:return_url]
220
215
 
221
216
  # notify url
222
- x.ipnNotificationUrl opts[:notify_url] if opts.has_key?(:notify_url)
217
+ x.ipnNotificationUrl opts[:notify_url] if
218
+ opts.has_key?(:notify_url)
223
219
  end
224
220
  end
225
221
 
@@ -233,7 +229,8 @@ module ActiveMerchant #:nodoc:
233
229
  x.errorLanguage options[:error_language] ||= 'en_US'
234
230
  end
235
231
  x.preapprovalKey options[:preapproval_key]
236
- x.getBillingAddress options[:get_billing_address] if options[:get_billing_address]
232
+ x.getBillingAddress options[:get_billing_address] if
233
+ options[:get_billing_address]
237
234
  end
238
235
  end
239
236
 
@@ -303,7 +300,7 @@ module ActiveMerchant #:nodoc:
303
300
  end
304
301
 
305
302
  def test?
306
- Base.gateway_mode == :test
303
+ @config[:test] || Base.gateway_mode == :test
307
304
  end
308
305
 
309
306
  def action_url(action)
@@ -4,7 +4,10 @@ module ActiveMerchant
4
4
  def self.included(base)
5
5
  base.cattr_accessor :test_redirect_url
6
6
  base.cattr_accessor :live_redirect_url
7
+ base.cattr_accessor :test_redirect_pre_approval_url
8
+ base.cattr_accessor :live_redirect_pre_approval_url
7
9
  base.live_redirect_url = 'https://www.paypal.com/webscr?cmd=_ap-payment&paykey='
10
+ base.live_redirect_pre_approval_url = 'https://www.paypal.com/webscr?cmd=_ap-preapproval&preapprovalkey='
8
11
  end
9
12
 
10
13
  def redirect_url
@@ -14,6 +17,15 @@ module ActiveMerchant
14
17
  def redirect_url_for(token)
15
18
  redirect_url + token
16
19
  end
20
+
21
+ def redirect_pre_approval_url
22
+ test? ? test_redirect_pre_approval_url : live_redirect_pre_approval_url
23
+ end
24
+
25
+ def redirect_pre_approval_url_for(token)
26
+ redirect_pre_approval_url + token
27
+ end
28
+
17
29
  end
18
30
  end
19
31
  end
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.2
4
+ version: 0.3.3
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-10-21 00:00:00.000000000Z
12
+ date: 2011-11-16 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemerchant
16
- requirement: &6854140 !ruby/object:Gem::Requirement
16
+ requirement: &13666840 !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: *6854140
24
+ version_requirements: *13666840
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: multi_json
27
- requirement: &6852040 !ruby/object:Gem::Requirement
27
+ requirement: &13666260 !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: *6852040
35
+ version_requirements: *13666260
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rash
38
- requirement: &6850760 !ruby/object:Gem::Requirement
38
+ requirement: &13665520 !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: *6850760
46
+ version_requirements: *13665520
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: money
49
- requirement: &6847440 !ruby/object:Gem::Requirement
49
+ requirement: &13664660 !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: *6847440
57
+ version_requirements: *13664660
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: mocha
60
- requirement: &6843600 !ruby/object:Gem::Requirement
60
+ requirement: &13663900 !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: *6843600
68
+ version_requirements: *13663900
69
69
  description: ! ' This library is meant to interface with PayPal''s Adaptive Payment
70
70
  Gateway.
71
71
 
@@ -115,3 +115,4 @@ signing_key:
115
115
  specification_version: 3
116
116
  summary: ActiveMercant PayPal Adaptive Payment Library
117
117
  test_files: []
118
+ has_rdoc: