paypal 0.9.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README +7 -0
  2. data/Rakefile +3 -3
  3. data/lib/helper.rb +22 -5
  4. data/lib/notification.rb +11 -1
  5. metadata +4 -4
data/README CHANGED
@@ -69,6 +69,13 @@ sandbox account to use while the application is running in development mode.
69
69
 
70
70
  == Changelog
71
71
 
72
+ 2005-07-26 -- 0.9.5
73
+ * Added tax to the helper parameters
74
+ * fixed bug when money class was used to pass in amount. Cents were always 00 (doh!)
75
+ * Added invoice and custom optional parameters
76
+ * Added charset = utf-8 to all paypal posts
77
+ * Wrongly used undefined_quanitity parameter in 0.9.1, this caused users to be prompted for the quanitity on the paypal checkout page... fixed
78
+
72
79
  2005-07-22 -- 0.9.1
73
80
  * support for cancel_url as well as notify_url. This means you can now set the IPN callback address from the paypal_setup method and
74
81
  you don't have to do that in the paypal admin interface!
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 = "0.9.0"
8
+ PKG_VERSION = "1.0.0"
9
9
  PKG_NAME = "paypal"
10
10
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
11
11
 
@@ -77,8 +77,8 @@ end
77
77
 
78
78
  spec = Gem::Specification.new do |s|
79
79
  s.name = PKG_NAME
80
- s.version = PKG_VERSION
81
- s.summary = "Paypal IPN integration for rails apps and similar"
80
+ s.version = PKG_VERSION
81
+ s.description = s.summary = "Paypal IPN integration library for rails and other web applications"
82
82
  s.has_rdoc = true
83
83
 
84
84
  s.files = %w(README Rakefile MIT-LICENSE) + Dir['lib/**/*'] + Dir['misc/*'] + Dir['tests/*']
data/lib/helper.rb CHANGED
@@ -16,8 +16,9 @@ module Paypal
16
16
  module Helpers
17
17
 
18
18
  # Convenience helper. Can replace <%= form_tag Paypal::Notification.ipn_url %>
19
- def paypal_form_tag
20
- form_tag(Paypal::Notification.ipn_url)
19
+ # takes optional url parameter, default is Paypal::Notification.ipn_url
20
+ def paypal_form_tag(url = Paypal::Notification.ipn_url)
21
+ form_tag(url)
21
22
  end
22
23
 
23
24
  # This helper creates the hidden form data which is needed for a paypal purchase.
@@ -46,6 +47,11 @@ module Paypal
46
47
  # the shipping address should be collected in our application, not by paypal.
47
48
  # * <tt>:no_note</tt> -- default is '1'
48
49
  # * <tt>:currency</tt> -- default is 'USD'
50
+ # * <tt>:tax</tt> -- the tax for the store purchase. Same format as the amount parameter but optional
51
+ # * <tt>:invoice</tt> -- Unique invoice number. User will never see this. optional
52
+ # * <tt>:custom</tt> -- Custom field. User will never see this. optional
53
+ # * <tt>:no_utf8</tt> -- if set to false this prevents the charset = utf-8 hidden field. (I don't know why you
54
+ # would want to disable this... )
49
55
  #
50
56
  # Examples:
51
57
  #
@@ -65,13 +71,20 @@ module Paypal
65
71
  }.merge(options)
66
72
 
67
73
  # We accept both, strings and money objects as amount
68
- amount = amount.cents / 100 if amount.respond_to?(:cents)
74
+ amount = amount.cents.to_f / 100.0 if amount.respond_to?(:cents)
69
75
  amount = sprintf("%.2f", amount)
70
-
76
+
77
+ # same for tax
78
+ tax = params[:tax]
79
+ if tax
80
+ tax = tax.cents.to_f / 100.0 if tax.respond_to?(:cents)
81
+ tax = sprintf("%.2f", tax)
82
+ end
83
+
71
84
  # Build the form
72
85
  returning button = [] do
73
86
  button << tag(:input, :type => 'hidden', :name => 'cmd', :value => "_xclick")
74
- button << tag(:input, :type => 'hidden', :name => 'undefined_quantity', :value => 1)
87
+ button << tag(:input, :type => 'hidden', :name => 'quantity', :value => 1)
75
88
  button << tag(:input, :type => 'hidden', :name => 'business', :value => business)
76
89
  button << tag(:input, :type => 'hidden', :name => 'amount', :value => amount)
77
90
  button << tag(:input, :type => 'hidden', :name => 'item_number', :value => item_number)
@@ -81,10 +94,14 @@ module Paypal
81
94
  button << tag(:input, :type => 'hidden', :name => 'return', :value => params[:return_url]) if params[:return_url]
82
95
  button << tag(:input, :type => 'hidden', :name => 'notify_url', :value => params[:notify_url]) if params[:notify_url]
83
96
  button << tag(:input, :type => 'hidden', :name => 'cancel_return', :value => params[:cancel_url]) if params[:cancel_url]
97
+ button << tag(:input, :type => 'hidden', :name => 'tax', :value => tax) if tax
98
+ button << tag(:input, :type => 'hidden', :name => 'invoice', :value => params[:invoice]) if params[:invoice]
99
+ button << tag(:input, :type => 'hidden', :name => 'custom', :value => params[:custom]) if params[:custom]
84
100
 
85
101
  # if amount was a object of type money or something compatible we will use its currency,
86
102
  # otherwise get the currency from the options. default is USD
87
103
  button << tag(:input, :type => 'hidden', :name => 'currency_code', :value => amount.respond_to?(:currency) ? amount.currency : params[:currency])
104
+ button << tag(:input, :type => 'hidden', :name => 'charset', :value => 'utf-8') unless params[:no_utf8]
88
105
  end.join("\n")
89
106
  end
90
107
 
data/lib/notification.rb CHANGED
@@ -69,7 +69,7 @@ module Paypal
69
69
  # sometimes it can happen that we get the notification much later.
70
70
  # One possible scenario is that our web application was down. In this case paypal tries several
71
71
  # times an hour to inform us about the notification
72
- def recieved_at
72
+ def received_at
73
73
  Time.parse params['payment_date']
74
74
  end
75
75
 
@@ -109,6 +109,16 @@ module Paypal
109
109
  params['item_number']
110
110
  end
111
111
 
112
+ # This is the invocie which you passed to paypal
113
+ def invoice
114
+ params['invoice']
115
+ end
116
+
117
+ # This is the custom field which you passed to paypal
118
+ def invoice
119
+ params['invoice']
120
+ end
121
+
112
122
  # This combines the gross and currency and returns a proper Money object.
113
123
  # this requires the money library located at http://dist.leetsoft.com/api/money
114
124
  def amount
metadata CHANGED
@@ -3,15 +3,15 @@ rubygems_version: 0.8.10
3
3
  specification_version: 1
4
4
  name: paypal
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.9.0
7
- date: 2005-07-22
8
- summary: Paypal IPN integration for rails apps and similar
6
+ version: 1.0.0
7
+ date: 2005-08-01
8
+ summary: Paypal IPN integration library for rails and other web applications
9
9
  require_paths:
10
10
  - lib
11
11
  email: tobi@leetsoft.com
12
12
  homepage: http://dist.leetsoft.com/api/paypal
13
13
  rubyforge_project:
14
- description:
14
+ description: Paypal IPN integration library for rails and other web applications
15
15
  autorequire: paypal
16
16
  default_executable:
17
17
  bindir: bin