start_activemerchant 1.50.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +1769 -0
- data/CONTRIBUTORS +540 -0
- data/MIT-LICENSE +20 -0
- data/README.md +226 -0
- data/lib/active_merchant.rb +67 -0
- data/lib/active_merchant/billing.rb +15 -0
- data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
- data/lib/active_merchant/billing/avs_result.rb +98 -0
- data/lib/active_merchant/billing/base.rb +72 -0
- data/lib/active_merchant/billing/check.rb +76 -0
- data/lib/active_merchant/billing/compatibility.rb +120 -0
- data/lib/active_merchant/billing/credit_card.rb +404 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +195 -0
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/gateway.rb +291 -0
- data/lib/active_merchant/billing/gateways.rb +14 -0
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +203 -0
- data/lib/active_merchant/billing/gateways/app55.rb +176 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +510 -0
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +976 -0
- data/lib/active_merchant/billing/gateways/axcessms.rb +181 -0
- data/lib/active_merchant/billing/gateways/balanced.rb +256 -0
- data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
- data/lib/active_merchant/billing/gateways/banwire.rb +105 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +314 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
- data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +192 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +389 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +58 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +506 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +140 -0
- data/lib/active_merchant/billing/gateways/borgun.rb +211 -0
- data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +574 -0
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +20 -0
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +189 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +23 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +238 -0
- data/lib/active_merchant/billing/gateways/cashnet.rb +202 -0
- data/lib/active_merchant/billing/gateways/cc5.rb +201 -0
- data/lib/active_merchant/billing/gateways/cecabank.rb +229 -0
- data/lib/active_merchant/billing/gateways/cenpos.rb +262 -0
- data/lib/active_merchant/billing/gateways/certo_direct.rb +278 -0
- data/lib/active_merchant/billing/gateways/checkout.rb +216 -0
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +200 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +143 -0
- data/lib/active_merchant/billing/gateways/conekta.rb +210 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +720 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +600 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +206 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +219 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +348 -0
- data/lib/active_merchant/billing/gateways/epay.rb +274 -0
- data/lib/active_merchant/billing/gateways/evo_ca.rb +308 -0
- data/lib/active_merchant/billing/gateways/eway.rb +214 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +291 -0
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +522 -0
- data/lib/active_merchant/billing/gateways/exact.rb +227 -0
- data/lib/active_merchant/billing/gateways/ezic.rb +206 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +213 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +160 -0
- data/lib/active_merchant/billing/gateways/finansbank.rb +23 -0
- data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +160 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +413 -0
- data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
- data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +261 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +179 -0
- data/lib/active_merchant/billing/gateways/hdfc.rb +207 -0
- data/lib/active_merchant/billing/gateways/hps.rb +287 -0
- data/lib/active_merchant/billing/gateways/iats_payments.rb +277 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +246 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +13 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +29 -0
- data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +66 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +219 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +163 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +175 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +457 -0
- data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +275 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +438 -0
- data/lib/active_merchant/billing/gateways/litle.rb +345 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +197 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +170 -0
- data/lib/active_merchant/billing/gateways/merchant_one.rb +114 -0
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +319 -0
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +268 -0
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +195 -0
- data/lib/active_merchant/billing/gateways/mercury.rb +326 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +303 -0
- data/lib/active_merchant/billing/gateways/migs.rb +280 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +219 -0
- data/lib/active_merchant/billing/gateways/monei.rb +307 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +309 -0
- data/lib/active_merchant/billing/gateways/moneris_us.rb +298 -0
- data/lib/active_merchant/billing/gateways/money_movers.rb +152 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +290 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +198 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +181 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +224 -0
- data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
- data/lib/active_merchant/billing/gateways/network_merchants.rb +242 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +256 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +435 -0
- data/lib/active_merchant/billing/gateways/omise.rb +319 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +194 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +314 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +834 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +47 -0
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +207 -0
- data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
- data/lib/active_merchant/billing/gateways/pay_conex.rb +246 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +277 -0
- data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +112 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +188 -0
- data/lib/active_merchant/billing/gateways/payex.rb +412 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +308 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +220 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +224 -0
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +15 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +21 -0
- data/lib/active_merchant/billing/gateways/payment_express.rb +353 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +282 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +129 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +679 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +65 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +264 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +162 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +199 -0
- data/lib/active_merchant/billing/gateways/payu_in.rb +247 -0
- data/lib/active_merchant/billing/gateways/payway.rb +207 -0
- data/lib/active_merchant/billing/gateways/pin.rb +207 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +216 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +303 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +292 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +276 -0
- data/lib/active_merchant/billing/gateways/quickbooks.rb +280 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +26 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +188 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +240 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +227 -0
- data/lib/active_merchant/billing/gateways/qvalent.rb +179 -0
- data/lib/active_merchant/billing/gateways/realex.rb +298 -0
- data/lib/active_merchant/billing/gateways/redsys.rb +406 -0
- data/lib/active_merchant/billing/gateways/s5.rb +226 -0
- data/lib/active_merchant/billing/gateways/sage.rb +173 -0
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +89 -0
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +115 -0
- data/lib/active_merchant/billing/gateways/sage/sage_vault.rb +149 -0
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +399 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +143 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +263 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +201 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +281 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +105 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +451 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +283 -0
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +247 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +489 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +157 -0
- data/lib/active_merchant/billing/gateways/tns.rb +227 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +126 -0
- data/lib/active_merchant/billing/gateways/transax.rb +23 -0
- data/lib/active_merchant/billing/gateways/transnational.rb +10 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +416 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1516 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +259 -0
- data/lib/active_merchant/billing/gateways/vanco.rb +280 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +225 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +183 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
- data/lib/active_merchant/billing/gateways/wepay.rb +205 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +420 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +331 -0
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +204 -0
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +181 -0
- data/lib/active_merchant/billing/model.rb +30 -0
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +24 -0
- data/lib/active_merchant/billing/payment_token.rb +21 -0
- data/lib/active_merchant/billing/rails.rb +3 -0
- data/lib/active_merchant/billing/response.rb +92 -0
- data/lib/active_merchant/connection.rb +172 -0
- data/lib/active_merchant/country.rb +332 -0
- data/lib/active_merchant/empty.rb +20 -0
- data/lib/active_merchant/errors.rb +35 -0
- data/lib/active_merchant/network_connection_retries.rb +79 -0
- data/lib/active_merchant/post_data.rb +24 -0
- data/lib/active_merchant/posts_data.rb +84 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/certs/cacert.pem +3866 -0
- data/lib/support/gateway_support.rb +71 -0
- data/lib/support/outbound_hosts.rb +28 -0
- data/lib/support/ssl_verify.rb +93 -0
- metadata +387 -0
@@ -0,0 +1,438 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
|
6
|
+
# Initialization Options
|
7
|
+
# :login Your store number
|
8
|
+
# :pem The text of your linkpoint PEM file. Note
|
9
|
+
# this is not the path to file, but its
|
10
|
+
# contents. If you are only using one PEM
|
11
|
+
# file on your site you can declare it
|
12
|
+
# globally and then you won't need to
|
13
|
+
# include this option
|
14
|
+
#
|
15
|
+
#
|
16
|
+
# A valid store number is required. Unfortunately, with LinkPoint
|
17
|
+
# YOU CAN'T JUST USE ANY OLD STORE NUMBER. Also, you can't just
|
18
|
+
# generate your own PEM file. You'll need to use a special PEM file
|
19
|
+
# provided by LinkPoint.
|
20
|
+
#
|
21
|
+
# Go to http://www.linkpoint.com/support/sup_teststore.asp to set up
|
22
|
+
# a test account and obtain your PEM file.
|
23
|
+
#
|
24
|
+
# Declaring PEM file Globally
|
25
|
+
# ActiveMerchant::Billing::LinkpointGateway.pem_file = File.read( File.dirname(__FILE__) + '/../mycert.pem' )
|
26
|
+
#
|
27
|
+
#
|
28
|
+
# Valid Order Options
|
29
|
+
# :result =>
|
30
|
+
# LIVE Production mode
|
31
|
+
# GOOD Approved response in test mode
|
32
|
+
# DECLINE Declined response in test mode
|
33
|
+
# DUPLICATE Duplicate response in test mode
|
34
|
+
#
|
35
|
+
# :ponumber Order number
|
36
|
+
#
|
37
|
+
# :transactionorigin => Source of the transaction
|
38
|
+
# ECI Email or Internet
|
39
|
+
# MAIL Mail order
|
40
|
+
# MOTO Mail order/Telephone
|
41
|
+
# TELEPHONE Telephone
|
42
|
+
# RETAIL Face-to-face
|
43
|
+
#
|
44
|
+
# :ordertype =>
|
45
|
+
# SALE Real live sale
|
46
|
+
# PREAUTH Authorize only
|
47
|
+
# POSTAUTH Forced Ticket or Ticket Only transaction
|
48
|
+
# VOID
|
49
|
+
# CREDIT
|
50
|
+
# CALCSHIPPING For shipping charges calculations
|
51
|
+
# CALCTAX For sales tax calculations
|
52
|
+
#
|
53
|
+
# Recurring Options
|
54
|
+
# :action =>
|
55
|
+
# SUBMIT
|
56
|
+
# MODIFY
|
57
|
+
# CANCEL
|
58
|
+
#
|
59
|
+
# :installments Identifies how many recurring payments to charge the customer
|
60
|
+
# :startdate Date to begin charging the recurring payments. Format: YYYYMMDD or "immediate"
|
61
|
+
# :periodicity =>
|
62
|
+
# MONTHLY
|
63
|
+
# BIMONTHLY
|
64
|
+
# WEEKLY
|
65
|
+
# BIWEEKLY
|
66
|
+
# YEARLY
|
67
|
+
# DAILY
|
68
|
+
# :threshold Tells how many times to retry the transaction (if it fails) before contacting the merchant.
|
69
|
+
# :comments Uh... comments
|
70
|
+
#
|
71
|
+
#
|
72
|
+
# For reference:
|
73
|
+
#
|
74
|
+
# https://www.linkpointcentral.com/lpc/docs/Help/APIHelp/lpintguide.htm
|
75
|
+
#
|
76
|
+
# Entities = {
|
77
|
+
# :payment => [:subtotal, :tax, :vattax, :shipping, :chargetotal],
|
78
|
+
# :billing => [:name, :address1, :address2, :city, :state, :zip, :country, :email, :phone, :fax, :addrnum],
|
79
|
+
# :shipping => [:name, :address1, :address2, :city, :state, :zip, :country, :weight, :items, :carrier, :total],
|
80
|
+
# :creditcard => [:cardnumber, :cardexpmonth, :cardexpyear, :cvmvalue, :track],
|
81
|
+
# :telecheck => [:routing, :account, :checknumber, :bankname, :bankstate, :dl, :dlstate, :void, :accounttype, :ssn],
|
82
|
+
# :transactiondetails => [:transactionorigin, :oid, :ponumber, :taxexempt, :terminaltype, :ip, :reference_number, :recurring, :tdate],
|
83
|
+
# :periodic => [:action, :installments, :threshold, :startdate, :periodicity, :comments],
|
84
|
+
# :notes => [:comments, :referred]
|
85
|
+
# :items => [:item => [:price, :quantity, :description, :id, :options => [:option => [:name, :value]]]]
|
86
|
+
# }
|
87
|
+
#
|
88
|
+
#
|
89
|
+
# LinkPoint's Items entity is an optional entity that can be attached to orders.
|
90
|
+
# It is entered as :line_items to be consistent with the CyberSource implementation
|
91
|
+
#
|
92
|
+
# The line_item hash goes in the options hash and should look like
|
93
|
+
#
|
94
|
+
# :line_items => [
|
95
|
+
# {
|
96
|
+
# :id => '123456',
|
97
|
+
# :description => 'Logo T-Shirt',
|
98
|
+
# :price => '12.00',
|
99
|
+
# :quantity => '1',
|
100
|
+
# :options => [
|
101
|
+
# {
|
102
|
+
# :name => 'Color',
|
103
|
+
# :value => 'Red'
|
104
|
+
# },
|
105
|
+
# {
|
106
|
+
# :name => 'Size',
|
107
|
+
# :value => 'XL'
|
108
|
+
# }
|
109
|
+
# ]
|
110
|
+
# },
|
111
|
+
# {
|
112
|
+
# :id => '111',
|
113
|
+
# :description => 'keychain',
|
114
|
+
# :price => '3.00',
|
115
|
+
# :quantity => '1'
|
116
|
+
# }
|
117
|
+
# ]
|
118
|
+
# This functionality is only supported by this particular gateway may
|
119
|
+
# be changed at any time
|
120
|
+
#
|
121
|
+
class LinkpointGateway < Gateway
|
122
|
+
# Your global PEM file. This will be assigned to you by linkpoint
|
123
|
+
#
|
124
|
+
# Example:
|
125
|
+
#
|
126
|
+
# ActiveMerchant::Billing::LinkpointGateway.pem_file = File.read( File.dirname(__FILE__) + '/../mycert.pem' )
|
127
|
+
#
|
128
|
+
cattr_accessor :pem_file
|
129
|
+
|
130
|
+
self.test_url = 'https://staging.linkpt.net:1129/'
|
131
|
+
self.live_url = 'https://secure.linkpt.net:1129/'
|
132
|
+
|
133
|
+
self.supported_countries = ['US']
|
134
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club]
|
135
|
+
self.homepage_url = 'http://www.linkpoint.com/'
|
136
|
+
self.display_name = 'LinkPoint'
|
137
|
+
|
138
|
+
def initialize(options = {})
|
139
|
+
requires!(options, :login)
|
140
|
+
|
141
|
+
@options = {
|
142
|
+
:result => 'LIVE',
|
143
|
+
:pem => LinkpointGateway.pem_file
|
144
|
+
}.update(options)
|
145
|
+
|
146
|
+
raise ArgumentError, "You need to pass in your pem file using the :pem parameter or set it globally using ActiveMerchant::Billing::LinkpointGateway.pem_file = File.read( File.dirname(__FILE__) + '/../mycert.pem' ) or similar" if @options[:pem].blank?
|
147
|
+
end
|
148
|
+
|
149
|
+
# Send a purchase request with periodic options
|
150
|
+
# Recurring Options
|
151
|
+
# :action =>
|
152
|
+
# SUBMIT
|
153
|
+
# MODIFY
|
154
|
+
# CANCEL
|
155
|
+
#
|
156
|
+
# :installments Identifies how many recurring payments to charge the customer
|
157
|
+
# :startdate Date to begin charging the recurring payments. Format: YYYYMMDD or "immediate"
|
158
|
+
# :periodicity =>
|
159
|
+
# :monthly
|
160
|
+
# :bimonthly
|
161
|
+
# :weekly
|
162
|
+
# :biweekly
|
163
|
+
# :yearly
|
164
|
+
# :daily
|
165
|
+
# :threshold Tells how many times to retry the transaction (if it fails) before contacting the merchant.
|
166
|
+
# :comments Uh... comments
|
167
|
+
#
|
168
|
+
def recurring(money, creditcard, options={})
|
169
|
+
ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE
|
170
|
+
|
171
|
+
requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily], :installments, :order_id )
|
172
|
+
|
173
|
+
options.update(
|
174
|
+
:ordertype => "SALE",
|
175
|
+
:action => options[:action] || "SUBMIT",
|
176
|
+
:installments => options[:installments] || 12,
|
177
|
+
:startdate => options[:startdate] || "immediate",
|
178
|
+
:periodicity => options[:periodicity].to_s || "monthly",
|
179
|
+
:comments => options[:comments] || nil,
|
180
|
+
:threshold => options[:threshold] || 3
|
181
|
+
)
|
182
|
+
commit(money, creditcard, options)
|
183
|
+
end
|
184
|
+
|
185
|
+
# Buy the thing
|
186
|
+
def purchase(money, creditcard, options={})
|
187
|
+
requires!(options, :order_id)
|
188
|
+
options.update(
|
189
|
+
:ordertype => "SALE"
|
190
|
+
)
|
191
|
+
commit(money, creditcard, options)
|
192
|
+
end
|
193
|
+
|
194
|
+
#
|
195
|
+
# Authorize the transaction
|
196
|
+
#
|
197
|
+
# Reserves the funds on the customer's credit card, but does not charge the card.
|
198
|
+
#
|
199
|
+
def authorize(money, creditcard, options = {})
|
200
|
+
requires!(options, :order_id)
|
201
|
+
options.update(
|
202
|
+
:ordertype => "PREAUTH"
|
203
|
+
)
|
204
|
+
commit(money, creditcard, options)
|
205
|
+
end
|
206
|
+
|
207
|
+
#
|
208
|
+
# Post an authorization.
|
209
|
+
#
|
210
|
+
# Captures the funds from an authorized transaction.
|
211
|
+
# Order_id must be a valid order id from a prior authorized transaction.
|
212
|
+
#
|
213
|
+
def capture(money, authorization, options = {})
|
214
|
+
options.update(
|
215
|
+
:order_id => authorization,
|
216
|
+
:ordertype => "POSTAUTH"
|
217
|
+
)
|
218
|
+
commit(money, nil, options)
|
219
|
+
end
|
220
|
+
|
221
|
+
# Void a previous transaction
|
222
|
+
def void(identification, options = {})
|
223
|
+
options.update(
|
224
|
+
:order_id => identification,
|
225
|
+
:ordertype => "VOID"
|
226
|
+
)
|
227
|
+
commit(nil, nil, options)
|
228
|
+
end
|
229
|
+
|
230
|
+
#
|
231
|
+
# Refund an order
|
232
|
+
#
|
233
|
+
# identification must be a valid order id previously submitted by SALE
|
234
|
+
#
|
235
|
+
def refund(money, identification, options = {})
|
236
|
+
options.update(
|
237
|
+
:ordertype => "CREDIT",
|
238
|
+
:order_id => identification
|
239
|
+
)
|
240
|
+
commit(money, nil, options)
|
241
|
+
end
|
242
|
+
|
243
|
+
def credit(money, identification, options = {})
|
244
|
+
ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
|
245
|
+
refund(money, identification, options)
|
246
|
+
end
|
247
|
+
|
248
|
+
private
|
249
|
+
# Commit the transaction by posting the XML file to the LinkPoint server
|
250
|
+
def commit(money, creditcard, options = {})
|
251
|
+
response = parse(ssl_post(test? ? self.test_url : self.live_url, post_data(money, creditcard, options)))
|
252
|
+
|
253
|
+
Response.new(successful?(response), response[:message], response,
|
254
|
+
:test => test?,
|
255
|
+
:authorization => response[:ordernum],
|
256
|
+
:avs_result => { :code => response[:avs].to_s[2,1] },
|
257
|
+
:cvv_result => response[:avs].to_s[3,1]
|
258
|
+
)
|
259
|
+
end
|
260
|
+
|
261
|
+
def successful?(response)
|
262
|
+
response[:approved] == "APPROVED"
|
263
|
+
end
|
264
|
+
|
265
|
+
# Build the XML file
|
266
|
+
def post_data(money, creditcard, options)
|
267
|
+
params = parameters(money, creditcard, options)
|
268
|
+
|
269
|
+
xml = REXML::Document.new
|
270
|
+
order = xml.add_element("order")
|
271
|
+
|
272
|
+
# Merchant Info
|
273
|
+
merchantinfo = order.add_element("merchantinfo")
|
274
|
+
merchantinfo.add_element("configfile").text = @options[:login]
|
275
|
+
|
276
|
+
# Loop over the params hash to construct the XML string
|
277
|
+
for key, value in params
|
278
|
+
elem = order.add_element(key.to_s)
|
279
|
+
if key == :items
|
280
|
+
build_items(elem, value)
|
281
|
+
else
|
282
|
+
for k, _ in params[key]
|
283
|
+
elem.add_element(k.to_s).text = params[key][k].to_s if params[key][k]
|
284
|
+
end
|
285
|
+
end
|
286
|
+
# Linkpoint doesn't understand empty elements:
|
287
|
+
order.delete(elem) if elem.size == 0
|
288
|
+
end
|
289
|
+
return xml.to_s
|
290
|
+
end
|
291
|
+
|
292
|
+
# adds LinkPoint's Items entity to the XML. Called from post_data
|
293
|
+
def build_items(element, items)
|
294
|
+
for item in items
|
295
|
+
item_element = element.add_element("item")
|
296
|
+
for key, value in item
|
297
|
+
if key == :options
|
298
|
+
options_element = item_element.add_element("options")
|
299
|
+
for option in value
|
300
|
+
opt_element = options_element.add_element("option")
|
301
|
+
opt_element.add_element("name").text = option[:name] unless option[:name].blank?
|
302
|
+
opt_element.add_element("value").text = option[:value] unless option[:value].blank?
|
303
|
+
end
|
304
|
+
else
|
305
|
+
item_element.add_element(key.to_s).text = item[key].to_s unless item[key].blank?
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
# Set up the parameters hash just once so we don't have to do it
|
312
|
+
# for every action.
|
313
|
+
def parameters(money, creditcard, options = {})
|
314
|
+
|
315
|
+
params = {
|
316
|
+
:payment => {
|
317
|
+
:subtotal => amount(options[:subtotal]),
|
318
|
+
:tax => amount(options[:tax]),
|
319
|
+
:vattax => amount(options[:vattax]),
|
320
|
+
:shipping => amount(options[:shipping]),
|
321
|
+
:chargetotal => amount(money)
|
322
|
+
},
|
323
|
+
:transactiondetails => {
|
324
|
+
:transactionorigin => options[:transactionorigin] || "ECI",
|
325
|
+
:oid => options[:order_id],
|
326
|
+
:ponumber => options[:ponumber],
|
327
|
+
:taxexempt => options[:taxexempt],
|
328
|
+
:terminaltype => options[:terminaltype],
|
329
|
+
:ip => options[:ip],
|
330
|
+
:reference_number => options[:reference_number],
|
331
|
+
:recurring => options[:recurring] || "NO", #DO NOT USE if you are using the periodic billing option.
|
332
|
+
:tdate => options[:tdate]
|
333
|
+
},
|
334
|
+
:orderoptions => {
|
335
|
+
:ordertype => options[:ordertype],
|
336
|
+
:result => @options[:result]
|
337
|
+
},
|
338
|
+
:periodic => {
|
339
|
+
:action => options[:action],
|
340
|
+
:installments => options[:installments],
|
341
|
+
:threshold => options[:threshold],
|
342
|
+
:startdate => options[:startdate],
|
343
|
+
:periodicity => options[:periodicity],
|
344
|
+
:comments => options[:comments]
|
345
|
+
},
|
346
|
+
:telecheck => {
|
347
|
+
:routing => options[:telecheck_routing],
|
348
|
+
:account => options[:telecheck_account],
|
349
|
+
:checknumber => options[:telecheck_checknumber],
|
350
|
+
:bankname => options[:telecheck_bankname],
|
351
|
+
:dl => options[:telecheck_dl],
|
352
|
+
:dlstate => options[:telecheck_dlstate],
|
353
|
+
:void => options[:telecheck_void],
|
354
|
+
:accounttype => options[:telecheck_accounttype],
|
355
|
+
:ssn => options[:telecheck_ssn],
|
356
|
+
}
|
357
|
+
}
|
358
|
+
|
359
|
+
if creditcard
|
360
|
+
params[:creditcard] = {
|
361
|
+
:cardnumber => creditcard.number,
|
362
|
+
:cardexpmonth => creditcard.month,
|
363
|
+
:cardexpyear => format_creditcard_expiry_year(creditcard.year),
|
364
|
+
:track => nil
|
365
|
+
}
|
366
|
+
|
367
|
+
if creditcard.verification_value?
|
368
|
+
params[:creditcard][:cvmvalue] = creditcard.verification_value
|
369
|
+
params[:creditcard][:cvmindicator] = 'provided'
|
370
|
+
else
|
371
|
+
params[:creditcard][:cvmindicator] = 'not_provided'
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
if billing_address = options[:billing_address] || options[:address]
|
376
|
+
|
377
|
+
params[:billing] = {}
|
378
|
+
params[:billing][:name] = billing_address[:name] || (creditcard ? creditcard.name : nil)
|
379
|
+
params[:billing][:address1] = billing_address[:address1] unless billing_address[:address1].blank?
|
380
|
+
params[:billing][:address2] = billing_address[:address2] unless billing_address[:address2].blank?
|
381
|
+
params[:billing][:city] = billing_address[:city] unless billing_address[:city].blank?
|
382
|
+
params[:billing][:state] = billing_address[:state] unless billing_address[:state].blank?
|
383
|
+
params[:billing][:zip] = billing_address[:zip] unless billing_address[:zip].blank?
|
384
|
+
params[:billing][:country] = billing_address[:country] unless billing_address[:country].blank?
|
385
|
+
params[:billing][:company] = billing_address[:company] unless billing_address[:company].blank?
|
386
|
+
params[:billing][:phone] = billing_address[:phone] unless billing_address[:phone].blank?
|
387
|
+
params[:billing][:email] = options[:email] unless options[:email].blank?
|
388
|
+
end
|
389
|
+
|
390
|
+
if shipping_address = options[:shipping_address]
|
391
|
+
|
392
|
+
params[:shipping] = {}
|
393
|
+
params[:shipping][:name] = shipping_address[:name] || (creditcard ? creditcard.name : nil)
|
394
|
+
params[:shipping][:address1] = shipping_address[:address1] unless shipping_address[:address1].blank?
|
395
|
+
params[:shipping][:address2] = shipping_address[:address2] unless shipping_address[:address2].blank?
|
396
|
+
params[:shipping][:city] = shipping_address[:city] unless shipping_address[:city].blank?
|
397
|
+
params[:shipping][:state] = shipping_address[:state] unless shipping_address[:state].blank?
|
398
|
+
params[:shipping][:zip] = shipping_address[:zip] unless shipping_address[:zip].blank?
|
399
|
+
params[:shipping][:country] = shipping_address[:country] unless shipping_address[:country].blank?
|
400
|
+
end
|
401
|
+
|
402
|
+
params[:items] = options[:line_items] if options[:line_items]
|
403
|
+
|
404
|
+
return params
|
405
|
+
end
|
406
|
+
|
407
|
+
def parse(xml)
|
408
|
+
|
409
|
+
# For reference, a typical response...
|
410
|
+
# <r_csp></r_csp>
|
411
|
+
# <r_time></r_time>
|
412
|
+
# <r_ref></r_ref>
|
413
|
+
# <r_error></r_error>
|
414
|
+
# <r_ordernum></r_ordernum>
|
415
|
+
# <r_message>This is a test transaction and will not show up in the Reports</r_message>
|
416
|
+
# <r_code></r_code>
|
417
|
+
# <r_tdate>Thu Feb 2 15:40:21 2006</r_tdate>
|
418
|
+
# <r_score></r_score>
|
419
|
+
# <r_authresponse></r_authresponse>
|
420
|
+
# <r_approved>APPROVED</r_approved>
|
421
|
+
# <r_avs></r_avs>
|
422
|
+
|
423
|
+
response = {:message => "Global Error Receipt", :complete => false}
|
424
|
+
|
425
|
+
xml = REXML::Document.new("<response>#{xml}</response>")
|
426
|
+
xml.root.elements.each do |node|
|
427
|
+
response[node.name.downcase.sub(/^r_/, '').to_sym] = normalize(node.text)
|
428
|
+
end unless xml.root.nil?
|
429
|
+
|
430
|
+
response
|
431
|
+
end
|
432
|
+
|
433
|
+
def format_creditcard_expiry_year(year)
|
434
|
+
sprintf("%.4i", year)[-2..-1]
|
435
|
+
end
|
436
|
+
end
|
437
|
+
end
|
438
|
+
end
|
@@ -0,0 +1,345 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class LitleGateway < Gateway
|
6
|
+
SCHEMA_VERSION = '8.18'
|
7
|
+
|
8
|
+
self.test_url = 'https://www.testlitle.com/sandbox/communicator/online'
|
9
|
+
self.live_url = 'https://payments.litle.com/vap/communicator/online'
|
10
|
+
|
11
|
+
self.supported_countries = ['US']
|
12
|
+
self.default_currency = 'USD'
|
13
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
|
14
|
+
|
15
|
+
self.homepage_url = 'http://www.litle.com/'
|
16
|
+
self.display_name = 'Litle & Co.'
|
17
|
+
|
18
|
+
# Public: Create a new Litle gateway.
|
19
|
+
#
|
20
|
+
# options - A hash of options:
|
21
|
+
# :login - The user.
|
22
|
+
# :password - The password.
|
23
|
+
# :merchant_id - The merchant id.
|
24
|
+
def initialize(options={})
|
25
|
+
requires!(options, :login, :password, :merchant_id)
|
26
|
+
super
|
27
|
+
end
|
28
|
+
|
29
|
+
def purchase(money, payment_method, options={})
|
30
|
+
request = build_xml_request do |doc|
|
31
|
+
add_authentication(doc)
|
32
|
+
doc.sale(transaction_attributes(options)) do
|
33
|
+
add_auth_purchase_params(doc, money, payment_method, options)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
commit(:sale, request)
|
38
|
+
end
|
39
|
+
|
40
|
+
def authorize(money, payment_method, options={})
|
41
|
+
request = build_xml_request do |doc|
|
42
|
+
add_authentication(doc)
|
43
|
+
doc.authorization(transaction_attributes(options)) do
|
44
|
+
add_auth_purchase_params(doc, money, payment_method, options)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
commit(:authorization, request)
|
49
|
+
end
|
50
|
+
|
51
|
+
def capture(money, authorization, options={})
|
52
|
+
transaction_id, _ = split_authorization(authorization)
|
53
|
+
|
54
|
+
request = build_xml_request do |doc|
|
55
|
+
add_authentication(doc)
|
56
|
+
add_descriptor(doc, options)
|
57
|
+
doc.capture_(transaction_attributes(options)) do
|
58
|
+
doc.litleTxnId(transaction_id)
|
59
|
+
doc.amount(money) if money
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
commit(:capture, request)
|
64
|
+
end
|
65
|
+
|
66
|
+
def credit(money, authorization, options = {})
|
67
|
+
ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
|
68
|
+
refund(money, authorization, options)
|
69
|
+
end
|
70
|
+
|
71
|
+
def refund(money, authorization, options={})
|
72
|
+
transaction_id, _ = split_authorization(authorization)
|
73
|
+
|
74
|
+
request = build_xml_request do |doc|
|
75
|
+
add_authentication(doc)
|
76
|
+
add_descriptor(doc, options)
|
77
|
+
doc.credit(transaction_attributes(options)) do
|
78
|
+
doc.litleTxnId(transaction_id)
|
79
|
+
doc.amount(money) if money
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
commit(:credit, request)
|
84
|
+
end
|
85
|
+
|
86
|
+
def verify(creditcard, options = {})
|
87
|
+
MultiResponse.run(:use_first_response) do |r|
|
88
|
+
r.process { authorize(0, creditcard, options) }
|
89
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def void(authorization, options={})
|
94
|
+
transaction_id, kind = split_authorization(authorization)
|
95
|
+
|
96
|
+
request = build_xml_request do |doc|
|
97
|
+
add_authentication(doc)
|
98
|
+
doc.send(void_type(kind), transaction_attributes(options)) do
|
99
|
+
doc.litleTxnId(transaction_id)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
commit(void_type(kind), request)
|
104
|
+
end
|
105
|
+
|
106
|
+
def store(creditcard, options = {})
|
107
|
+
request = build_xml_request do |doc|
|
108
|
+
add_authentication(doc)
|
109
|
+
doc.registerTokenRequest(transaction_attributes(options)) do
|
110
|
+
doc.orderId(truncate(options[:order_id], 24))
|
111
|
+
doc.accountNumber(creditcard.number)
|
112
|
+
doc.cardValidationNum(creditcard.verification_value) if creditcard.verification_value
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
commit(:registerToken, request)
|
117
|
+
end
|
118
|
+
|
119
|
+
private
|
120
|
+
CARD_TYPE = {
|
121
|
+
'visa' => 'VI',
|
122
|
+
'master' => 'MC',
|
123
|
+
'american_express' => 'AX',
|
124
|
+
'discover' => 'DI',
|
125
|
+
'jcb' => 'JC',
|
126
|
+
'diners_club' => 'DC'
|
127
|
+
}
|
128
|
+
|
129
|
+
AVS_RESPONSE_CODE = {
|
130
|
+
'00' => 'Y',
|
131
|
+
'01' => 'X',
|
132
|
+
'02' => 'D',
|
133
|
+
'10' => 'Z',
|
134
|
+
'11' => 'W',
|
135
|
+
'12' => 'A',
|
136
|
+
'13' => 'A',
|
137
|
+
'14' => 'P',
|
138
|
+
'20' => 'N',
|
139
|
+
'30' => 'S',
|
140
|
+
'31' => 'R',
|
141
|
+
'32' => 'U',
|
142
|
+
'33' => 'R',
|
143
|
+
'34' => 'I',
|
144
|
+
'40' => 'E'
|
145
|
+
}
|
146
|
+
|
147
|
+
def void_type(kind)
|
148
|
+
(kind == 'authorization') ? :authReversal : :void
|
149
|
+
end
|
150
|
+
|
151
|
+
def add_authentication(doc)
|
152
|
+
doc.authentication do
|
153
|
+
doc.user(@options[:login])
|
154
|
+
doc.password(@options[:password])
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def add_auth_purchase_params(doc, money, payment_method, options)
|
159
|
+
doc.orderId(truncate(options[:order_id], 24))
|
160
|
+
doc.amount(money)
|
161
|
+
add_order_source(doc, payment_method, options)
|
162
|
+
add_billing_address(doc, payment_method, options)
|
163
|
+
add_shipping_address(doc, payment_method, options)
|
164
|
+
add_payment_method(doc, payment_method)
|
165
|
+
add_pos(doc, payment_method)
|
166
|
+
add_descriptor(doc, options)
|
167
|
+
add_debt_repayment(doc, options)
|
168
|
+
end
|
169
|
+
|
170
|
+
def add_descriptor(doc, options)
|
171
|
+
if options[:descriptor_name] || options[:descriptor_phone]
|
172
|
+
doc.customBilling do
|
173
|
+
doc.phone(options[:descriptor_phone]) if options[:descriptor_phone]
|
174
|
+
doc.descriptor(options[:descriptor_name]) if options[:descriptor_name]
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def add_debt_repayment(doc, options)
|
180
|
+
doc.debtRepayment(true) if options[:debt_repayment] == true
|
181
|
+
end
|
182
|
+
|
183
|
+
def add_payment_method(doc, payment_method)
|
184
|
+
if payment_method.is_a?(String)
|
185
|
+
doc.token do
|
186
|
+
doc.litleToken(payment_method)
|
187
|
+
end
|
188
|
+
elsif payment_method.respond_to?(:track_data) && payment_method.track_data.present?
|
189
|
+
doc.card do
|
190
|
+
doc.track(payment_method.track_data)
|
191
|
+
end
|
192
|
+
else
|
193
|
+
doc.card do
|
194
|
+
doc.type_(CARD_TYPE[payment_method.brand])
|
195
|
+
doc.number(payment_method.number)
|
196
|
+
doc.expDate(exp_date(payment_method))
|
197
|
+
doc.cardValidationNum(payment_method.verification_value)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
def add_billing_address(doc, payment_method, options)
|
203
|
+
return if payment_method.is_a?(String)
|
204
|
+
|
205
|
+
doc.billToAddress do
|
206
|
+
doc.name(payment_method.name)
|
207
|
+
doc.email(options[:email]) if options[:email]
|
208
|
+
|
209
|
+
add_address(doc, options[:billing_address])
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
def add_shipping_address(doc, payment_method, options)
|
214
|
+
return if payment_method.is_a?(String)
|
215
|
+
|
216
|
+
doc.shipToAddress do
|
217
|
+
add_address(doc, options[:shipping_address])
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
def add_address(doc, address)
|
222
|
+
return unless address
|
223
|
+
|
224
|
+
doc.companyName(address[:company]) unless address[:company].blank?
|
225
|
+
doc.addressLine1(address[:address1]) unless address[:address1].blank?
|
226
|
+
doc.addressLine2(address[:address2]) unless address[:address2].blank?
|
227
|
+
doc.city(address[:city]) unless address[:city].blank?
|
228
|
+
doc.state(address[:state]) unless address[:state].blank?
|
229
|
+
doc.zip(address[:zip]) unless address[:zip].blank?
|
230
|
+
doc.country(address[:country]) unless address[:country].blank?
|
231
|
+
doc.phone(address[:phone]) unless address[:phone].blank?
|
232
|
+
end
|
233
|
+
|
234
|
+
def add_order_source(doc, payment_method, options)
|
235
|
+
if options[:order_source]
|
236
|
+
doc.orderSource(options[:order_source])
|
237
|
+
elsif payment_method.respond_to?(:track_data) && payment_method.track_data.present?
|
238
|
+
doc.orderSource('retail')
|
239
|
+
else
|
240
|
+
doc.orderSource('ecommerce')
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
def add_pos(doc, payment_method)
|
245
|
+
return unless payment_method.respond_to?(:track_data) && payment_method.track_data.present?
|
246
|
+
|
247
|
+
doc.pos do
|
248
|
+
doc.capability('magstripe')
|
249
|
+
doc.entryMode('completeread')
|
250
|
+
doc.cardholderId('signature')
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
def exp_date(payment_method)
|
255
|
+
"#{format(payment_method.month, :two_digits)}#{format(payment_method.year, :two_digits)}"
|
256
|
+
end
|
257
|
+
|
258
|
+
def parse(kind, xml)
|
259
|
+
parsed = {}
|
260
|
+
|
261
|
+
doc = Nokogiri::XML(xml).remove_namespaces!
|
262
|
+
doc.xpath("//litleOnlineResponse/#{kind}Response/*").each do |node|
|
263
|
+
if (node.elements.empty?)
|
264
|
+
parsed[node.name.to_sym] = node.text
|
265
|
+
else
|
266
|
+
node.elements.each do |childnode|
|
267
|
+
name = "#{node.name}_#{childnode.name}"
|
268
|
+
parsed[name.to_sym] = childnode.text
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
if parsed.empty?
|
274
|
+
%w(response message).each do |attribute|
|
275
|
+
parsed[attribute.to_sym] = doc.xpath("//litleOnlineResponse").attribute(attribute).value
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
parsed
|
280
|
+
end
|
281
|
+
|
282
|
+
def commit(kind, request)
|
283
|
+
parsed = parse(kind, ssl_post(url, request, headers))
|
284
|
+
|
285
|
+
options = {
|
286
|
+
authorization: authorization_from(kind, parsed),
|
287
|
+
test: test?,
|
288
|
+
:avs_result => { :code => AVS_RESPONSE_CODE[parsed[:fraudResult_avsResult]] },
|
289
|
+
:cvv_result => parsed[:fraudResult_cardValidationResult]
|
290
|
+
}
|
291
|
+
|
292
|
+
Response.new(success_from(kind, parsed), parsed[:message], parsed, options)
|
293
|
+
end
|
294
|
+
|
295
|
+
def success_from(kind, parsed)
|
296
|
+
return (parsed[:response] == '000') unless kind == :registerToken
|
297
|
+
%w(000 801 802).include?(parsed[:response])
|
298
|
+
end
|
299
|
+
|
300
|
+
def authorization_from(kind, parsed)
|
301
|
+
(kind == :registerToken) ? parsed[:litleToken] : "#{parsed[:litleTxnId]};#{kind}"
|
302
|
+
end
|
303
|
+
|
304
|
+
def split_authorization(authorization)
|
305
|
+
transaction_id, kind = authorization.to_s.split(';')
|
306
|
+
[transaction_id, kind]
|
307
|
+
end
|
308
|
+
|
309
|
+
def transaction_attributes(options)
|
310
|
+
attributes = {}
|
311
|
+
attributes[:id] = truncate(options[:id] || options[:order_id], 24)
|
312
|
+
attributes[:reportGroup] = options[:merchant] || 'Default Report Group'
|
313
|
+
attributes[:customerId] = options[:customer]
|
314
|
+
attributes.delete_if { |key, value| value == nil }
|
315
|
+
attributes
|
316
|
+
end
|
317
|
+
|
318
|
+
def root_attributes
|
319
|
+
{
|
320
|
+
merchantId: @options[:merchant_id],
|
321
|
+
version: SCHEMA_VERSION,
|
322
|
+
xmlns: "http://www.litle.com/schema"
|
323
|
+
}
|
324
|
+
end
|
325
|
+
|
326
|
+
def build_xml_request
|
327
|
+
builder = Nokogiri::XML::Builder.new
|
328
|
+
builder.__send__('litleOnlineRequest', root_attributes) do |doc|
|
329
|
+
yield(doc)
|
330
|
+
end
|
331
|
+
builder.doc.root.to_xml
|
332
|
+
end
|
333
|
+
|
334
|
+
def url
|
335
|
+
test? ? test_url : live_url
|
336
|
+
end
|
337
|
+
|
338
|
+
def headers
|
339
|
+
{
|
340
|
+
'Content-Type' => 'text/xml'
|
341
|
+
}
|
342
|
+
end
|
343
|
+
end
|
344
|
+
end
|
345
|
+
end
|