Parent

Class Index [+]

Quicksearch

ActiveMerchant::Billing::BarclaysEpdqGateway::Document

Constants

PAYMENT_INTERVALS
EPDQ_CARD_TYPES

Attributes

type[R]
xml[R]

Public Class Methods

new(gateway, options = {}, document_options = {}, &block) click to toggle source
     # File lib/active_merchant/billing/gateways/barclays_epdq.rb, line 184
184:         def initialize(gateway, options = {}, document_options = {}, &block)
185:           @gateway = gateway
186:           @options = options
187:           @document_options = document_options
188:           @xml = Builder::XmlMarkup.new(:indent => 2)
189:           build(&block)
190:         end

Public Instance Methods

add_consumer(options=nil, &block) click to toggle source
     # File lib/active_merchant/billing/gateways/barclays_epdq.rb, line 228
228:         def add_consumer(options=nil, &block)
229:           xml.Consumer do
230:             if options
231:               xml.Email(options[:email]) if options[:email]
232:               billing_address = options[:billing_address] || options[:address]
233:               if billing_address
234:                 xml.BillTo do
235:                   xml.Location do
236:                     xml.Address do
237:                       xml.Street1 billing_address[:address1]
238:                       xml.Street2 billing_address[:address2]
239:                       xml.City billing_address[:city]
240:                       xml.StateProv billing_address[:state]
241:                       xml.PostalCode billing_address[:zip]
242:                       xml.Country billing_address[:country_code]
243:                     end
244:                   end
245:                 end
246:               end
247:             end
248:             instance_eval(&block)
249:           end
250:         end
add_creditcard(creditcard) click to toggle source
     # File lib/active_merchant/billing/gateways/barclays_epdq.rb, line 252
252:         def add_creditcard(creditcard)
253:           xml.PaymentMech do
254:             xml.CreditCard do
255:               xml.Type({ :DataType => 'S32' }, EPDQ_CARD_TYPES[creditcard.brand.to_sym])
256:               xml.Number creditcard.number
257:               xml.Expires({ :DataType => 'ExpirationDate', :Locale => 826 }, format_expiry_date(creditcard))
258:               if creditcard.verification_value.present?
259:                 xml.Cvv2Indicator 1
260:                 xml.Cvv2Val creditcard.verification_value
261:               else
262:                 xml.Cvv2Indicator 5
263:               end
264:               xml.IssueNum(creditcard.issue_number) if creditcard.issue_number.present?
265:             end
266:           end
267:         end
add_order_form(order_id=nil, group_id=nil, &block) click to toggle source
     # File lib/active_merchant/billing/gateways/barclays_epdq.rb, line 219
219:         def add_order_form(order_id=nil, group_id=nil, &block)
220:           xml.OrderFormDoc do
221:             xml.Mode 'P'
222:             xml.Id(order_id) if order_id
223:             xml.GroupId(group_id) if group_id
224:             instance_eval(&block)
225:           end
226:         end
add_transaction(auth_type, amount = nil, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/barclays_epdq.rb, line 269
269:         def add_transaction(auth_type, amount = nil, options = {})
270:           @auth_type = auth_type
271:           xml.Transaction do
272:             xml.Type @auth_type.to_s
273:             if options[:payment_number] && options[:payment_number] > 1
274:               xml.CardholderPresentCode({ :DataType => 'S32' }, 8)
275:             else
276:               xml.CardholderPresentCode({ :DataType => 'S32' }, 7)
277:             end
278:             if options[:payment_number]
279:               xml.PaymentNumber({ :DataType => 'S32' }, options[:payment_number])
280:             end
281:             if options[:total_payments]
282:               xml.TotalNumberPayments({ :DataType => 'S32' }, options[:total_payments])
283:             end
284:             if amount
285:               xml.CurrentTotals do
286:                 xml.Totals do
287:                   xml.Total({ :DataType => 'Money', :Currency => 826 }, amount)
288:                 end
289:               end
290:             end
291:           end
292:         end
build(&block) click to toggle source
     # File lib/active_merchant/billing/gateways/barclays_epdq.rb, line 196
196:         def build(&block)
197:           xml.instruct!(:xml, :version => '1.0')
198:           xml.EngineDocList do
199:             xml.DocVersion "1.0"
200:             xml.EngineDoc do
201:               xml.ContentType "OrderFormDoc"
202:               xml.User do
203:                 xml.Name(@options[:login])
204:                 xml.Password(@options[:password])
205:                 xml.ClientId({ :DataType => "S32" }, @options[:client_id])
206:               end
207:               xml.Instructions do
208:                 if @document_options[:no_fraud]
209:                   xml.Pipeline "PaymentNoFraud" 
210:                 else
211:                   xml.Pipeline "Payment"
212:                 end
213:               end
214:               instance_eval(&block)
215:             end
216:           end
217:         end
format_expiry_date(creditcard) click to toggle source

date must be formatted MM/YY

     # File lib/active_merchant/billing/gateways/barclays_epdq.rb, line 295
295:         def format_expiry_date(creditcard)
296:           month_str = "%02d" % creditcard.month
297:           if match = creditcard.year.to_s.match(/^\d{2}(\d{2})$/) 
298:             year_str = "%02d" % match[1].to_i
299:           else 
300:             year_str = "%02d" % creditcard.year
301:           end
302:           "#{month_str}/#{year_str}"
303:         end
to_xml() click to toggle source
     # File lib/active_merchant/billing/gateways/barclays_epdq.rb, line 192
192:         def to_xml
193:           @xml.target!
194:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.