lib/active_merchant/billing/gateways/paypal_express.rb in activemerchant-1.43.3 vs lib/active_merchant/billing/gateways/paypal_express.rb in activemerchant-1.44.0

- old
+ new

@@ -65,10 +65,14 @@ def unstore(token, options = {}) commit 'BAUpdate', build_cancel_billing_agreement_request(token) end + def agreement_details(reference_id, options = {}) + commit 'BAUpdate', build_details_billing_agreement_request(reference_id) + end + def authorize_reference_transaction(money, options = {}) requires!(options, :reference_id, :payment_type, :invoice_id, :description, :ip) commit 'DoReferenceTransaction', build_reference_transaction_request('Authorization', money, options) end @@ -125,16 +129,18 @@ 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:ReqBillingAddress', options[:req_billing_address] ? '1' : '0' xml.tag! 'n2:NoShipping', options[:no_shipping] ? '1' : '0' xml.tag! 'n2:AddressOverride', options[:address_override] ? '1' : '0' 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-logo-image', options[:logo_image] unless options[:logo_image].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] @@ -152,10 +158,17 @@ end if !options[:allow_note].nil? xml.tag! 'n2:AllowNote', options[:allow_note] ? '1' : '0' end + + if options[:funding_sources] + xml.tag! 'n2:FundingSourceDetails' do + xml.tag! 'n2:UserSelectedFundingSource', options[:funding_sources][:source] + end + end + xml.tag! 'n2:CallbackURL', options[:callback_url] unless options[:callback_url].blank? add_payment_details(xml, money, currency_code, options) if options[:shipping_options] options[:shipping_options].each do |shipping_option| @@ -197,9 +210,21 @@ xml.tag! 'BillAgreementUpdateReq', 'xmlns' => PAYPAL_NAMESPACE do xml.tag! 'BAUpdateRequest', 'xmlns:n2' => EBAY_NAMESPACE do xml.tag! 'n2:Version', API_VERSION xml.tag! 'ReferenceID', token xml.tag! 'BillingAgreementStatus', "Canceled" + end + end + + xml.target! + end + + def build_details_billing_agreement_request(reference_id) + xml = Builder::XmlMarkup.new :indent => 2 + xml.tag! 'BillAgreementUpdateReq', 'xmlns' => PAYPAL_NAMESPACE do + xml.tag! 'BAUpdateRequest', 'xmlns:n2' => EBAY_NAMESPACE do + xml.tag! 'n2:Version', API_VERSION + xml.tag! 'ReferenceID', reference_id end end xml.target! end