lib/active_merchant/billing/gateways/paypal_express.rb in activemerchant-1.20.3 vs lib/active_merchant/billing/gateways/paypal_express.rb in activemerchant-1.20.4
- old
+ new
@@ -96,16 +96,43 @@
xml = Builder::XmlMarkup.new :indent => 2
xml.tag! 'SetExpressCheckoutReq', 'xmlns' => PAYPAL_NAMESPACE do
xml.tag! 'SetExpressCheckoutRequest', 'xmlns:n2' => EBAY_NAMESPACE do
xml.tag! 'n2:Version', API_VERSION
xml.tag! 'n2:SetExpressCheckoutRequestDetails' do
+ xml.tag! 'n2:ReturnURL', options[:return_url]
+ xml.tag! 'n2:CancelURL', options[:cancel_return_url]
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?
+ # 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?
+ xml.tag! 'n2:cpp-header-back-color', options[:header_background_color] unless options[:header_background_color].blank?
+ xml.tag! 'n2:cpp-payflow-color', options[:background_color] unless options[:background_color].blank?
+ if options[:allow_guest_checkout]
+ xml.tag! 'n2:SolutionType', 'Sole'
+ xml.tag! 'n2:LandingPage', 'Billing'
+ end
+ xml.tag! 'n2:BuyerEmail', options[:email] unless options[:email].blank?
+
+ if options[:billing_agreement]
+ xml.tag! 'n2:BillingAgreementDetails' do
+ xml.tag! 'n2:BillingType', options[:billing_agreement][:type]
+ xml.tag! 'n2:BillingAgreementDescription', options[:billing_agreement][:description]
+ xml.tag! 'n2:PaymentType', options[:billing_agreement][:payment_type] || 'InstantOnly'
+ end
+ end
+
if !options[:allow_note].nil?
xml.tag! 'n2:AllowNote', options[:allow_note] ? '1' : '0'
end
+ xml.tag! 'n2:CallbackURL', options[:callback_url] unless options[:callback_url].blank?
+
xml.tag! 'n2:PaymentDetails' do
xml.tag! 'n2:OrderTotal', amount(money).to_f.zero? ? localized_amount(100, currency_code) : localized_amount(money, currency_code), 'currencyID' => currency_code
# All of the values must be included together and add up to the order total
if [:subtotal, :shipping, :handling, :tax].all? { |o| options.has_key?(o) }
xml.tag! 'n2:ItemTotal', localized_amount(options[:subtotal], currency_code), 'currencyID' => currency_code
@@ -115,45 +142,29 @@
end
xml.tag! 'n2:OrderDescription', options[:description]
xml.tag! 'n2:InvoiceID', options[:order_id]
- add_items_xml(xml, options, currency_code) if options[:items]
-
add_address(xml, 'n2:ShipToAddress', options[:shipping_address] || options[:address])
+ add_items_xml(xml, options, currency_code) if options[:items]
+
xml.tag! 'n2:PaymentAction', action
end
- xml.tag! 'n2:AddressOverride', options[:address_override] ? '1' : '0'
- xml.tag! 'n2:NoShipping', options[:no_shipping] ? '1' : '0'
- xml.tag! 'n2:ReturnURL', options[:return_url]
- xml.tag! 'n2:CancelURL', options[:cancel_return_url]
- xml.tag! 'n2:IPAddress', options[:ip] unless options[:ip].blank?
- xml.tag! 'n2:BuyerEmail', options[:email] unless options[:email].blank?
-
- if options[:billing_agreement]
- xml.tag! 'n2:BillingAgreementDetails' do
- xml.tag! 'n2:BillingType', options[:billing_agreement][:type]
- xml.tag! 'n2:BillingAgreementDescription', options[:billing_agreement][:description]
- xml.tag! 'n2:PaymentType', options[:billing_agreement][:payment_type] || 'InstantOnly'
+ if options[:shipping_options]
+ options[:shipping_options].each do |shipping_option|
+ xml.tag! 'n2:FlatRateShippingOptions' do
+ xml.tag! 'n2:ShippingOptionIsDefault', shipping_option[:default]
+ xml.tag! 'n2:ShippingOptionAmount', localized_amount(shipping_option[:amount], currency_code), 'currencyID' => currency_code
+ xml.tag! 'n2:ShippingOptionName', shipping_option[:name]
+ end
end
end
-
- # 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-back-color', options[:header_background_color] unless options[:header_background_color].blank?
- xml.tag! 'n2:cpp-header-border-color', options[:header_border_color] unless options[:header_border_color].blank?
- xml.tag! 'n2:cpp-payflow-color', options[:background_color] unless options[:background_color].blank?
-
- if options[:allow_guest_checkout]
- xml.tag! 'n2:SolutionType', 'Sole'
- xml.tag! 'n2:LandingPage', 'Billing'
- end
-
- xml.tag! 'n2:LocaleCode', options[:locale] unless options[:locale].blank?
+
+ xml.tag! 'n2:CallbackTimeout', options[:callback_timeout] unless options[:callback_timeout].blank?
+ xml.tag! 'n2:CallbackVersion', options[:callback_version] unless options[:callback_version].blank?
end
end
end
xml.target!
@@ -179,6 +190,6 @@
end
end
end
end
end
-end
+end
\ No newline at end of file