paypal-recurring 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  .DS_Store
2
2
  pkg
3
3
  tmp
4
+ examples
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paypal-recurring (0.1.2)
4
+ paypal-recurring (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -13,6 +13,18 @@ module PayPal
13
13
  end
14
14
  end
15
15
 
16
+ def type
17
+ params[:txn_type]
18
+ end
19
+
20
+ def express_checkout?
21
+ type == "express_checkout"
22
+ end
23
+
24
+ def recurring_payment?
25
+ type == "recurring_payment"
26
+ end
27
+
16
28
  def request
17
29
  @request ||= PayPal::Recurring::Request.new.tap do |request|
18
30
  request.uri = URI.parse("#{PayPal::Recurring.site_endpoint}?cmd=_notify-validate")
@@ -24,7 +36,7 @@ module PayPal
24
36
  end
25
37
 
26
38
  def valid?
27
- completed? && verified? && params[:receiver_email] == PayPal::Recurring.email && params[:receiver_id] == PayPal::Recurring.seller_id && params[:txn_type] == "recurring_payment"
39
+ completed? && verified? && params[:receiver_email] == PayPal::Recurring.email && params[:receiver_id] == PayPal::Recurring.seller_id
28
40
  end
29
41
 
30
42
  def completed?
@@ -53,7 +53,7 @@ module PayPal
53
53
  :payment_action => "PAYMENTREQUEST_0_PAYMENTACTION",
54
54
  :period => "BILLINGPERIOD",
55
55
  :profile_id => "PROFILEID",
56
- :reference => "PROFILEREFERENCE",
56
+ :reference => ["PROFILEREFERENCE", "PAYMENTREQUEST_0_CUSTOM", "PAYMENTREQUEST_0_INVNUM"],
57
57
  :return_url => "RETURNURL",
58
58
  :signature => "SIGNATURE",
59
59
  :start_at => "PROFILESTARTDATE",
@@ -3,7 +3,7 @@ module PayPal
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 1
6
- PATCH = 2
6
+ PATCH = 3
7
7
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
8
8
  end
9
9
  end
@@ -1,6 +1,16 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe PayPal::Recurring::Notification do
4
+ it "detects express checkout" do
5
+ subject.params[:txn_type] = "express_checkout"
6
+ subject.should be_express_checkout
7
+ end
8
+
9
+ it "detects recurring payment" do
10
+ subject.params[:txn_type] = "recurring_payment"
11
+ subject.should be_recurring_payment
12
+ end
13
+
4
14
  context "when successful" do
5
15
  use_vcr_cassette "notification/success"
6
16
 
@@ -107,5 +107,9 @@ describe PayPal::Recurring::Request do
107
107
  subject.normalize_params(:initial_amount_action => :cancel).should == {:FAILEDINITAMTACTION => "CancelOnFailure"}
108
108
  subject.normalize_params(:initial_amount_action => :continue).should == {:FAILEDINITAMTACTION => "ContinueOnFailure"}
109
109
  end
110
+
111
+ it "normalizes reference" do
112
+ subject.normalize_params(:reference => "abc").should == {:PROFILEREFERENCE => "abc", :PAYMENTREQUEST_0_CUSTOM => "abc", :PAYMENTREQUEST_0_INVNUM => "abc"}
113
+ end
110
114
  end
111
115
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: paypal-recurring
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.2
5
+ version: 0.1.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Nando Vieira
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-01 00:00:00 Z
13
+ date: 2011-07-04 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -142,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
144
144
  - !ruby/object:Gem::Version
145
- hash: 2223999469554791748
145
+ hash: 507875766264394818
146
146
  segments:
147
147
  - 0
148
148
  version: "0"
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  requirements:
152
152
  - - ">="
153
153
  - !ruby/object:Gem::Version
154
- hash: 2223999469554791748
154
+ hash: 507875766264394818
155
155
  segments:
156
156
  - 0
157
157
  version: "0"