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,20 @@
|
|
1
|
+
require 'active_merchant/billing/gateways/smart_ps.rb'
|
2
|
+
require 'active_merchant/billing/gateways/braintree/braintree_common'
|
3
|
+
|
4
|
+
module ActiveMerchant #:nodoc:
|
5
|
+
module Billing #:nodoc:
|
6
|
+
class BraintreeOrangeGateway < SmartPs
|
7
|
+
include BraintreeCommon
|
8
|
+
|
9
|
+
self.display_name = 'Braintree (Orange Platform)'
|
10
|
+
self.supported_countries = ["US"]
|
11
|
+
|
12
|
+
self.live_url = self.test_url = 'https://secure.braintreepaymentgateway.com/api/transact.php'
|
13
|
+
|
14
|
+
def add_processor(post, options)
|
15
|
+
post[:processor_id] = options[:processor] unless options[:processor].nil?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,189 @@
|
|
1
|
+
require "nokogiri"
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class BridgePayGateway < Gateway
|
6
|
+
self.display_name = "BridgePay"
|
7
|
+
self.homepage_url = "http://www.bridgepaynetwork.com/"
|
8
|
+
|
9
|
+
self.test_url = "https://gatewaystage.itstgate.com/SmartPayments/transact.asmx/ProcessCreditCard"
|
10
|
+
self.live_url = "https://gateway.itstgate.com/SmartPayments/transact.asmx/ProcessCreditCard"
|
11
|
+
|
12
|
+
self.supported_countries = ["CA", "US"]
|
13
|
+
self.default_currency = "USD"
|
14
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
|
15
|
+
|
16
|
+
|
17
|
+
def initialize(options={})
|
18
|
+
requires!(options, :user_name, :password)
|
19
|
+
super
|
20
|
+
end
|
21
|
+
|
22
|
+
def purchase(amount, creditcard, options={})
|
23
|
+
post = post_required_fields("Sale")
|
24
|
+
|
25
|
+
# Allow the same amount in multiple transactions.
|
26
|
+
post[:ExtData] = "<Force>T</Force>"
|
27
|
+
add_invoice(post, amount, options)
|
28
|
+
add_creditcard(post, creditcard)
|
29
|
+
add_customer_data(post, options)
|
30
|
+
|
31
|
+
commit(post)
|
32
|
+
end
|
33
|
+
|
34
|
+
def authorize(amount, creditcard, options={})
|
35
|
+
post = post_required_fields("Auth")
|
36
|
+
|
37
|
+
add_invoice(post, amount, options)
|
38
|
+
add_creditcard(post, creditcard)
|
39
|
+
add_customer_data(post, options)
|
40
|
+
|
41
|
+
commit(post)
|
42
|
+
end
|
43
|
+
|
44
|
+
def capture(amount, authorization, options={})
|
45
|
+
post = post_required_fields("Force")
|
46
|
+
|
47
|
+
add_invoice(post, amount, options)
|
48
|
+
add_reference(post, authorization)
|
49
|
+
add_customer_data(post, options)
|
50
|
+
|
51
|
+
commit(post)
|
52
|
+
end
|
53
|
+
|
54
|
+
def refund(amount, authorization, options={})
|
55
|
+
post = post_required_fields("Return")
|
56
|
+
|
57
|
+
add_invoice(post, amount, options)
|
58
|
+
add_reference(post, authorization)
|
59
|
+
|
60
|
+
commit(post)
|
61
|
+
end
|
62
|
+
|
63
|
+
def void(authorization, options={})
|
64
|
+
post = post_required_fields("Void")
|
65
|
+
|
66
|
+
add_reference(post, authorization)
|
67
|
+
|
68
|
+
commit(post)
|
69
|
+
end
|
70
|
+
|
71
|
+
def verify(creditcard, options = {})
|
72
|
+
MultiResponse.run(:use_first_response) do |r|
|
73
|
+
r.process { authorize(100, creditcard, options) }
|
74
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def post_required_fields(transaction_type)
|
81
|
+
post = {}
|
82
|
+
post[:TransType] = transaction_type
|
83
|
+
post[:Amount] = ""
|
84
|
+
post[:PNRef] = ""
|
85
|
+
post[:InvNum] = ""
|
86
|
+
post[:CardNum] = ""
|
87
|
+
post[:ExpDate] = ""
|
88
|
+
post[:MagData] = ""
|
89
|
+
post[:NameOnCard] = ""
|
90
|
+
post[:Zip] = ""
|
91
|
+
post[:Street] = ""
|
92
|
+
post[:CVNum] = ""
|
93
|
+
post[:MagData] = ""
|
94
|
+
post[:ExtData] = ""
|
95
|
+
post
|
96
|
+
end
|
97
|
+
|
98
|
+
def add_customer_data(post, options)
|
99
|
+
if(billing_address = (options[:billing_address] || options[:address]))
|
100
|
+
post[:Street] = billing_address[:address1]
|
101
|
+
post[:Zip] = billing_address[:zip]
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def add_invoice(post, amount, options)
|
106
|
+
post[:Amount] = amount(amount)
|
107
|
+
post[:InvNum] = options[:order_id]
|
108
|
+
end
|
109
|
+
|
110
|
+
def add_creditcard(post, creditcard)
|
111
|
+
post[:NameOnCard] = creditcard.name if creditcard.name
|
112
|
+
post[:ExpDate] = expdate(creditcard)
|
113
|
+
post[:CardNum] = creditcard.number
|
114
|
+
post[:CVNum] = creditcard.verification_value
|
115
|
+
end
|
116
|
+
|
117
|
+
def expdate(creditcard)
|
118
|
+
"#{format(creditcard.month, :two_digits)}#{format(creditcard.year, :two_digits)}"
|
119
|
+
end
|
120
|
+
|
121
|
+
def parse(xml)
|
122
|
+
response = {}
|
123
|
+
|
124
|
+
doc = Nokogiri::XML(xml)
|
125
|
+
doc.root.xpath("*").each do |node|
|
126
|
+
if (node.elements.size == 0)
|
127
|
+
response[node.name.downcase.to_sym] = node.text
|
128
|
+
else
|
129
|
+
node.elements.each do |childnode|
|
130
|
+
name = "#{node.name.downcase}_#{childnode.name.downcase}"
|
131
|
+
response[name.to_sym] = childnode.text
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end unless doc.root.nil?
|
135
|
+
|
136
|
+
response
|
137
|
+
end
|
138
|
+
|
139
|
+
def commit(parameters)
|
140
|
+
url = (test? ? test_url : live_url)
|
141
|
+
data = post_data(parameters)
|
142
|
+
raw = parse(ssl_post(url, data))
|
143
|
+
|
144
|
+
Response.new(
|
145
|
+
success_from(raw[:respmsg]),
|
146
|
+
message_from(raw),
|
147
|
+
raw,
|
148
|
+
authorization: authorization_from(raw),
|
149
|
+
test: test?
|
150
|
+
)
|
151
|
+
end
|
152
|
+
|
153
|
+
def success_from(result)
|
154
|
+
case result
|
155
|
+
when "Approved"
|
156
|
+
true
|
157
|
+
else
|
158
|
+
false
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def message_from(response)
|
163
|
+
response[:respmsg]
|
164
|
+
end
|
165
|
+
|
166
|
+
def authorization_from(response)
|
167
|
+
[response[:authcode], response[:pnref]].join("|")
|
168
|
+
end
|
169
|
+
|
170
|
+
def split_authorization(authorization)
|
171
|
+
authcode, pnref = authorization.split("|")
|
172
|
+
[authcode, pnref]
|
173
|
+
end
|
174
|
+
|
175
|
+
def add_reference(post, authorization)
|
176
|
+
authcode, pnref = split_authorization(authorization)
|
177
|
+
post[:AuthCode] = authcode
|
178
|
+
post[:PNRef] = pnref
|
179
|
+
end
|
180
|
+
|
181
|
+
def post_data(post)
|
182
|
+
{
|
183
|
+
:UserName => @options[:user_name],
|
184
|
+
:Password => @options[:password]
|
185
|
+
}.merge(post).collect{|k,v| "#{k}=#{CGI.escape(v.to_s)}"}.join("&")
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class CardSaveGateway < IridiumGateway
|
4
|
+
#CardSave lets you handle failovers on payments by providing 3 gateways in case one happens to be down
|
5
|
+
#URLS = ['https://gw1.cardsaveonlinepayments.com:4430/','https://gw2.cardsaveonlinepayments.com:4430/','https://gw3.cardsaveonlinepayments.com:4430/']
|
6
|
+
|
7
|
+
self.money_format = :cents
|
8
|
+
self.default_currency = 'GBP'
|
9
|
+
self.supported_cardtypes = [ :visa, :switch, :maestro, :master, :solo, :american_express, :jcb ]
|
10
|
+
self.supported_countries = [ 'GB' ]
|
11
|
+
self.homepage_url = 'http://www.cardsave.net/'
|
12
|
+
self.display_name = 'CardSave'
|
13
|
+
|
14
|
+
def initialize(options={})
|
15
|
+
super
|
16
|
+
@test_url = 'https://gw1.cardsaveonlinepayments.com:4430/'
|
17
|
+
@live_url = 'https://gw1.cardsaveonlinepayments.com:4430/'
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,238 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class CardStreamGateway < Gateway
|
4
|
+
self.test_url = self.live_url = 'https://gateway.cardstream.com/direct/'
|
5
|
+
self.money_format = :cents
|
6
|
+
self.default_currency = 'GBP'
|
7
|
+
self.supported_countries = ['GB', 'US', 'CH', 'SE', 'SG', 'NO', 'JP', 'IS', 'HK', 'NL', 'CZ', 'CA', 'AU']
|
8
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :discover, :jcb, :maestro, :solo, :switch]
|
9
|
+
self.homepage_url = 'http://www.cardstream.com/'
|
10
|
+
self.display_name = 'CardStream'
|
11
|
+
|
12
|
+
CURRENCY_CODES = {
|
13
|
+
"AUD" => '036',
|
14
|
+
"CAD" => '124',
|
15
|
+
"CZK" => '203',
|
16
|
+
"DKK" => '208',
|
17
|
+
"HKD" => '344',
|
18
|
+
"ICK" => '352',
|
19
|
+
"JPY" => '392',
|
20
|
+
"NOK" => '578',
|
21
|
+
"SGD" => '702',
|
22
|
+
"SEK" => '752',
|
23
|
+
"CHF" => '756',
|
24
|
+
"GBP" => '826',
|
25
|
+
"USD" => '840',
|
26
|
+
"EUR" => '978'
|
27
|
+
}
|
28
|
+
|
29
|
+
CVV_CODE = {
|
30
|
+
'0' => 'U',
|
31
|
+
'1' => 'P',
|
32
|
+
'2' => 'M',
|
33
|
+
'4' => 'N'
|
34
|
+
}
|
35
|
+
|
36
|
+
# 0 - No additional information available.
|
37
|
+
# 1 - Postcode not checked.
|
38
|
+
# 2 - Postcode matched.
|
39
|
+
# 4 - Postcode not matched.
|
40
|
+
# 8 - Postcode partially matched.
|
41
|
+
AVS_POSTAL_MATCH = {
|
42
|
+
"0" => nil,
|
43
|
+
"1" => nil,
|
44
|
+
"2" => "Y",
|
45
|
+
"4" => "N",
|
46
|
+
"8" => "N"
|
47
|
+
}
|
48
|
+
|
49
|
+
# 0 - No additional information available.
|
50
|
+
# 1 - Address numeric not checked.
|
51
|
+
# 2 - Address numeric matched.
|
52
|
+
# 4 - Address numeric not matched.
|
53
|
+
# 8 - Address numeric partially matched.
|
54
|
+
AVS_STREET_MATCH = {
|
55
|
+
"0" => nil,
|
56
|
+
"1" => nil,
|
57
|
+
"2" => "Y",
|
58
|
+
"4" => "N",
|
59
|
+
"8" => "N"
|
60
|
+
}
|
61
|
+
|
62
|
+
def initialize(options = {})
|
63
|
+
requires!(options, :login, :shared_secret)
|
64
|
+
if (options[:threeDSRequired])
|
65
|
+
@threeDSRequired = options[:threeDSRequired]
|
66
|
+
else
|
67
|
+
@threeDSRequired = 'N'
|
68
|
+
end
|
69
|
+
super
|
70
|
+
end
|
71
|
+
|
72
|
+
def authorize(money, creditcard, options = {})
|
73
|
+
post = {}
|
74
|
+
add_amount(post, money, options)
|
75
|
+
add_invoice(post, creditcard, money, options)
|
76
|
+
add_creditcard(post, creditcard)
|
77
|
+
add_address(post, creditcard, options)
|
78
|
+
add_customer_data(post, options)
|
79
|
+
commit('PREAUTH', post)
|
80
|
+
end
|
81
|
+
|
82
|
+
def purchase(money, creditcard, options = {})
|
83
|
+
post = {}
|
84
|
+
add_amount(post, money, options)
|
85
|
+
add_invoice(post, creditcard, money, options)
|
86
|
+
add_creditcard(post, creditcard)
|
87
|
+
add_address(post, creditcard, options)
|
88
|
+
add_customer_data(post, options)
|
89
|
+
commit('SALE', post)
|
90
|
+
end
|
91
|
+
|
92
|
+
def capture(money, authorization, options = {})
|
93
|
+
post = {}
|
94
|
+
add_pair(post, :xref, authorization)
|
95
|
+
add_amount(post, money, options)
|
96
|
+
commit('SALE', post)
|
97
|
+
end
|
98
|
+
|
99
|
+
def refund(money, authorization, options = {})
|
100
|
+
post = {}
|
101
|
+
add_pair(post, :xref, authorization)
|
102
|
+
add_amount(post, money, options)
|
103
|
+
commit('REFUND', post)
|
104
|
+
end
|
105
|
+
|
106
|
+
def void(authorization, options = {})
|
107
|
+
post = {}
|
108
|
+
add_pair(post, :xref, authorization)
|
109
|
+
commit('REFUND', post)
|
110
|
+
end
|
111
|
+
|
112
|
+
def verify(creditcard, options={})
|
113
|
+
MultiResponse.run(:use_first_response) do |r|
|
114
|
+
r.process { authorize(100, creditcard, options) }
|
115
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def supports_scrubbing?
|
120
|
+
true
|
121
|
+
end
|
122
|
+
|
123
|
+
def scrub(transcript)
|
124
|
+
transcript.
|
125
|
+
gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
|
126
|
+
gsub(%r((cardNumber=)\d+), '\1[FILTERED]').
|
127
|
+
gsub(%r((CVV=)\d+), '\1[FILTERED]')
|
128
|
+
end
|
129
|
+
|
130
|
+
private
|
131
|
+
|
132
|
+
def add_amount(post, money, options)
|
133
|
+
add_pair(post, :amount, amount(money), :required => true)
|
134
|
+
add_pair(post, :currencyCode, currency_code(options[:currency] || currency(money)) || currency_code(self.default_currency))
|
135
|
+
end
|
136
|
+
|
137
|
+
def add_customer_data(post, options)
|
138
|
+
address = options[:billing_address] || options[:address]
|
139
|
+
add_pair(post, :customerPostCode, address[:zip])
|
140
|
+
add_pair(post, :customerEmail, options[:email])
|
141
|
+
add_pair(post, :customerPhone, options[:phone])
|
142
|
+
end
|
143
|
+
|
144
|
+
def add_address(post, creditcard, options)
|
145
|
+
address = options[:billing_address] || options[:address]
|
146
|
+
|
147
|
+
return if address.nil?
|
148
|
+
|
149
|
+
add_pair(post, :customerAddress, address[:address1] + " " + (address[:address2].nil? ? "" : address[:address2]))
|
150
|
+
add_pair(post, :customerPostCode, address[:zip])
|
151
|
+
end
|
152
|
+
|
153
|
+
def add_invoice(post, credit_card, money, options)
|
154
|
+
add_pair(post, :transactionUnique, options[:order_id], :required => true)
|
155
|
+
add_pair(post, :orderRef, options[:description] || options[:order_id], :required => true)
|
156
|
+
if ['american_express', 'diners_club'].include?(card_brand(credit_card).to_s)
|
157
|
+
add_pair(post, :item1Quantity, 1)
|
158
|
+
add_pair(post, :item1Description, (options[:description] || options[:order_id]).slice(0, 15))
|
159
|
+
add_pair(post, :item1GrossValue, amount(money))
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def add_creditcard(post, credit_card)
|
164
|
+
add_pair(post, :customerName, credit_card.name, :required => true)
|
165
|
+
add_pair(post, :cardNumber, credit_card.number, :required => true)
|
166
|
+
|
167
|
+
add_pair(post, :cardExpiryMonth, format(credit_card.month, :two_digits), :required => true)
|
168
|
+
add_pair(post, :cardExpiryYear, format(credit_card.year, :two_digits), :required => true)
|
169
|
+
|
170
|
+
if requires_start_date_or_issue_number?(credit_card)
|
171
|
+
add_pair(post, :cardStartMonth, format(credit_card.start_month, :two_digits))
|
172
|
+
add_pair(post, :cardStartYear, format(credit_card.start_year, :two_digits))
|
173
|
+
|
174
|
+
add_pair(post, :cardIssueNumber, credit_card.issue_number)
|
175
|
+
end
|
176
|
+
|
177
|
+
add_pair(post, :cardCVV, credit_card.verification_value)
|
178
|
+
end
|
179
|
+
|
180
|
+
def add_hmac(post)
|
181
|
+
result = post.sort.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
182
|
+
result = Digest::SHA512.hexdigest("#{result}#{@options[:shared_secret]}")
|
183
|
+
|
184
|
+
add_pair(post, :signature, result)
|
185
|
+
end
|
186
|
+
|
187
|
+
def parse(body)
|
188
|
+
result = {}
|
189
|
+
pairs = body.split("&")
|
190
|
+
pairs.each do |pair|
|
191
|
+
a = pair.split("=")
|
192
|
+
# because some values pairs dont have a value
|
193
|
+
result[a[0].to_sym] = a[1] == nil ? '' : CGI.unescape(a[1])
|
194
|
+
end
|
195
|
+
result
|
196
|
+
end
|
197
|
+
|
198
|
+
def commit(action, parameters)
|
199
|
+
|
200
|
+
parameters.update(
|
201
|
+
:merchantID => @options[:login],
|
202
|
+
:action => action,
|
203
|
+
:type => '1', #Ecommerce
|
204
|
+
:countryCode => self.supported_countries[0],
|
205
|
+
:threeDSRequired => @threeDSRequired #Disable 3d secure by default
|
206
|
+
)
|
207
|
+
# adds a signature to the post hash/array
|
208
|
+
add_hmac(parameters)
|
209
|
+
|
210
|
+
response = parse(ssl_post(self.live_url, post_data(action, parameters)))
|
211
|
+
|
212
|
+
Response.new(response[:responseCode] == "0",
|
213
|
+
response[:responseCode] == "0" ? "APPROVED" : response[:responseMessage],
|
214
|
+
response,
|
215
|
+
:test => test?,
|
216
|
+
:authorization => response[:xref],
|
217
|
+
:cvv_result => CVV_CODE[response[:avscv2ResponseCode].to_s[0, 1]],
|
218
|
+
:avs_result => {
|
219
|
+
:postal_match => AVS_POSTAL_MATCH[response[:avscv2ResponseCode].to_s[1, 1]],
|
220
|
+
:street_match => AVS_STREET_MATCH[response[:avscv2ResponseCode].to_s[2, 1]]
|
221
|
+
}
|
222
|
+
)
|
223
|
+
end
|
224
|
+
|
225
|
+
def currency_code(currency)
|
226
|
+
CURRENCY_CODES[currency]
|
227
|
+
end
|
228
|
+
|
229
|
+
def post_data(action, parameters = {})
|
230
|
+
parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
231
|
+
end
|
232
|
+
|
233
|
+
def add_pair(post, key, value, options = {})
|
234
|
+
post[key] = value if !value.blank? || options[:required]
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|