rack-payment 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,17 +13,34 @@ module Rack #:nodoc:
13
13
  end
14
14
 
15
15
  def partially_filled_out?
16
- %w( name address1 city state zip country ).each do |field|
16
+ %w( name address1 city state zip ).each do |field|
17
17
  return true unless send(field).nil?
18
18
  end
19
19
 
20
20
  return false
21
21
  end
22
22
 
23
+ # defaults to 'US'
24
+ def country
25
+ @country ||= 'US'
26
+ end
27
+
23
28
  # Aliases
24
29
 
25
30
  def street() address1 end
26
31
  def street=(value) self.address1=(value) end
32
+
33
+ # Returns a hash that can be passed to a Gateway#authorize call
34
+ def active_merchant_hash
35
+ {
36
+ :name => name,
37
+ :address1 => street,
38
+ :city => city,
39
+ :state => state,
40
+ :country => country,
41
+ :zip => zip
42
+ }
43
+ end
27
44
  end
28
45
 
29
46
  end
@@ -135,7 +135,7 @@ module Rack #:nodoc:
135
135
  # TODO should pass :billing_address, if the billing address isn't empty.
136
136
  # fields: name, address1, city, state, country, zip.
137
137
  # Some gateways (eg. PayPal Pro) require a billing_address!
138
- self.raw_authorize_response = gateway.authorize amount_in_cents, credit_card.active_merchant_card, :ip => options[:ip]
138
+ self.raw_authorize_response = gateway.authorize amount_in_cents, credit_card.active_merchant_card, :ip => options[:ip], :billing_address => billing_address.active_merchant_hash
139
139
  unless raw_authorize_response.success?
140
140
  errors << raw_authorize_response.message
141
141
  log_authorize_unsuccessful(transaction_id, options)
@@ -175,12 +175,15 @@ module Rack #:nodoc:
175
175
  # By default, the form will POST to the current URL (action='')
176
176
  #
177
177
  # You can pass a different URL for the form action
178
- def form post_to = ''
179
- css = ::File.dirname(__FILE__) + '/views/credit-card-and-billing-info-form.css'
178
+ def form post_to = '', options = nil
180
179
  view = ::File.dirname(__FILE__) + '/views/credit-card-and-billing-info-form.html.erb'
181
180
  erb = ::File.read view
181
+ html = ''
182
+
183
+ if options and options[:inline_css]
184
+ html << "<style type='text/css'>\n#{ options[:inline_css] }\n</style>"
185
+ end
182
186
 
183
- html = "<style type='text/css'>\n#{ ::File.read(css) }\n</style>"
184
187
  html << ERB.new(erb).result(binding)
185
188
  end
186
189
 
@@ -202,7 +202,8 @@ module Rack #:nodoc:
202
202
  end
203
203
 
204
204
  def credit_card_and_billing_info_response
205
- form_html = payment.form built_in_form_path
205
+ css_file = ::File.dirname(__FILE__) + '/views/credit-card-and-billing-info-form.css'
206
+ form_html = payment.form built_in_form_path, :inline_css => ::File.read(css_file)
206
207
  layout = ::File.dirname(__FILE__) + '/views/layout.html'
207
208
  html = ::File.read(layout)
208
209
  html = html.sub 'CONTENT', form_html
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-payment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - remi
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-25 00:00:00 -07:00
12
+ date: 2010-01-27 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency