Skip to content

Commit

Permalink
Add 2Checkout language support
Browse files Browse the repository at this point in the history
  • Loading branch information
Bart de Water committed Apr 6, 2017
1 parent 72f07e1 commit 8b0b6d5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/offsite_payments/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ def lookup_country_code(name_or_code, format = country_format)
name_or_code
end

def language_from_locale(locale)
locale[0..1].downcase
end

def method_missing(method_id, *args)
method_id = method_id.to_s.gsub(/=$/, '').to_sym
# Return and do nothing if the mapping was not found. This allows
Expand Down
4 changes: 4 additions & 0 deletions lib/offsite_payments/integrations/two_checkout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ def third_party_cart(params = {})
add_field("c_#{key}_#{line_item_id}", value)
end
end

def locale(locale)
add_field 'lang', language_from_locale(locale)
end
end

class Notification < OffsitePayments::Notification
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ def test_extra_helper_fields
@helper.return_url 'https://return.url/'
@helper.cart_type 'shopify'
@helper.purchase_step 'payment-method'
@helper.locale 'en-US'

assert_field 'currency_code', 'ZAR'
assert_field 'cart_order_id', '123'
assert_field 'x_receipt_link_url', 'https://return.url/'
assert_field '2co_cart_type', 'shopify'
assert_field 'purchase_step', 'payment-method'
assert_field 'lang', 'en'
end

def test_customer_fields
Expand Down

0 comments on commit 8b0b6d5

Please sign in to comment.