paypal 1.9.0 → 2.0.0

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/README CHANGED
@@ -95,6 +95,9 @@ uninitalized constant Paypal - Make sure your ruby has openssl support
95
95
 
96
96
  == Changelog
97
97
 
98
+ 2006-04-20 -- 2.0.0
99
+ * Uses paypal extended syntax. The plugin can now submit shipping and billing addresses using the paypal_address helper.
100
+
98
101
  2006-04-20 -- 1.7.0
99
102
  * Now a rails plugin
100
103
 
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/rdoctask'
5
5
  require 'rake/gempackagetask'
6
6
  require 'rake/contrib/rubyforgepublisher'
7
7
 
8
- PKG_VERSION = "1.9.0"
8
+ PKG_VERSION = "2.0.0"
9
9
  PKG_NAME = "paypal"
10
10
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
11
11
 
@@ -80,7 +80,8 @@ module Paypal
80
80
  raise ArgumentError, "Unknown option #{misses.inspect}" if not misses.empty?
81
81
 
82
82
  params = {
83
- :cmd => "_xclick",
83
+ :cmd => "_ext-enter",
84
+ :redirect_cmd => "_xclick",
84
85
  :quantity => 1,
85
86
  :business => business,
86
87
  :item_number => item_number,
@@ -145,6 +146,27 @@ module Paypal
145
146
  end.join("\n")
146
147
  end
147
148
 
149
+
150
+ # Pass an address to paypal so that all singup forms can be prefilled
151
+ #
152
+ # * <tt>email</tt> -- Customer's email address
153
+ # * <tt>first_name</tt> -- Customer's first name. Must be alpha-numeric, with a 32 character limit
154
+ # * <tt>last_name</tt> -- Customer's last name. Must be alpha-numeric, with a 64 character limit
155
+ # * <tt>address1</tt> -- First line of customer's address. Must be alpha-numeric, with a 100 character limit
156
+ # * <tt>address2</tt> -- Second line of customer's address. Must be alpha-numeric, with a 100 character limit
157
+ # * <tt>city</tt> -- City of customer's address. Must be alpha-numeric, with a 100 character limit
158
+ # * <tt>state</tt> -- State of customer's address. Must be official 2 letter abbreviation
159
+ # * <tt>zip</tt> -- Zip code of customer's address
160
+ # * <tt>night_phone_a</tt> -- Area code of customer's night telephone number
161
+ # * <tt>night_phone_b</tt> -- First three digits of customer's night telephone number
162
+ # * <tt>day_phone_a</tt> -- Area code of customer's daytime telephone number
163
+ # * <tt>day_phone_b</tt> -- First three digits of customer's daytime telephon
164
+ def paypal_address(options = {})
165
+ options.collect do |key, value|
166
+ tag(:input, :type => 'hidden', :name => key, :value => value)
167
+ end.join("\n")
168
+ end
169
+
148
170
  private
149
171
 
150
172
  # See https://www.paypal.com/IntegrationCenter/ic_std-variable-reference.html for details on the following options.
@@ -147,20 +147,27 @@ jZJTylbJQ1b5PBBjGiP0PpK48cdF
147
147
  # This is the invocie which you passed to paypal
148
148
  def invoice
149
149
  params['invoice']
150
+ end
151
+
152
+ # This is the invocie which you passed to paypal
153
+ def test?
154
+ params['test_ipn'] == '1'
150
155
  end
151
156
 
152
157
  # This is the custom field which you passed to paypal
153
158
  def invoice
154
- params['invoice']
159
+ params['custom']
160
+ end
161
+
162
+ def gross_cents
163
+ (gross.to_f * 100.0).round
155
164
  end
156
165
 
157
166
  # This combines the gross and currency and returns a proper Money object.
158
167
  # this requires the money library located at http://dist.leetsoft.com/api/money
159
168
  def amount
160
- require 'money'
161
- amount = gross.sub(/[^\d]/, '').to_i
162
- return Money.new(amount, currency) rescue ArgumentError
163
- return Money.new(amount) # maybe you have an own money object which doesn't take a currency?
169
+ return Money.new(gross_cents, currency) rescue ArgumentError
170
+ return Money.new(gross_cents) # maybe you have an own money object which doesn't take a currency?
164
171
  end
165
172
 
166
173
  # reset the notification.
@@ -51,12 +51,13 @@ class HelperTest < Test::Unit::TestCase
51
51
  assert_inputs({ "amount" => "500.00",
52
52
  "business" => "bob@bigbusiness.com",
53
53
  "charset" => "utf-8",
54
- "cmd" => "_xclick",
54
+ "cmd" => "_ext-enter",
55
55
  "currency_code" => "USD",
56
56
  "item_name" => "Store purchase",
57
57
  "item_number" => "100",
58
58
  "no_note" => "1",
59
59
  "no_shipping" => "1",
60
+ "redirect_cmd" => "_xclick",
60
61
  "quantity" => "1"}, actual)
61
62
  end
62
63
 
@@ -65,13 +66,14 @@ class HelperTest < Test::Unit::TestCase
65
66
  assert_inputs({ "amount" => "500.00",
66
67
  "business" => "bob@bigbusiness.com",
67
68
  "charset" => "utf-8",
68
- "cmd" => "_xclick",
69
+ "cmd" => "_ext-enter",
69
70
  "currency_code" => "USD",
70
71
  "item_name" => "Store purchase",
71
72
  "item_number" => "100",
72
73
  "no_note" => "1",
73
74
  "no_shipping" => "1",
74
75
  "quantity" => "1",
76
+ "redirect_cmd" => "_xclick",
75
77
  "tax" => "5.00"}, actual)
76
78
  end
77
79
 
@@ -80,13 +82,14 @@ class HelperTest < Test::Unit::TestCase
80
82
  assert_inputs({ "amount" => "500.00",
81
83
  "business" => "bob@bigbusiness.com",
82
84
  "charset" => "utf-8",
83
- "cmd" => "_xclick",
85
+ "cmd" => "_ext-enter",
84
86
  "currency_code" => "USD",
85
87
  "invoice" => "Cool invoice!",
86
88
  "item_name" => "Store purchase",
87
89
  "item_number" => "100",
88
90
  "no_note" => "1",
89
91
  "no_shipping" => "1",
92
+ "redirect_cmd" => "_xclick",
90
93
  "quantity" => "1"}, actual)
91
94
  end
92
95
 
@@ -95,14 +98,16 @@ class HelperTest < Test::Unit::TestCase
95
98
  assert_inputs({ "amount" => "500.00",
96
99
  "business" => "bob@bigbusiness.com",
97
100
  "charset" => "utf-8",
98
- "cmd" => "_xclick",
101
+ "cmd" => "_ext-enter",
99
102
  "currency_code" => "USD",
100
103
  "custom" => "Custom",
101
104
  "item_name" => "Store purchase",
102
105
  "item_number" => "100",
103
106
  "no_note" => "1",
104
107
  "no_shipping" => "1",
105
- "quantity" => "1"}, actual)
108
+ "quantity" => "1",
109
+ "redirect_cmd" => "_xclick",
110
+ }, actual)
106
111
  end
107
112
 
108
113
  def test_paypal_setup_with_float
@@ -110,12 +115,13 @@ class HelperTest < Test::Unit::TestCase
110
115
  assert_inputs({ "amount" => "50.00",
111
116
  "business" => "bob@bigbusiness.com",
112
117
  "charset" => "utf-8",
113
- "cmd" => "_xclick",
118
+ "cmd" => "_ext-enter",
114
119
  "currency_code" => "CAD",
115
120
  "item_name" => "Store purchase",
116
121
  "item_number" => "100",
117
122
  "no_note" => "1",
118
123
  "no_shipping" => "1",
124
+ "redirect_cmd" => "_xclick",
119
125
  "quantity" => "1"}, actual)
120
126
  end
121
127
 
@@ -124,12 +130,13 @@ class HelperTest < Test::Unit::TestCase
124
130
  assert_inputs({ "amount" => "50.00",
125
131
  "business" => "bob@bigbusiness.com",
126
132
  "charset" => "utf-8",
127
- "cmd" => "_xclick",
133
+ "cmd" => "_ext-enter",
128
134
  "currency_code" => "CAD",
129
135
  "item_name" => "Store purchase",
130
136
  "item_number" => "100",
131
137
  "no_note" => "1",
132
138
  "no_shipping" => "1",
139
+ "redirect_cmd" => "_xclick",
133
140
  "quantity" => "1"}, actual)
134
141
  end
135
142
 
@@ -139,7 +146,7 @@ class HelperTest < Test::Unit::TestCase
139
146
  "business" => "bob@bigbusiness.com",
140
147
  "cancel_return" => "http://www.bigbusiness.com",
141
148
  "charset" => "utf-8",
142
- "cmd" => "_xclick",
149
+ "cmd" => "_ext-enter",
143
150
  "currency_code" => "USD",
144
151
  "item_name" => "MegaBob's shop purchase",
145
152
  "item_number" => "100",
@@ -147,6 +154,7 @@ class HelperTest < Test::Unit::TestCase
147
154
  "no_shipping" => "0",
148
155
  "notify_url" => "http://www.bigbusiness.com",
149
156
  "quantity" => "1",
157
+ "redirect_cmd" => "_xclick",
150
158
  "return" => "http://www.bigbusiness.com"}, actual )
151
159
  end
152
160
 
@@ -0,0 +1,47 @@
1
+ module Net
2
+ remove_const "HTTP"
3
+
4
+ class Response
5
+ def initialize(result)
6
+ @result = result
7
+ end
8
+
9
+ def body
10
+ @result
11
+ end
12
+ end
13
+
14
+ class Request < Struct.new(:host, :port, :query, :post_data)
15
+
16
+ cattr_accessor :fail
17
+ @@fail = false
18
+
19
+ def post(query, post)
20
+ self.query = query
21
+ self.post_data = post
22
+ Response.new(self.class.fail ? "INVALID": "VERIFIED")
23
+ end
24
+
25
+ end
26
+
27
+ class Net::HTTP
28
+
29
+
30
+ def self.start(host, port)
31
+ request = Request.new
32
+ request.host = host
33
+ request.port = port
34
+
35
+ @packages ||= []
36
+ @packages << request
37
+
38
+ yield request
39
+ end
40
+
41
+ def self.packages
42
+ @packages
43
+ end
44
+
45
+ end
46
+ end
47
+
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
2
+ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: paypal
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.9.0
7
- date: 2006-04-29 00:00:00 -04:00
6
+ version: 2.0.0
7
+ date: 2006-06-30 00:00:00 -04:00
8
8
  summary: Paypal IPN integration library for rails and other web applications
9
9
  require_paths:
10
10
  - lib
@@ -25,6 +25,7 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
25
25
  platform: ruby
26
26
  signing_key:
27
27
  cert_chain:
28
+ post_install_message:
28
29
  authors:
29
30
  - Tobias Luetke
30
31
  files:
@@ -41,6 +42,7 @@ files:
41
42
  - test/mocks
42
43
  - test/notification_test.rb
43
44
  - test/remote
45
+ - test/mocks/http_mock.rb
44
46
  - test/mocks/method_mock.rb
45
47
  - test/remote/remote_test.rb
46
48
  test_files: []