Sha256: 8b70daf18cd3c505a27aa7b2c2813743a05650b12c3f3fb995024caf1eedddb4

Contents?: true

Size: 1.52 KB

Versions: 9

Compression:

Stored size: 1.52 KB

Contents

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    class PaypalExpressResponse < Response
      def email
        info['Payer']
      end

      def info
        (@params['PayerInfo']||{})
      end
      
      def name
        payer = (info['PayerName']||{})
        [payer['FirstName'], payer['MiddleName'], payer['LastName']].compact.join(' ')
      end
      
      def token
        @params['Token']
      end
      
      def payer_id
        info['PayerID']
      end
      
      def payer_country
        info['PayerCountry']
      end
      
      # PayPal returns a contact telephone number only if your Merchant account profile settings require that the buyer enter one.
      def contact_phone
        @params['ContactPhone']
      end
      
      def address
        address = (@params['PaymentDetails']||{})['ShipToAddress']
        {  'name'       => address['Name'],
           'company'    => info['PayerBusiness'],
           'address1'   => address['Street1'],
           'address2'   => address['Street2'],
           'city'       => address['CityName'],
           'state'      => address['StateOrProvince'],
           'country'    => address['Country'],
           'zip'        => address['PostalCode'],
           'phone'      => (contact_phone || address['Phone'])
        }
      end
      
      def shipping
        shipping = (@params['UserSelectedOptions']||{})
        {  'amount'   => shipping['ShippingOptionAmount'],
           'name'     => shipping['ShippingOptionName']
        }
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
activemerchant-1.31.1 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.31.0 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.30.0 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
jelaniharris-activemerchant-1.29.2 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.29.3 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.29.2 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.29.1 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
jelaniharris-activemerchant-1.29.1 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.29.0 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb