Sha256: 24276d047858050a09ec88ff111baa07822e2b244e26b55812c1a725bea471dc

Contents?: true

Size: 1.54 KB

Versions: 39

Compression:

Stored size: 1.54 KB

Contents

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

      def info
        (@params['PayerInfo']||{})
      end

      def details
        (@params['PaymentDetails']||{})
      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 = (details['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

39 entries across 39 versions & 3 rubygems

Version Path
tanga_activemerchant-1.38.0.5 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
tanga_activemerchant-1.38.0.4 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
tanga_activemerchant-1.38.0.3 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
tanga_activemerchant-1.38.0.2 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/activemerchant-1.44.1/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
tanga_activemerchant-1.38.0.1 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
tanga_activemerchant-1.38.0 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
tanga_activemerchant-1.37.0 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.44.1 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.44.0 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.43.3 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.43.1 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.43.0 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.42.9 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.42.8 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.42.7 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.42.6 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.42.5 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.42.4 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.42.3 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb