start_activemerchant 1.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,173 @@
|
|
|
1
|
+
require 'active_merchant/billing/gateways/sage/sage_bankcard'
|
|
2
|
+
require 'active_merchant/billing/gateways/sage/sage_virtual_check'
|
|
3
|
+
require 'active_merchant/billing/gateways/sage/sage_vault'
|
|
4
|
+
|
|
5
|
+
module ActiveMerchant #:nodoc:
|
|
6
|
+
module Billing #:nodoc:
|
|
7
|
+
class SageGateway < Gateway
|
|
8
|
+
self.supported_countries = SageBankcardGateway.supported_countries
|
|
9
|
+
self.supported_cardtypes = SageBankcardGateway.supported_cardtypes
|
|
10
|
+
|
|
11
|
+
self.abstract_class = true
|
|
12
|
+
|
|
13
|
+
# Creates a new SageGateway
|
|
14
|
+
#
|
|
15
|
+
# The gateway requires that a valid login and password be passed
|
|
16
|
+
# in the +options+ hash.
|
|
17
|
+
#
|
|
18
|
+
# ==== Options
|
|
19
|
+
#
|
|
20
|
+
# * <tt>:login</tt> - The Sage Payment Solutions Merchant ID Number.
|
|
21
|
+
# * <tt>:password</tt> - The Sage Payment Solutions Merchant Key Number.
|
|
22
|
+
def initialize(options = {})
|
|
23
|
+
requires!(options, :login, :password)
|
|
24
|
+
super
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Performs an authorization transaction
|
|
28
|
+
#
|
|
29
|
+
# ==== Parameters
|
|
30
|
+
# * <tt>money</tt> - The amount to be authorized as an integer value in cents.
|
|
31
|
+
# * <tt>credit_card</tt> - The CreditCard object to be used as the funding source for the transaction.
|
|
32
|
+
# * <tt>options</tt> - A hash of optional parameters.
|
|
33
|
+
# * <tt>:order_id</tt> - A unique reference for this order. (maximum of 20 characters).
|
|
34
|
+
# * <tt>:email</tt> - The customer's email address
|
|
35
|
+
# * <tt>:customer</tt> - The Customer Number for Purchase Card Level II Transactions
|
|
36
|
+
# * <tt>:billing_address</tt> - The customer's billing address as a hash of address information.
|
|
37
|
+
# * <tt>:address1</tt> - The billing address street
|
|
38
|
+
# * <tt>:city</tt> - The billing address city
|
|
39
|
+
# * <tt>:state</tt> - The billing address state
|
|
40
|
+
# * <tt>:country</tt> - The 2 digit ISO billing address country code
|
|
41
|
+
# * <tt>:zip</tt> - The billing address zip code
|
|
42
|
+
# * <tt>:phone</tt> - The billing address phone number
|
|
43
|
+
# * <tt>:fax</tt> - The billing address fax number
|
|
44
|
+
# * <tt>:shipping_address</tt> - The customer's shipping address as a hash of address information.
|
|
45
|
+
# * <tt>:name</tt> - The name at the shipping address
|
|
46
|
+
# * <tt>:address1</tt> - The shipping address street
|
|
47
|
+
# * <tt>:city</tt> - The shipping address city
|
|
48
|
+
# * <tt>:state</tt> - The shipping address state code
|
|
49
|
+
# * <tt>:country</tt> - The 2 digit ISO shipping address country code
|
|
50
|
+
# * <tt>:zip</tt> - The shipping address zip code
|
|
51
|
+
# * <tt>:tax</tt> - The tax amount for the transaction as an Integer value in cents. Maps to Sage <tt>T_tax</tt>.
|
|
52
|
+
# * <tt>:shipping</tt> - The shipping amount for the transaction as an Integer value in cents. Maps to Sage <tt>T_shipping</tt>.
|
|
53
|
+
def authorize(money, credit_card, options = {})
|
|
54
|
+
bankcard.authorize(money, credit_card, options)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Performs a purchase, which is essentially an authorization and capture in a single operation.
|
|
58
|
+
#
|
|
59
|
+
# ==== Parameters
|
|
60
|
+
#
|
|
61
|
+
# * <tt>money</tt> - The amount to be authorized as an integer value in cents.
|
|
62
|
+
# * <tt>source</tt> - The CreditCard or Check object to be used as the funding source for the transaction.
|
|
63
|
+
# * <tt>options</tt> - A hash of optional parameters.
|
|
64
|
+
# * <tt>:order_id</tt> - A unique reference for this order. (maximum of 20 characters).
|
|
65
|
+
# * <tt>:email</tt> - The customer's email address
|
|
66
|
+
# * <tt>:customer</tt> - The Customer Number for Purchase Card Level II Transactions
|
|
67
|
+
# * <tt>:billing_address</tt> - The customer's billing address as a hash of address information.
|
|
68
|
+
# * <tt>:address1</tt> - The billing address street
|
|
69
|
+
# * <tt>:city</tt> - The billing address city
|
|
70
|
+
# * <tt>:state</tt> - The billing address state
|
|
71
|
+
# * <tt>:country</tt> - The 2 digit ISO billing address country code
|
|
72
|
+
# * <tt>:zip</tt> - The billing address zip code
|
|
73
|
+
# * <tt>:phone</tt> - The billing address phone number
|
|
74
|
+
# * <tt>:fax</tt> - The billing address fax number
|
|
75
|
+
# * <tt>:shipping_address</tt> - The customer's shipping address as a hash of address information.
|
|
76
|
+
# * <tt>:name</tt> - The name at the shipping address
|
|
77
|
+
# * <tt>:address1</tt> - The shipping address street
|
|
78
|
+
# * <tt>:city</tt> - The shipping address city
|
|
79
|
+
# * <tt>:state</tt> - The shipping address state code
|
|
80
|
+
# * <tt>:country</tt> - The 2 digit ISO shipping address country code
|
|
81
|
+
# * <tt>:zip</tt> - The shipping address zip code
|
|
82
|
+
# * <tt>:tax</tt> - The tax amount for the transaction as an integer value in cents. Maps to Sage <tt>T_tax</tt>.
|
|
83
|
+
# * <tt>:shipping</tt> - The shipping amount for the transaction as an integer value in cents. Maps to Sage <tt>T_shipping</tt>.
|
|
84
|
+
#
|
|
85
|
+
# ==== Additional options in the +options+ hash for when using a Check as the funding source
|
|
86
|
+
# * <tt>:originator_id</tt> - 10 digit originator. If not provided, Sage will use the default Originator ID for the specific customer type.
|
|
87
|
+
# * <tt>:addenda</tt> - Transaction addenda.
|
|
88
|
+
# * <tt>:ssn</tt> - The customer's Social Security Number.
|
|
89
|
+
# * <tt>:drivers_license_state</tt> - The customer's drivers license state code.
|
|
90
|
+
# * <tt>:drivers_license_number</tt> - The customer's drivers license number.
|
|
91
|
+
# * <tt>:date_of_birth</tt> - The customer's date of birth as a Time or Date object or a string in the format <tt>mm/dd/yyyy</tt>.
|
|
92
|
+
def purchase(money, source, options = {})
|
|
93
|
+
if card_brand(source) == "check"
|
|
94
|
+
virtual_check.purchase(money, source, options)
|
|
95
|
+
else
|
|
96
|
+
bankcard.purchase(money, source, options)
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Captures authorized funds.
|
|
101
|
+
#
|
|
102
|
+
# ==== Parameters
|
|
103
|
+
#
|
|
104
|
+
# * <tt>money</tt> - The amount to be authorized as an integer value in cents. Sage doesn't support changing the capture amount, so the full amount of the initial transaction will be captured.
|
|
105
|
+
# * <tt>reference</tt> - The authorization reference string returned by the original transaction's Response#authorization.
|
|
106
|
+
def capture(money, reference, options = {})
|
|
107
|
+
bankcard.capture(money, reference, options)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Voids a prior transaction. Works for both CreditCard and Check transactions.
|
|
111
|
+
#
|
|
112
|
+
# ==== Parameters
|
|
113
|
+
#
|
|
114
|
+
# * <tt>reference</tt> - The authorization reference string returned by the original transaction's Response#authorization.
|
|
115
|
+
def void(reference, options = {})
|
|
116
|
+
if reference.split(";").last == "virtual_check"
|
|
117
|
+
virtual_check.void(reference, options)
|
|
118
|
+
else
|
|
119
|
+
bankcard.void(reference, options)
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
#
|
|
124
|
+
# ==== Parameters
|
|
125
|
+
#
|
|
126
|
+
# * <tt>money</tt> - The amount to be authorized as an integer value in cents.
|
|
127
|
+
# * <tt>source</tt> - The CreditCard or Check object to be used as the target for the credit.
|
|
128
|
+
def credit(money, source, options = {})
|
|
129
|
+
if card_brand(source) == "check"
|
|
130
|
+
virtual_check.credit(money, source, options)
|
|
131
|
+
else
|
|
132
|
+
bankcard.credit(money, source, options)
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def refund(money, reference, options={})
|
|
137
|
+
bankcard.refund(money, reference, options)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# Stores a credit card in the Sage vault.
|
|
141
|
+
#
|
|
142
|
+
# ==== Parameters
|
|
143
|
+
#
|
|
144
|
+
# * <tt>credit_card</tt> - The CreditCard object to be stored.
|
|
145
|
+
def store(credit_card, options = {})
|
|
146
|
+
vault.store(credit_card, options)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Deletes a stored card from the Sage vault.
|
|
150
|
+
#
|
|
151
|
+
# ==== Parameters
|
|
152
|
+
#
|
|
153
|
+
# * <tt>identification</tt> - The 'GUID' identifying the stored card.
|
|
154
|
+
def unstore(identification, options = {})
|
|
155
|
+
vault.unstore(identification, options)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
private
|
|
159
|
+
|
|
160
|
+
def bankcard
|
|
161
|
+
@bankcard ||= SageBankcardGateway.new(@options)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def virtual_check
|
|
165
|
+
@virtual_check ||= SageVirtualCheckGateway.new(@options)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def vault
|
|
169
|
+
@vault ||= SageVaultGateway.new(@options)
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
require 'active_merchant/billing/gateways/sage/sage_core'
|
|
2
|
+
|
|
3
|
+
module ActiveMerchant #:nodoc:
|
|
4
|
+
module Billing #:nodoc:
|
|
5
|
+
class SageBankcardGateway < Gateway #:nodoc:
|
|
6
|
+
include SageCore
|
|
7
|
+
self.live_url = 'https://www.sagepayments.net/cgi-bin/eftBankcard.dll?transaction'
|
|
8
|
+
self.source = 'bankcard'
|
|
9
|
+
|
|
10
|
+
# Credit cards supported by Sage
|
|
11
|
+
# * VISA
|
|
12
|
+
# * MasterCard
|
|
13
|
+
# * AMEX
|
|
14
|
+
# * Diners
|
|
15
|
+
# * Carte Blanche
|
|
16
|
+
# * Discover
|
|
17
|
+
# * JCB
|
|
18
|
+
# * Sears
|
|
19
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club]
|
|
20
|
+
|
|
21
|
+
def authorize(money, credit_card, options = {})
|
|
22
|
+
post = {}
|
|
23
|
+
add_credit_card(post, credit_card)
|
|
24
|
+
add_transaction_data(post, money, options)
|
|
25
|
+
commit(:authorization, post)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def purchase(money, credit_card, options = {})
|
|
29
|
+
post = {}
|
|
30
|
+
add_credit_card(post, credit_card)
|
|
31
|
+
add_transaction_data(post, money, options)
|
|
32
|
+
commit(:purchase, post)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# The +money+ amount is not used. The entire amount of the
|
|
36
|
+
# initial authorization will be captured.
|
|
37
|
+
def capture(money, reference, options = {})
|
|
38
|
+
post = {}
|
|
39
|
+
add_reference(post, reference)
|
|
40
|
+
commit(:capture, post)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def void(reference, options = {})
|
|
44
|
+
post = {}
|
|
45
|
+
add_reference(post, reference)
|
|
46
|
+
commit(:void, post)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def credit(money, credit_card, options = {})
|
|
50
|
+
post = {}
|
|
51
|
+
add_credit_card(post, credit_card)
|
|
52
|
+
add_transaction_data(post, money, options)
|
|
53
|
+
commit(:credit, post)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def refund(money, reference, options={})
|
|
57
|
+
post = {}
|
|
58
|
+
add_reference(post, reference)
|
|
59
|
+
add_transaction_data(post, money, options)
|
|
60
|
+
commit(:refund, post)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
private
|
|
64
|
+
|
|
65
|
+
def add_credit_card(post, credit_card)
|
|
66
|
+
post[:C_name] = credit_card.name
|
|
67
|
+
post[:C_cardnumber] = credit_card.number
|
|
68
|
+
post[:C_exp] = expdate(credit_card)
|
|
69
|
+
post[:C_cvv] = credit_card.verification_value if credit_card.verification_value?
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def parse(data)
|
|
73
|
+
response = {}
|
|
74
|
+
response[:success] = data[1,1]
|
|
75
|
+
response[:code] = data[2,6]
|
|
76
|
+
response[:message] = data[8,32].strip
|
|
77
|
+
response[:front_end] = data[40, 2]
|
|
78
|
+
response[:cvv_result] = data[42, 1]
|
|
79
|
+
response[:avs_result] = data[43, 1].strip
|
|
80
|
+
response[:risk] = data[44, 2]
|
|
81
|
+
response[:reference] = data[46, 10]
|
|
82
|
+
|
|
83
|
+
response[:order_number], response[:recurring] = data[57...-1].split("\034")
|
|
84
|
+
response
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
|
2
|
+
module Billing #:nodoc:
|
|
3
|
+
module SageCore #:nodoc:
|
|
4
|
+
def self.included(base)
|
|
5
|
+
base.cattr_accessor :source
|
|
6
|
+
base.supported_countries = ['US', 'CA']
|
|
7
|
+
base.homepage_url = 'http://www.sagepayments.com'
|
|
8
|
+
base.display_name = 'Sage Payment Solutions'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Transactions types:
|
|
12
|
+
# <tt>01</tt> - Sale
|
|
13
|
+
# <tt>02</tt> - AuthOnly
|
|
14
|
+
# <tt>03</tt> - Force/PriorAuthSale
|
|
15
|
+
# <tt>04</tt> - Void
|
|
16
|
+
# <tt>06</tt> - Credit
|
|
17
|
+
# <tt>11</tt> - PriorAuthSale by Reference*
|
|
18
|
+
TRANSACTIONS = {
|
|
19
|
+
:purchase => '01',
|
|
20
|
+
:authorization => '02',
|
|
21
|
+
:capture => '11',
|
|
22
|
+
:void => '04',
|
|
23
|
+
:credit => '06',
|
|
24
|
+
:refund => '10'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
def initialize(options = {})
|
|
28
|
+
requires!(options, :login, :password)
|
|
29
|
+
super
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
def add_invoice(post, options)
|
|
34
|
+
post[:T_ordernum] = (options[:order_id] || generate_unique_id).slice(0, 20)
|
|
35
|
+
post[:T_tax] = amount(options[:tax]) unless options[:tax].blank?
|
|
36
|
+
post[:T_shipping] = amount(options[:shipping]) unless options[:shipping].blank?
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def add_reference(post, reference)
|
|
40
|
+
ref, _ = reference.to_s.split(";")
|
|
41
|
+
post[:T_reference] = ref
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def add_amount(post, money)
|
|
45
|
+
post[:T_amt] = amount(money)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def add_customer_data(post, options)
|
|
49
|
+
post[:T_customer_number] = options[:customer] if Float(options[:customer]) rescue nil
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def add_addresses(post, options)
|
|
53
|
+
billing_address = options[:billing_address] || options[:address] || {}
|
|
54
|
+
|
|
55
|
+
post[:C_address] = billing_address[:address1]
|
|
56
|
+
post[:C_city] = billing_address[:city]
|
|
57
|
+
|
|
58
|
+
if ['US', 'CA'].include?(billing_address[:country])
|
|
59
|
+
post[:C_state] = billing_address[:state]
|
|
60
|
+
else
|
|
61
|
+
post[:C_state] = "Outside of United States"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
post[:C_zip] = billing_address[:zip]
|
|
65
|
+
post[:C_country] = billing_address[:country]
|
|
66
|
+
post[:C_telephone] = billing_address[:phone]
|
|
67
|
+
post[:C_fax] = billing_address[:fax]
|
|
68
|
+
post[:C_email] = options[:email]
|
|
69
|
+
|
|
70
|
+
if shipping_address = options[:shipping_address]
|
|
71
|
+
post[:C_ship_name] = shipping_address[:name]
|
|
72
|
+
post[:C_ship_address] = shipping_address[:address1]
|
|
73
|
+
post[:C_ship_city] = shipping_address[:city]
|
|
74
|
+
post[:C_ship_state] = shipping_address[:state]
|
|
75
|
+
post[:C_ship_zip] = shipping_address[:zip]
|
|
76
|
+
post[:C_ship_country] = shipping_address[:country]
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def add_transaction_data(post, money, options)
|
|
81
|
+
add_amount(post, money)
|
|
82
|
+
add_invoice(post, options)
|
|
83
|
+
add_addresses(post, options)
|
|
84
|
+
add_customer_data(post, options)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def commit(action, params)
|
|
88
|
+
response = parse(ssl_post(self.live_url, post_data(action, params)))
|
|
89
|
+
|
|
90
|
+
Response.new(success?(response), response[:message], response,
|
|
91
|
+
:test => test?,
|
|
92
|
+
:authorization => authorization_from(response),
|
|
93
|
+
:avs_result => { :code => response[:avs_result] },
|
|
94
|
+
:cvv_result => response[:cvv_result]
|
|
95
|
+
)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def authorization_from(response)
|
|
99
|
+
"#{response[:reference]};#{source}"
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def success?(response)
|
|
103
|
+
response[:success] == 'A'
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def post_data(action, params = {})
|
|
107
|
+
params[:M_id] = @options[:login]
|
|
108
|
+
params[:M_key] = @options[:password]
|
|
109
|
+
params[:T_code] = TRANSACTIONS[action]
|
|
110
|
+
|
|
111
|
+
params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
|
2
|
+
module Billing #:nodoc:
|
|
3
|
+
class SageVaultGateway < Gateway #:nodoc:
|
|
4
|
+
self.live_url = 'https://www.sagepayments.net/web_services/wsVault/wsVault.asmx'
|
|
5
|
+
|
|
6
|
+
def initialize(options = {})
|
|
7
|
+
requires!(options, :login, :password)
|
|
8
|
+
super
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def store(credit_card, options = {})
|
|
12
|
+
request = build_store_request(credit_card, options)
|
|
13
|
+
commit(:store, request)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def unstore(identification, options = {})
|
|
17
|
+
request = build_unstore_request(identification, options)
|
|
18
|
+
commit(:unstore, request)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
# A valid request example, since the Sage docs have none:
|
|
24
|
+
#
|
|
25
|
+
# <?xml version="1.0" encoding="UTF-8" ?>
|
|
26
|
+
# <SOAP-ENV:Envelope
|
|
27
|
+
# xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
|
|
28
|
+
# xmlns:ns1="https://www.sagepayments.net/web_services/wsVault/wsVault">
|
|
29
|
+
# <SOAP-ENV:Body>
|
|
30
|
+
# <ns1:INSERT_CREDIT_CARD_DATA>
|
|
31
|
+
# <ns1:M_ID>279277516172</ns1:M_ID>
|
|
32
|
+
# <ns1:M_KEY>O3I8G2H8V6A3</ns1:M_KEY>
|
|
33
|
+
# <ns1:CARDNUMBER>4111111111111111</ns1:CARDNUMBER>
|
|
34
|
+
# <ns1:EXPIRATION_DATE>0915</ns1:EXPIRATION_DATE>
|
|
35
|
+
# </ns1:INSERT_CREDIT_CARD_DATA>
|
|
36
|
+
# </SOAP-ENV:Body>
|
|
37
|
+
# </SOAP-ENV:Envelope>
|
|
38
|
+
def build_store_request(credit_card, options)
|
|
39
|
+
xml = Builder::XmlMarkup.new
|
|
40
|
+
add_credit_card(xml, credit_card, options)
|
|
41
|
+
xml.target!
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def build_unstore_request(identification, options)
|
|
45
|
+
xml = Builder::XmlMarkup.new
|
|
46
|
+
add_identification(xml, identification, options)
|
|
47
|
+
xml.target!
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def add_customer_data(xml)
|
|
51
|
+
xml.tag! 'ns1:M_ID', @options[:login]
|
|
52
|
+
xml.tag! 'ns1:M_KEY', @options[:password]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def add_credit_card(xml, credit_card, options)
|
|
56
|
+
xml.tag! 'ns1:CARDNUMBER', credit_card.number
|
|
57
|
+
xml.tag! 'ns1:EXPIRATION_DATE', exp_date(credit_card)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def add_identification(xml, identification, options)
|
|
61
|
+
xml.tag! 'ns1:GUID', identification
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def exp_date(credit_card)
|
|
65
|
+
year = sprintf("%.4i", credit_card.year)
|
|
66
|
+
month = sprintf("%.2i", credit_card.month)
|
|
67
|
+
|
|
68
|
+
"#{month}#{year[-2..-1]}"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def commit(action, request)
|
|
72
|
+
response = parse(ssl_post(live_url,
|
|
73
|
+
build_soap_request(action, request),
|
|
74
|
+
build_headers(action))
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
case action
|
|
78
|
+
when :store
|
|
79
|
+
success = response[:success] == 'true'
|
|
80
|
+
message = response[:message].downcase.capitalize if response[:message]
|
|
81
|
+
when :unstore
|
|
82
|
+
success = response[:delete_data_result] == 'true'
|
|
83
|
+
message = success ? 'Succeeded' : 'Failed'
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
Response.new(success, message, response,
|
|
87
|
+
authorization: response[:guid]
|
|
88
|
+
)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
ENVELOPE_NAMESPACES = {
|
|
92
|
+
'xmlns:SOAP-ENV' => "http://schemas.xmlsoap.org/soap/envelope/",
|
|
93
|
+
'xmlns:ns1' => "https://www.sagepayments.net/web_services/wsVault/wsVault"
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
ACTION_ELEMENTS = {
|
|
97
|
+
store: 'INSERT_CREDIT_CARD_DATA',
|
|
98
|
+
unstore: 'DELETE_DATA'
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
def build_soap_request(action, body)
|
|
102
|
+
xml = Builder::XmlMarkup.new
|
|
103
|
+
|
|
104
|
+
xml.instruct!
|
|
105
|
+
xml.tag! 'SOAP-ENV:Envelope', ENVELOPE_NAMESPACES do
|
|
106
|
+
xml.tag! 'SOAP-ENV:Body' do
|
|
107
|
+
xml.tag! "ns1:#{ACTION_ELEMENTS[action]}" do
|
|
108
|
+
add_customer_data(xml)
|
|
109
|
+
xml << body
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
xml.target!
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
SOAP_ACTIONS = {
|
|
117
|
+
store: 'https://www.sagepayments.net/web_services/wsVault/wsVault/INSERT_CREDIT_CARD_DATA',
|
|
118
|
+
unstore: 'https://www.sagepayments.net/web_services/wsVault/wsVault/DELETE_DATA'
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
def build_headers(action)
|
|
122
|
+
{
|
|
123
|
+
"SOAPAction" => SOAP_ACTIONS[action],
|
|
124
|
+
"Content-Type" => "text/xml; charset=utf-8"
|
|
125
|
+
}
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def parse(body)
|
|
129
|
+
response = {}
|
|
130
|
+
hashify_xml!(body, response)
|
|
131
|
+
response
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def hashify_xml!(xml, response)
|
|
135
|
+
xml = REXML::Document.new(xml)
|
|
136
|
+
|
|
137
|
+
# Store
|
|
138
|
+
xml.elements.each("//Table1/*") do |node|
|
|
139
|
+
response[node.name.underscore.to_sym] = node.text
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Unstore
|
|
143
|
+
xml.elements.each("//DELETE_DATAResponse/*") do |node|
|
|
144
|
+
response[node.name.underscore.to_sym] = node.text
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
end
|