paypal-express 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -15,6 +15,7 @@ https://github.com/nov/paypal-express/wiki
15
15
 
16
16
  Play with Sample Rails App
17
17
  https://github.com/nov/paypal-express-sample
18
+ https://paypal-express-sample.heroku.com
18
19
 
19
20
  == Note on Patches/Pull Requests
20
21
 
@@ -28,4 +29,4 @@ https://github.com/nov/paypal-express-sample
28
29
 
29
30
  == Copyright
30
31
 
31
- Copyright (c) 2011 nov matake. See LICENSE for details.
32
+ Copyright (c) 2011 nov matake. See LICENSE for details.
data/Rakefile CHANGED
@@ -9,12 +9,4 @@ RSpec::Core::RakeTask.new(:rcov) do |spec|
9
9
  spec.rcov_opts = ['-Ilib -Ispec --exclude spec,gems']
10
10
  end
11
11
 
12
- task :default => :spec
13
-
14
- require 'rake/rdoctask'
15
- Rake::RDocTask.new do |rdoc|
16
- rdoc.rdoc_dir = 'rdoc'
17
- rdoc.title = "paypal-express #{File.read('VERSION')}"
18
- rdoc.rdoc_files.include('README*')
19
- rdoc.rdoc_files.include('lib/**/*.rb')
20
- end
12
+ task :default => :spec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -63,6 +63,18 @@ module Paypal
63
63
  response = self.request :ManageRecurringPaymentsProfileStatus, params
64
64
  Response.new response
65
65
  end
66
+
67
+ def suspend!(profile_id, options = {})
68
+ renew!(profile_id, :Suspend, options)
69
+ end
70
+
71
+ def cancel!(profile_id, options = {})
72
+ renew!(profile_id, :Cancel, options)
73
+ end
74
+
75
+ def reactivate!(profile_id, options = {})
76
+ renew!(profile_id, :Reactivate, options)
77
+ end
66
78
 
67
79
  def refund!(transaction_id, options = {})
68
80
  params = {
@@ -86,4 +98,4 @@ module Paypal
86
98
 
87
99
  end
88
100
  end
89
- end
101
+ end
@@ -15,7 +15,8 @@ module Paypal
15
15
  :NOTIFYURL => :notify_url,
16
16
  :TIMESTAMP => :timestamp,
17
17
  :TOKEN => :token,
18
- :VERSION => :version
18
+ :VERSION => :version,
19
+ :BILLINGAGREEMENTID => :billing_agreement_id
19
20
  }
20
21
  attr_accessor *@@attribute_mapping.values
21
22
  attr_accessor :shipping_options_is_default, :success_page_redirect_requested, :insurance_option_selected
@@ -1,7 +1,7 @@
1
1
  module Paypal
2
2
  module Payment
3
3
  class Request < Base
4
- attr_optional :action, :currency_code, :description, :notify_url, :billing_type, :billing_agreement_description
4
+ attr_optional :action, :currency_code, :description, :notify_url, :billing_type, :billing_agreement_description, :reference_transactions_billing_type, :billing_agreement_id
5
5
  attr_accessor :amount, :items
6
6
 
7
7
  def initialize(attributes = {})
@@ -34,7 +34,8 @@ module Paypal
34
34
  # recurring payment doesn't support dynamic notify_url.
35
35
  :"PAYMENTREQUEST_#{index}_NOTIFYURL" => self.notify_url,
36
36
  :"L_BILLINGTYPE#{index}" => self.billing_type,
37
- :"L_BILLINGAGREEMENTDESCRIPTION#{index}" => self.billing_agreement_description
37
+ :"L_BILLINGAGREEMENTDESCRIPTION#{index}" => self.billing_agreement_description,
38
+ :"BILLINGTYPE" => self.reference_transactions_billing_type
38
39
  }.delete_if do |k, v|
39
40
  v.blank?
40
41
  end
@@ -1,7 +1,7 @@
1
1
  module Paypal
2
2
  module Payment
3
3
  class Response < Base
4
- attr_accessor :amount, :ship_to, :description, :note, :items, :notify_url, :insurance_option_offered, :currency_code, :error_code, :transaction_id
4
+ attr_accessor :amount, :ship_to, :description, :note, :items, :notify_url, :insurance_option_offered, :currency_code, :error_code, :transaction_id, :billing_agreement_id
5
5
 
6
6
  def initialize(attributes = {})
7
7
  attrs = attributes.dup
@@ -31,6 +31,7 @@ module Paypal
31
31
  @currency_code = attrs.delete(:CURRENCYCODE)
32
32
  @error_code = attrs.delete(:ERRORCODE)
33
33
  @transaction_id = attrs.delete(:TRANSACTIONID)
34
+ @billing_agreement_id = attrs.delete(:BILLINGAGREEMENTID)
34
35
 
35
36
  # items
36
37
  items = []
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.add_dependency "i18n"
18
18
  s.add_dependency "restclient_with_cert"
19
19
  s.add_dependency "attr_required", ">= 0.0.3"
20
- s.add_development_dependency "rake", ">= 0.8", "< 0.9"
20
+ s.add_development_dependency "rake", ">= 0.8"
21
21
  s.add_development_dependency "rcov", ">= 0.9"
22
22
  s.add_development_dependency "rspec", ">= 2"
23
23
  s.add_development_dependency "fakeweb", ">= 1.3.0"
@@ -1 +1 @@
1
- TOKEN=EC-9E2743126S4330617&SUCCESSPAGEREDIRECTREQUESTED=false&TIMESTAMP=2011-02-08T03:23:55Z&CORRELATIONID=15b93874c358c&ACK=Success&VERSION=66.0&BUILD=1721431&INSURANCEOPTIONSELECTED=false&SHIPPINGOPTIONISDEFAULT=false&PAYMENTINFO_0_TRANSACTIONID=8NC65222871997739&PAYMENTINFO_0_TRANSACTIONTYPE=expresscheckout&PAYMENTINFO_0_PAYMENTTYPE=instant&PAYMENTINFO_0_ORDERTIME=2011-02-08T03:23:54Z&PAYMENTINFO_0_AMT=14.00&PAYMENTINFO_0_FEEAMT=0.85&PAYMENTINFO_0_TAXAMT=0.00&PAYMENTINFO_0_CURRENCYCODE=USD&PAYMENTINFO_0_PAYMENTSTATUS=Completed&PAYMENTINFO_0_PENDINGREASON=None&PAYMENTINFO_0_REASONCODE=None&PAYMENTINFO_0_PROTECTIONELIGIBILITY=Ineligible&PAYMENTINFO_0_PROTECTIONELIGIBILITYTYPE=None&PAYMENTINFO_0_ERRORCODE=0&PAYMENTINFO_0_ACK=Success
1
+ TOKEN=EC-9E2743126S4330617&SUCCESSPAGEREDIRECTREQUESTED=false&TIMESTAMP=2011-02-08T03:23:55Z&CORRELATIONID=15b93874c358c&ACK=Success&VERSION=66.0&BUILD=1721431&INSURANCEOPTIONSELECTED=false&SHIPPINGOPTIONISDEFAULT=false&PAYMENTINFO_0_TRANSACTIONID=8NC65222871997739&PAYMENTINFO_0_TRANSACTIONTYPE=expresscheckout&PAYMENTINFO_0_PAYMENTTYPE=instant&PAYMENTINFO_0_ORDERTIME=2011-02-08T03:23:54Z&PAYMENTINFO_0_AMT=14.00&PAYMENTINFO_0_FEEAMT=0.85&PAYMENTINFO_0_TAXAMT=0.00&PAYMENTINFO_0_CURRENCYCODE=USD&PAYMENTINFO_0_PAYMENTSTATUS=Completed&PAYMENTINFO_0_PENDINGREASON=None&PAYMENTINFO_0_REASONCODE=None&PAYMENTINFO_0_PROTECTIONELIGIBILITY=Ineligible&PAYMENTINFO_0_PROTECTIONELIGIBILITYTYPE=None&PAYMENTINFO_0_ERRORCODE=0&BILLINGAGREEMENTID=B-1XR87946TC504770W&PAYMENTINFO_0_ACK=Success
@@ -243,6 +243,63 @@ describe Paypal::Express::Request do
243
243
  end
244
244
  end
245
245
 
246
+ describe '#cancel!' do
247
+ it 'should return Paypal::Express::Response' do
248
+ fake_response 'ManageRecurringPaymentsProfileStatus/success'
249
+ response = instance.cancel! 'profile_id'
250
+ response.should be_instance_of(Paypal::Express::Response)
251
+ end
252
+
253
+ it 'should call ManageRecurringPaymentsProfileStatus' do
254
+ expect do
255
+ instance.cancel! 'profile_id'
256
+ end.should request_to nvp_endpoint, :post
257
+ instance._method_.should == :ManageRecurringPaymentsProfileStatus
258
+ instance._sent_params_.should == {
259
+ :ACTION => :Cancel,
260
+ :PROFILEID => 'profile_id'
261
+ }
262
+ end
263
+ end
264
+
265
+ describe '#suspend!' do
266
+ it 'should return Paypal::Express::Response' do
267
+ fake_response 'ManageRecurringPaymentsProfileStatus/success'
268
+ response = instance.cancel! 'profile_id'
269
+ response.should be_instance_of(Paypal::Express::Response)
270
+ end
271
+
272
+ it 'should call ManageRecurringPaymentsProfileStatus' do
273
+ expect do
274
+ instance.suspend! 'profile_id'
275
+ end.should request_to nvp_endpoint, :post
276
+ instance._method_.should == :ManageRecurringPaymentsProfileStatus
277
+ instance._sent_params_.should == {
278
+ :ACTION => :Suspend,
279
+ :PROFILEID => 'profile_id'
280
+ }
281
+ end
282
+ end
283
+
284
+ describe '#reactivate!' do
285
+ it 'should return Paypal::Express::Response' do
286
+ fake_response 'ManageRecurringPaymentsProfileStatus/success'
287
+ response = instance.cancel! 'profile_id'
288
+ response.should be_instance_of(Paypal::Express::Response)
289
+ end
290
+
291
+ it 'should call ManageRecurringPaymentsProfileStatus' do
292
+ expect do
293
+ instance.reactivate! 'profile_id'
294
+ end.should request_to nvp_endpoint, :post
295
+ instance._method_.should == :ManageRecurringPaymentsProfileStatus
296
+ instance._sent_params_.should == {
297
+ :ACTION => :Reactivate,
298
+ :PROFILEID => 'profile_id'
299
+ }
300
+ end
301
+ end
302
+
246
303
  describe '#refund!' do
247
304
  it 'should return Paypal::Express::Response' do
248
305
  fake_response 'RefundTransaction/full'
@@ -262,4 +319,4 @@ describe Paypal::Express::Request do
262
319
  end
263
320
  end
264
321
 
265
- end
322
+ end
@@ -79,6 +79,7 @@ describe Paypal::NVP::Response do
79
79
  response = request.checkout! 'token', 'payer_id', payment_request
80
80
  response.payment_responses.size.should == 0
81
81
  response.payment_info.size.should == 1
82
+ response.billing_agreement_id.should == 'B-1XR87946TC504770W'
82
83
  response.payment_info.first.should be_instance_of(Paypal::Payment::Response::Info)
83
84
  end
84
85
  end
@@ -31,6 +31,15 @@ describe Paypal::Payment::Request do
31
31
  )
32
32
  end
33
33
 
34
+ let :recurring_request_with_reference_transaction do
35
+ Paypal::Payment::Request.new(
36
+ :currency_code => :JPY,
37
+ :billing_type => :RecurringPayments,
38
+ :billing_agreement_description => 'Recurring Payment Request',
39
+ :reference_transactions_billing_type => :MerchantInitiatedBillingSingleAgreement
40
+ )
41
+ end
42
+
34
43
  describe '.new' do
35
44
  it 'should handle Instant Payment parameters' do
36
45
  instant_request.amount.total.should == 25.7
@@ -46,6 +55,12 @@ describe Paypal::Payment::Request do
46
55
  recurring_request.billing_type.should == :RecurringPayments
47
56
  recurring_request.billing_agreement_description.should == 'Recurring Payment Request'
48
57
  end
58
+
59
+ it 'should handle Recurring Payment parameters' do
60
+ recurring_request_with_reference_transaction.currency_code.should == :JPY
61
+ recurring_request_with_reference_transaction.billing_type.should == :RecurringPayments
62
+ recurring_request_with_reference_transaction.billing_agreement_description.should == 'Recurring Payment Request'
63
+ end
49
64
  end
50
65
 
51
66
  describe '#to_params' do
@@ -79,5 +94,17 @@ describe Paypal::Payment::Request do
79
94
  :L_BILLINGAGREEMENTDESCRIPTION0 => "Recurring Payment Request"
80
95
  }
81
96
  end
97
+
98
+ it 'should handle Recurring Payment with Reference Transactions parameters' do
99
+ recurring_request_with_reference_transaction.to_params.should == {
100
+ :PAYMENTREQUEST_0_AMT => "0.00",
101
+ :PAYMENTREQUEST_0_TAXAMT => "0.00",
102
+ :PAYMENTREQUEST_0_SHIPPINGAMT => "0.00",
103
+ :PAYMENTREQUEST_0_CURRENCYCODE => :JPY,
104
+ :L_BILLINGTYPE0 => :RecurringPayments,
105
+ :L_BILLINGAGREEMENTDESCRIPTION0 => "Recurring Payment Request",
106
+ :BILLINGTYPE => :MerchantInitiatedBillingSingleAgreement,
107
+ }
108
+ end
82
109
  end
83
110
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paypal-express
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - nov matake
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-23 00:00:00 Z
18
+ date: 2011-06-27 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activesupport
@@ -89,13 +89,6 @@ dependencies:
89
89
  - 0
90
90
  - 8
91
91
  version: "0.8"
92
- - - <
93
- - !ruby/object:Gem::Version
94
- hash: 25
95
- segments:
96
- - 0
97
- - 9
98
- version: "0.9"
99
92
  type: :development
100
93
  version_requirements: *id005
101
94
  - !ruby/object:Gem::Dependency