class ActiveMerchant::Billing::ProPayGateway
Constants
- STATUS_RESPONSE_CODES
- TRANSACTION_RESPONSE_CODES
Public Class Methods
new(options = {})
click to toggle source
Calls superclass method
ActiveMerchant::Billing::Gateway::new
# File lib/active_merchant/billing/gateways/pro_pay.rb, line 136 def initialize(options = {}) requires!(options, :cert_str) super end
Public Instance Methods
capture(money, authorization, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/pro_pay.rb, line 167 def capture(money, authorization, options = {}) request = build_xml_request do |xml| add_invoice(xml, money, options) add_account(xml, options) xml.transNum authorization xml.transType '06' end commit(request) end
credit(money, payment, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/pro_pay.rb, line 193 def credit(money, payment, options = {}) request = build_xml_request do |xml| add_invoice(xml, money, options) add_payment(xml, payment, options) add_account(xml, options) xml.transType '35' end commit(request) end
purchase(money, payment, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/pro_pay.rb, line 141 def purchase(money, payment, options = {}) request = build_xml_request do |xml| add_invoice(xml, money, options) add_payment(xml, payment, options) add_address(xml, options) add_account(xml, options) add_recurring(xml, options) xml.transType '04' end commit(request) end
refund(money, authorization, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/pro_pay.rb, line 178 def refund(money, authorization, options = {}) request = build_xml_request do |xml| add_invoice(xml, money, options) add_account(xml, options) xml.transNum authorization xml.transType '07' end commit(request) end
scrub(transcript)
click to toggle source
# File lib/active_merchant/billing/gateways/pro_pay.rb, line 215 def scrub(transcript) transcript. gsub(%r((<certStr>).+(</certStr>)), '\1[FILTERED]\2'). gsub(%r((<ccNum>).+(</ccNum>)), '\1[FILTERED]\2'). gsub(%r((<CVV2>).+(</CVV2>)), '\1[FILTERED]\2') end
supports_scrubbing?()
click to toggle source
# File lib/active_merchant/billing/gateways/pro_pay.rb, line 211 def supports_scrubbing? true end
verify(credit_card, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/pro_pay.rb, line 204 def verify(credit_card, options = {}) MultiResponse.run(:use_first_response) do |r| r.process { authorize(100, credit_card, options) } r.process(:ignore_result) { void(r.authorization, options) } end end
void(authorization, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/pro_pay.rb, line 189 def void(authorization, options = {}) refund(nil, authorization, options) end
Private Instance Methods
add_account(xml, options)
click to toggle source
# File lib/active_merchant/billing/gateways/pro_pay.rb, line 241 def add_account(xml, options) xml.accountNum options[:account_num] end
add_address(xml, options)
click to toggle source
# File lib/active_merchant/billing/gateways/pro_pay.rb, line 231 def add_address(xml, options) if address = options[:billing_address] || options[:address] xml.addr address[:address1] xml.aptNum address[:address2] xml.city address[:city] xml.state address[:state] xml.zip address[:zip].to_s.delete('-') end end
add_invoice(xml, money, options)
click to toggle source
# File lib/active_merchant/billing/gateways/pro_pay.rb, line 245 def add_invoice(xml, money, options) xml.amount amount(money) xml.currencyCode options[:currency] || currency(money) xml.invNum options[:order_id] || SecureRandom.hex(25) end
add_payment(xml, payment, options)
click to toggle source
# File lib/active_merchant/billing/gateways/pro_pay.rb, line 224 def add_payment(xml, payment, options) xml.ccNum payment.number xml.expDate "#{format(payment.month, :two_digits)}#{format(payment.year, :two_digits)}" xml.CVV2 payment.verification_value xml.cardholderName payment.name end
add_recurring(xml, options)
click to toggle source
# File lib/active_merchant/billing/gateways/pro_pay.rb, line 251 def add_recurring(xml, options) xml.recurringPayment options[:recurring_payment] end
build_xml_request() { |xml| ... }
click to toggle source
# File lib/active_merchant/billing/gateways/pro_pay.rb, line 302 def build_xml_request builder = Nokogiri::XML::Builder.new do |xml| xml.XMLRequest do xml.certStr @options[:cert_str] xml.class_ 'partner' xml.XMLTrans do yield(xml) end end end builder.to_xml end
commit(parameters)
click to toggle source
# File lib/active_merchant/billing/gateways/pro_pay.rb, line 265 def commit(parameters) url = (test? ? test_url : live_url) response = parse(ssl_post(url, parameters)) Response.new( success_from(response), message_from(response), response, authorization: authorization_from(response), avs_result: AVSResult.new(code: response[:avs]), cvv_result: CVVResult.new(response[:cvv2_resp]), test: test?, error_code: error_code_from(response) ) end
error_code_from(response)
click to toggle source
# File lib/active_merchant/billing/gateways/pro_pay.rb, line 298 def error_code_from(response) response[:status] unless success_from(response) end
message_from(response)
click to toggle source
# File lib/active_merchant/billing/gateways/pro_pay.rb, line 285 def message_from(response) return 'Success' if success_from(response) message = STATUS_RESPONSE_CODES[response[:status]] message += " - #{TRANSACTION_RESPONSE_CODES[response[:response_code]]}" if response[:response_code] message end
parse(body)
click to toggle source
# File lib/active_merchant/billing/gateways/pro_pay.rb, line 255 def parse(body) results = {} xml = Nokogiri::XML(body) resp = xml.xpath('//XMLResponse/XMLTrans') resp.children.each do |element| results[element.name.underscore.downcase.to_sym] = element.text end results end
success_from(response)
click to toggle source
# File lib/active_merchant/billing/gateways/pro_pay.rb, line 281 def success_from(response) response[:status] == '00' end