Skip to content

Commit

Permalink
Added locale option.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnando committed Jul 11, 2011
1 parent 36bbcd1 commit 416324b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/paypal/recurring/base.rb
Expand Up @@ -11,6 +11,7 @@ class Base
attr_accessor :initial_amount
attr_accessor :initial_amount_action
attr_accessor :ipn_url
attr_accessor :locale
attr_accessor :outstanding
attr_accessor :payer_id
attr_accessor :period
Expand Down Expand Up @@ -45,7 +46,20 @@ def request # :nodoc:
# response.checkout_url
#
def checkout
params = collect(:amount, :return_url, :cancel_url, :currency, :description, :ipn_url).merge(:payment_action => "Authorization", :no_shipping => 1, :L_BILLINGTYPE0 => "RecurringPayments")
params = collect(
:locale,
:amount,
:return_url,
:cancel_url,
:currency,
:description,
:ipn_url
).merge(
:payment_action => "Authorization",
:no_shipping => 1,
:L_BILLINGTYPE0 => "RecurringPayments"
)

request.run(:checkout, params)
end

Expand Down
5 changes: 5 additions & 0 deletions lib/paypal/recurring/request.rb
Expand Up @@ -45,6 +45,7 @@ class Request
:initial_amount => "INITAMT",
:initial_amount_action => "FAILEDINITAMTACTION",
:ipn_url => ["PAYMENTREQUEST_0_NOTIFYURL", "NOTIFYURL"],
:locale => "LOCALECODE",
:method => "METHOD",
:no_shipping => "NOSHIPPING",
:outstanding => "AUTOBILLOUTAMT",
Expand Down Expand Up @@ -163,6 +164,10 @@ def build_action(value) # :nodoc:
def build_initial_amount_action(value) # :nodoc:
INITIAL_AMOUNT_ACTIONS.fetch(value.to_sym, value) if value
end

def build_locale(value) # :nodoc:
value.to_s.upcase
end
end
end
end
4 changes: 4 additions & 0 deletions spec/paypal/request_spec.rb
Expand Up @@ -111,5 +111,9 @@
it "normalizes reference" do
subject.normalize_params(:reference => "abc").should == {:PROFILEREFERENCE => "abc", :PAYMENTREQUEST_0_CUSTOM => "abc", :PAYMENTREQUEST_0_INVNUM => "abc"}
end

it "normalizes locale" do
subject.normalize_params(:locale => :us).should == {:LOCALECODE => "US"}
end
end
end

0 comments on commit 416324b

Please sign in to comment.