lib/active_merchant/billing/gateways/paypal_express.rb in activemerchant-1.27.0 vs lib/active_merchant/billing/gateways/paypal_express.rb in activemerchant-1.28.0
- old
+ new
@@ -5,11 +5,27 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class PaypalExpressGateway < Gateway
include PaypalCommonAPI
include PaypalExpressCommon
-
+
+ NON_STANDARD_LOCALE_CODES = {
+ 'DK' => 'da_DK',
+ 'IL' => 'he_IL',
+ 'ID' => 'id_ID',
+ 'JP' => 'jp_JP',
+ 'NO' => 'no_NO',
+ 'BR' => 'pt_BR',
+ 'RU' => 'ru_RU',
+ 'SE' => 'sv_SE',
+ 'TH' => 'th_TH',
+ 'TR' => 'tr_TR',
+ 'CN' => 'zh_CN',
+ 'HK' => 'zh_HK',
+ 'TW' => 'zh_TW'
+ }
+
self.test_redirect_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'
self.supported_countries = ['US']
self.homepage_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=xpt/merchant/ExpressCheckoutIntro-outside'
self.display_name = 'PayPal Express Checkout'
@@ -95,11 +111,11 @@
if options[:max_amount]
xml.tag! 'n2:MaxAmount', localized_amount(options[:max_amount], currency_code), 'currencyID' => currency_code
end
xml.tag! 'n2:NoShipping', options[:no_shipping] ? '1' : '0'
xml.tag! 'n2:AddressOverride', options[:address_override] ? '1' : '0'
- xml.tag! 'n2:LocaleCode', options[:locale] unless options[:locale].blank?
+ xml.tag! 'n2:LocaleCode', locale_code(options[:locale]) unless options[:locale].blank?
xml.tag! 'n2:BrandName', options[:brand_name] unless options[:brand_name].blank?
# Customization of the payment page
xml.tag! 'n2:PageStyle', options[:page_style] unless options[:page_style].blank?
xml.tag! 'n2:cpp-header-image', options[:header_image] unless options[:header_image].blank?
xml.tag! 'n2:cpp-header-border-color', options[:header_border_color] unless options[:header_border_color].blank?
@@ -170,9 +186,13 @@
PaypalExpressResponse.new(success, message, response, options)
end
def with_money_default(money)
amount(money).to_f.zero? ? 100 : money
+ end
+
+ def locale_code(country_code)
+ NON_STANDARD_LOCALE_CODES[country_code] || country_code
end
end
end
end