Included Modules

Class Index [+]

Quicksearch

ActiveMerchant::Billing::PaypalGateway

Public Instance Methods

authorize(money, credit_card_or_referenced_id, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/paypal.rb, line 14
14:       def authorize(money, credit_card_or_referenced_id, options = {})
15:         requires!(options, :ip)
16:         commit define_transaction_type(credit_card_or_referenced_id), build_sale_or_authorization_request('Authorization', money, credit_card_or_referenced_id, options)
17:       end
express() click to toggle source
    # File lib/active_merchant/billing/gateways/paypal.rb, line 24
24:       def express
25:         @express ||= PaypalExpressGateway.new(@options)
26:       end
purchase(money, credit_card_or_referenced_id, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/paypal.rb, line 19
19:       def purchase(money, credit_card_or_referenced_id, options = {})
20:         requires!(options, :ip)
21:         commit define_transaction_type(credit_card_or_referenced_id), build_sale_or_authorization_request('Sale', money, credit_card_or_referenced_id, options)
22:       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 79
 79:       def add_credit_card(xml, credit_card, address, options)
 80:         xml.tag! 'n2:CreditCard' do
 81:           xml.tag! 'n2:CreditCardType', credit_card_type(card_brand(credit_card))
 82:           xml.tag! 'n2:CreditCardNumber', credit_card.number
 83:           xml.tag! 'n2:ExpMonth', format(credit_card.month, :two_digits)
 84:           xml.tag! 'n2:ExpYear', format(credit_card.year, :four_digits)
 85:           xml.tag! 'n2:CVV2', credit_card.verification_value
 86:           
 87:           if [ 'switch', 'solo' ].include?(card_brand(credit_card).to_s)
 88:             xml.tag! 'n2:StartMonth', format(credit_card.start_month, :two_digits) unless credit_card.start_month.blank?
 89:             xml.tag! 'n2:StartYear', format(credit_card.start_year, :four_digits) unless credit_card.start_year.blank?
 90:             xml.tag! 'n2:IssueNumber', format(credit_card.issue_number, :two_digits) unless credit_card.issue_number.blank?
 91:           end
 92:           
 93:           xml.tag! 'n2:CardOwner' do
 94:             xml.tag! 'n2:PayerName' do
 95:               xml.tag! 'n2:FirstName', credit_card.first_name
 96:               xml.tag! 'n2:LastName', credit_card.last_name
 97:             end
 98:             
 99:             xml.tag! 'n2:Payer', options[:email]
100:             add_address(xml, 'n2:Address', address)
101:           end
102:         end
103:       end
build_response(success, message, response, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/paypal.rb, line 116
116:       def build_response(success, message, response, options = {})
117:          Response.new(success, message, response, options)
118:       end
build_sale_or_authorization_request(action, money, credit_card_or_referenced_id, options) click to toggle source
    # File lib/active_merchant/billing/gateways/paypal.rb, line 38
38:       def build_sale_or_authorization_request(action, money, credit_card_or_referenced_id, options)
39:         transaction_type = define_transaction_type(credit_card_or_referenced_id)
40:         reference_id = credit_card_or_referenced_id if transaction_type == "DoReferenceTransaction"
41:         
42:         billing_address = options[:billing_address] || options[:address]
43:         currency_code = options[:currency] || currency(money)
44:        
45:         xml = Builder::XmlMarkup.new :indent => 2
46:         xml.tag! transaction_type + 'Req', 'xmlns' => PAYPAL_NAMESPACE do
47:           xml.tag! transaction_type + 'Request', 'xmlns:n2' => EBAY_NAMESPACE do
48:             xml.tag! 'n2:Version', API_VERSION
49:             xml.tag! 'n2:' + transaction_type + 'RequestDetails' do
50:               xml.tag! 'n2:ReferenceID', reference_id if transaction_type == 'DoReferenceTransaction'
51:               xml.tag! 'n2:PaymentAction', action
52:               xml.tag! 'n2:PaymentDetails' do
53:                 xml.tag! 'n2:OrderTotal', localized_amount(money, currency_code), 'currencyID' => currency_code
54:                 
55:                 # All of the values must be included together and add up to the order total
56:                 if [:subtotal, :shipping, :handling, :tax].all?{ |o| options.has_key?(o) }
57:                   xml.tag! 'n2:ItemTotal', localized_amount(options[:subtotal], currency_code), 'currencyID' => currency_code
58:                   xml.tag! 'n2:ShippingTotal', localized_amount(options[:shipping], currency_code),'currencyID' => currency_code
59:                   xml.tag! 'n2:HandlingTotal', localized_amount(options[:handling], currency_code),'currencyID' => currency_code
60:                   xml.tag! 'n2:TaxTotal', localized_amount(options[:tax], currency_code), 'currencyID' => currency_code
61:                 end
62:                 
63:                 xml.tag! 'n2:NotifyURL', options[:notify_url]
64:                 xml.tag! 'n2:OrderDescription', options[:description]
65:                 xml.tag! 'n2:InvoiceID', options[:order_id]
66:                 xml.tag! 'n2:ButtonSource', application_id.to_s.slice(0,32) unless application_id.blank? 
67:                 
68:                 add_address(xml, 'n2:ShipToAddress', options[:shipping_address]) if options[:shipping_address]
69:               end
70:               add_credit_card(xml, credit_card_or_referenced_id, billing_address, options) unless transaction_type == 'DoReferenceTransaction'
71:               xml.tag! 'n2:IPAddress', options[:ip]
72:             end
73:           end
74:         end
75: 
76:         xml.target!        
77:       end
credit_card_type(type) click to toggle source
     # File lib/active_merchant/billing/gateways/paypal.rb, line 105
105:       def credit_card_type(type)
106:         case type
107:         when 'visa'             then 'Visa'
108:         when 'master'           then 'MasterCard'
109:         when 'discover'         then 'Discover'
110:         when 'american_express' then 'Amex'
111:         when 'switch'           then 'Switch'
112:         when 'solo'             then 'Solo'
113:         end
114:       end
define_transaction_type(transaction_arg) click to toggle source
    # File lib/active_merchant/billing/gateways/paypal.rb, line 30
30:       def define_transaction_type(transaction_arg)
31:         if transaction_arg.is_a?(String)
32:           return 'DoReferenceTransaction'
33:         else
34:           return 'DoDirectPayment'
35:         end
36:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.