class ActiveMerchant::Billing::PaypalGateway
Public Instance Methods
express()
click to toggle source
# File lib/active_merchant/billing/gateways/paypal.rb, line 37 def express @express ||= PaypalExpressGateway.new(@options) end
purchase(money, credit_card_or_referenced_id, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/paypal.rb, line 21 def purchase(money, credit_card_or_referenced_id, options = {}) requires!(options, :ip) commit define_transaction_type(credit_card_or_referenced_id), build_sale_or_authorization_request('Sale', money, credit_card_or_referenced_id, options) end
verify(credit_card, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/paypal.rb, line 26 def verify(credit_card, options = {}) if %w(visa master).include?(credit_card.brand) authorize(0, credit_card, options) else MultiResponse.run(:use_first_response) do |r| r.process { authorize(100, credit_card, options) } r.process(:ignore_result) { void(r.authorization, options) } end end end
Private Instance Methods
add_credit_card(xml, credit_card, address, options)
click to toggle source
# File lib/active_merchant/billing/gateways/paypal.rb, line 75 def add_credit_card(xml, credit_card, address, options) xml.tag! 'n2:CreditCard' do xml.tag! 'n2:CreditCardType', credit_card_type(card_brand(credit_card)) xml.tag! 'n2:CreditCardNumber', credit_card.number xml.tag! 'n2:ExpMonth', format(credit_card.month, :two_digits) xml.tag! 'n2:ExpYear', format(credit_card.year, :four_digits) xml.tag! 'n2:CVV2', credit_card.verification_value if [ 'switch', 'solo' ].include?(card_brand(credit_card).to_s) xml.tag! 'n2:StartMonth', format(credit_card.start_month, :two_digits) unless credit_card.start_month.blank? xml.tag! 'n2:StartYear', format(credit_card.start_year, :four_digits) unless credit_card.start_year.blank? xml.tag! 'n2:IssueNumber', format(credit_card.issue_number, :two_digits) unless credit_card.issue_number.blank? end xml.tag! 'n2:CardOwner' do xml.tag! 'n2:PayerName' do xml.tag! 'n2:FirstName', credit_card.first_name xml.tag! 'n2:LastName', credit_card.last_name end xml.tag! 'n2:Payer', options[:email] add_address(xml, 'n2:Address', address) end end end
build_response(success, message, response, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/paypal.rb, line 112 def build_response(success, message, response, options = {}) Response.new(success, message, response, options) end
credit_card_type(type)
click to toggle source
# File lib/active_merchant/billing/gateways/paypal.rb, line 101 def credit_card_type(type) case type when 'visa' then 'Visa' when 'master' then 'MasterCard' when 'discover' then 'Discover' when 'american_express' then 'Amex' when 'switch' then 'Switch' when 'solo' then 'Solo' end end
define_transaction_type(transaction_arg)
click to toggle source
# File lib/active_merchant/billing/gateways/paypal.rb, line 43 def define_transaction_type(transaction_arg) if transaction_arg.is_a?(String) return 'DoReferenceTransaction' else return 'DoDirectPayment' end end