Included Modules

Class Index [+]

Quicksearch

ActiveMerchant::Billing::PayflowGateway

Constants

RECURRING_ACTIONS

Public Instance Methods

authorize(money, credit_card_or_reference, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/payflow.rb, line 16
16:       def authorize(money, credit_card_or_reference, options = {})
17:         request = build_sale_or_authorization_request(:authorization, money, credit_card_or_reference, options)
18:       
19:         commit(request, options)
20:       end
cancel_recurring(profile_id) click to toggle source
    # File lib/active_merchant/billing/gateways/payflow.rb, line 63
63:       def cancel_recurring(profile_id)
64:         request = build_recurring_request(:cancel, 0, :profile_id => profile_id)
65:         commit(request, options.merge(:request_type => :recurring))
66:       end
credit(money, identification_or_credit_card, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/payflow.rb, line 28
28:       def credit(money, identification_or_credit_card, options = {})
29:         if identification_or_credit_card.is_a?(String)
30:           deprecated CREDIT_DEPRECATION_MESSAGE
31:           # Perform referenced credit
32:           refund(money, identification_or_credit_card, options)
33:         else
34:           # Perform non-referenced credit
35:           request = build_credit_card_request(:credit, money, identification_or_credit_card, options)
36:           commit(request, options)
37:         end
38:       end
express() click to toggle source
    # File lib/active_merchant/billing/gateways/payflow.rb, line 73
73:       def express
74:         @express ||= PayflowExpressGateway.new(@options)
75:       end
purchase(money, credit_card_or_reference, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/payflow.rb, line 22
22:       def purchase(money, credit_card_or_reference, options = {})
23:         request = build_sale_or_authorization_request(:purchase, money, credit_card_or_reference, options)
24: 
25:         commit(request, options)
26:       end
recurring(money, credit_card, options = {}) click to toggle source

Adds or modifies a recurring Payflow profile. See the Payflow Pro Recurring Billing Guide for more details: www.paypal.com/en_US/pdf/PayflowPro_RecurringBilling_Guide.pdf

   

Several options are available to customize the recurring profile:

  • profile_id - is only required for editing a recurring profile

  • starting_at - takes a Date, Time, or string in mmddyyyy format. The date must be in the future.

  • name - The name of the customer to be billed. If not specified, the name from the credit card is used.

  • periodicity - The frequency that the recurring payments will occur at. Can be one of

:bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily, :semimonthly, :quadweekly, :quarterly, :semiyearly

  • payments - The term, or number of payments that will be made

  • comment - A comment associated with the profile

    # File lib/active_merchant/billing/gateways/payflow.rb, line 55
55:       def recurring(money, credit_card, options = {})
56:         options[:name] = credit_card.name if options[:name].blank? && credit_card
57:         request = build_recurring_request(options[:profile_id] ? :modify : :add, money, options) do |xml|
58:           add_credit_card(xml, credit_card) if credit_card
59:         end
60:         commit(request, options.merge(:request_type => :recurring))
61:       end
recurring_inquiry(profile_id, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/payflow.rb, line 68
68:       def recurring_inquiry(profile_id, options = {})
69:         request = build_recurring_request(:inquiry, nil, options.update( :profile_id => profile_id ))
70:         commit(request, options.merge(:request_type => :recurring))
71:       end
refund(money, reference, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/payflow.rb, line 40
40:       def refund(money, reference, options = {})
41:         commit(build_reference_request(:credit, money, reference, options), options)
42:       end

Private Instance Methods

add_credit_card(xml, credit_card) click to toggle source
     # File lib/active_merchant/billing/gateways/payflow.rb, line 141
141:       def add_credit_card(xml, credit_card)
142:         xml.tag! 'Card' do
143:           xml.tag! 'CardType', credit_card_type(credit_card)
144:           xml.tag! 'CardNum', credit_card.number
145:           xml.tag! 'ExpDate', expdate(credit_card)
146:           xml.tag! 'NameOnCard', credit_card.first_name
147:           xml.tag! 'CVNum', credit_card.verification_value if credit_card.verification_value?
148:           
149:           if requires_start_date_or_issue_number?(credit_card)
150:             xml.tag!('ExtData', 'Name' => 'CardStart', 'Value' => startdate(credit_card)) unless credit_card.start_month.blank? || credit_card.start_year.blank?
151:             xml.tag!('ExtData', 'Name' => 'CardIssue', 'Value' => format(credit_card.issue_number, :two_digits)) unless credit_card.issue_number.blank?
152:           end
153:           xml.tag! 'ExtData', 'Name' => 'LASTNAME', 'Value' =>  credit_card.last_name
154:         end
155:       end
build_credit_card_request(action, money, credit_card, options) click to toggle source
     # File lib/active_merchant/billing/gateways/payflow.rb, line 114
114:       def build_credit_card_request(action, money, credit_card, options)
115:         xml = Builder::XmlMarkup.new 
116:         xml.tag! TRANSACTIONS[action] do
117:           xml.tag! 'PayData' do
118:             xml.tag! 'Invoice' do
119:               xml.tag! 'CustIP', options[:ip] unless options[:ip].blank?
120:               xml.tag! 'InvNum', options[:order_id].to_s.gsub(/[^\w.]/, '') unless options[:order_id].blank?
121:               xml.tag! 'Description', options[:description] unless options[:description].blank?
122:               # Comment and Comment2 will show up in manager.paypal.com as Comment1 and Comment2
123:               xml.tag! 'Comment', options[:comment] unless options[:comment].blank?
124:               xml.tag!('ExtData', 'Name'=> 'COMMENT2', 'Value'=> options[:comment2]) unless options[:comment2].blank?
125: 
126:               billing_address = options[:billing_address] || options[:address]
127:               add_address(xml, 'BillTo', billing_address, options) if billing_address
128:               add_address(xml, 'ShipTo', options[:shipping_address], options) if options[:shipping_address]
129:               
130:               xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
131:             end
132:             
133:             xml.tag! 'Tender' do
134:               add_credit_card(xml, credit_card)
135:             end
136:           end 
137:         end
138:         xml.target!
139:       end
build_recurring_request(action, money, options) click to toggle source
     # File lib/active_merchant/billing/gateways/payflow.rb, line 177
177:       def build_recurring_request(action, money, options)
178:         unless RECURRING_ACTIONS.include?(action)
179:           raise StandardError, "Invalid Recurring Profile Action: #{action}"
180:         end
181: 
182:         xml = Builder::XmlMarkup.new 
183:         xml.tag! 'RecurringProfiles' do
184:           xml.tag! 'RecurringProfile' do
185:             xml.tag! action.to_s.capitalize do
186:               unless [:cancel, :inquiry].include?(action)
187:                 xml.tag! 'RPData' do
188:                   xml.tag! 'Name', options[:name] unless options[:name].nil?
189:                   xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
190:                   xml.tag! 'PayPeriod', get_pay_period(options)
191:                   xml.tag! 'Term', options[:payments] unless options[:payments].nil?
192:                   xml.tag! 'Comment', options[:comment] unless options[:comment].nil?
193:                 
194:                 
195:                   if initial_tx = options[:initial_transaction]
196:                     requires!(initial_tx, [:type, :authorization, :purchase])
197:                     requires!(initial_tx, :amount) if initial_tx[:type] == :purchase
198:                       
199:                     xml.tag! 'OptionalTrans', TRANSACTIONS[initial_tx[:type]]
200:                     xml.tag! 'OptionalTransAmt', amount(initial_tx[:amount]) unless initial_tx[:amount].blank?
201:                   end
202:                 
203:                   xml.tag! 'Start', format_rp_date(options[:starting_at] || Date.today + 1 )
204:                   xml.tag! 'EMail', options[:email] unless options[:email].nil?
205:                   
206:                   billing_address = options[:billing_address] || options[:address]
207:                   add_address(xml, 'BillTo', billing_address, options) if billing_address
208:                   add_address(xml, 'ShipTo', options[:shipping_address], options) if options[:shipping_address]
209:                 end
210:                 xml.tag! 'Tender' do
211:                   yield xml
212:                 end
213:               end
214:               if action != :add
215:                 xml.tag! "ProfileID", options[:profile_id]
216:               end
217:               if action == :inquiry
218:                 xml.tag! "PaymentHistory", ( options[:history] ? 'Y' : 'N' )
219:               end
220:             end
221:           end
222:         end
223:       end
build_reference_sale_or_authorization_request(action, money, reference, options) click to toggle source
     # File lib/active_merchant/billing/gateways/payflow.rb, line 86
 86:       def build_reference_sale_or_authorization_request(action, money, reference, options)
 87:         xml = Builder::XmlMarkup.new
 88:         xml.tag! TRANSACTIONS[action] do
 89:           xml.tag! 'PayData' do
 90:             xml.tag! 'Invoice' do
 91:               # Fields accepted by PayFlow and recommended to be provided even for Reference Transaction, per Payflow docs.
 92:               xml.tag! 'CustIP', options[:ip] unless options[:ip].blank?
 93:               xml.tag! 'InvNum', options[:order_id].to_s.gsub(/[^\w.]/, '') unless options[:order_id].blank?
 94:               xml.tag! 'Description', options[:description] unless options[:description].blank?
 95:               xml.tag! 'Comment', options[:comment] unless options[:comment].blank?
 96:               xml.tag!('ExtData', 'Name'=> 'COMMENT2', 'Value'=> options[:comment2]) unless options[:comment2].blank?
 97: 
 98:               billing_address = options[:billing_address] || options[:address]
 99:               add_address(xml, 'BillTo', billing_address, options) if billing_address
100:               add_address(xml, 'ShipTo', options[:shipping_address],options) if options[:shipping_address]
101: 
102:               xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
103:             end
104:             xml.tag! 'Tender' do
105:               xml.tag! 'Card' do
106:                 xml.tag! 'ExtData', 'Name' => 'ORIGID', 'Value' =>  reference
107:               end
108:             end
109:           end
110:         end
111:         xml.target!
112:       end
build_response(success, message, response, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/payflow.rb, line 247
247:       def build_response(success, message, response, options = {}) 
248:         PayflowResponse.new(success, message, response, options)
249:       end
build_sale_or_authorization_request(action, money, credit_card_or_reference, options) click to toggle source
    # File lib/active_merchant/billing/gateways/payflow.rb, line 78
78:       def build_sale_or_authorization_request(action, money, credit_card_or_reference, options)
79:         if credit_card_or_reference.is_a?(String)
80:           build_reference_sale_or_authorization_request(action, money, credit_card_or_reference, options)
81:         else  
82:           build_credit_card_request(action, money, credit_card_or_reference, options)
83:         end  
84:       end
credit_card_type(credit_card) click to toggle source
     # File lib/active_merchant/billing/gateways/payflow.rb, line 157
157:       def credit_card_type(credit_card)
158:         return '' if card_brand(credit_card).blank?
159:         
160:         CARD_MAPPING[card_brand(credit_card).to_sym]
161:       end
expdate(creditcard) click to toggle source
     # File lib/active_merchant/billing/gateways/payflow.rb, line 163
163:       def expdate(creditcard)
164:         year  = sprintf("%.4i", creditcard.year)
165:         month = sprintf("%.2i", creditcard.month)
166: 
167:         "#{year}#{month}"
168:       end
format_rp_date(time) click to toggle source
     # File lib/active_merchant/billing/gateways/payflow.rb, line 239
239:       def format_rp_date(time)
240:         case time
241:           when Time, Date then time.strftime("%m%d%Y")
242:         else
243:           time.to_s
244:         end
245:       end
get_pay_period(options) click to toggle source
     # File lib/active_merchant/billing/gateways/payflow.rb, line 225
225:       def get_pay_period(options)
226:         requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily, :semimonthly, :quadweekly, :quarterly, :semiyearly])
227:         case options[:periodicity]
228:           when :weekly then 'Weekly'
229:           when :biweekly then 'Bi-weekly'
230:           when :semimonthly then 'Semi-monthly'
231:           when :quadweekly then 'Every four weeks'
232:           when :monthly then 'Monthly'
233:           when :quarterly then 'Quarterly'
234:           when :semiyearly then 'Semi-yearly'
235:           when :yearly then 'Yearly'
236:         end
237:       end
startdate(creditcard) click to toggle source
     # File lib/active_merchant/billing/gateways/payflow.rb, line 170
170:       def startdate(creditcard)
171:         year  = format(creditcard.start_year, :two_digits)
172:         month = format(creditcard.start_month, :two_digits)
173: 
174:         "#{month}#{year}"
175:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.