Sha256: e4da2fe79f5413632a1b885c26f737a5e4cd226878ec4d7f798733bed39939a5

Contents?: true

Size: 1.67 KB

Versions: 10

Compression:

Stored size: 1.67 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 checkout_status
        (@params['CheckoutStatus']||{})
      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

      def note
        @params['note_text']
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
swiss-activemerchant-1.0.6 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
swiss-activemerchant-1.0.5 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
swiss-activemerchant-1.0.4 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.137.0 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
swiss-activemerchant-1.0.2 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
swiss-activemerchant-1.0.1 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.133.0 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.131.0 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.130.0 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb
activemerchant-1.129.0 lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb