active_accountability_merchant 1.97.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +2948 -0
- data/CONTRIBUTORS +568 -0
- data/MIT-LICENSE +20 -0
- data/README.md +246 -0
- data/lib/active_merchant.rb +63 -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 +96 -0
- data/lib/active_merchant/billing/base.rb +61 -0
- data/lib/active_merchant/billing/check.rb +80 -0
- data/lib/active_merchant/billing/compatibility.rb +117 -0
- data/lib/active_merchant/billing/credit_card.rb +406 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +23 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +343 -0
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/gateway.rb +330 -0
- data/lib/active_merchant/billing/gateways.rb +14 -0
- data/lib/active_merchant/billing/gateways/adyen.rb +503 -0
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +1055 -0
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +980 -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/bambora_apac.rb +226 -0
- data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
- data/lib/active_merchant/billing/gateways/banwire.rb +116 -0
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +384 -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 +217 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +473 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +522 -0
- data/lib/active_merchant/billing/gateways/blue_snap.rb +522 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +186 -0
- data/lib/active_merchant/billing/gateways/borgun.rb +220 -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 +22 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +740 -0
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +244 -0
- data/lib/active_merchant/billing/gateways/cams.rb +230 -0
- data/lib/active_merchant/billing/gateways/card_connect.rb +316 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +22 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +367 -0
- data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
- data/lib/active_merchant/billing/gateways/cardprocess.rb +254 -0
- data/lib/active_merchant/billing/gateways/cashnet.rb +219 -0
- data/lib/active_merchant/billing/gateways/cc5.rb +198 -0
- data/lib/active_merchant/billing/gateways/cecabank.rb +249 -0
- data/lib/active_merchant/billing/gateways/cenpos.rb +327 -0
- data/lib/active_merchant/billing/gateways/checkout.rb +214 -0
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +270 -0
- data/lib/active_merchant/billing/gateways/citrus_pay.rb +22 -0
- data/lib/active_merchant/billing/gateways/clearhaus.rb +220 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
- data/lib/active_merchant/billing/gateways/conekta.rb +228 -0
- data/lib/active_merchant/billing/gateways/creditcall.rb +271 -0
- data/lib/active_merchant/billing/gateways/credorax.rb +382 -0
- data/lib/active_merchant/billing/gateways/ct_payment.rb +268 -0
- data/lib/active_merchant/billing/gateways/culqi.rb +277 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +828 -0
- data/lib/active_merchant/billing/gateways/d_local.rb +226 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +305 -0
- data/lib/active_merchant/billing/gateways/decidir.rb +233 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
- data/lib/active_merchant/billing/gateways/digitzs.rb +292 -0
- data/lib/active_merchant/billing/gateways/ebanx.rb +296 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +320 -0
- data/lib/active_merchant/billing/gateways/element.rb +356 -0
- data/lib/active_merchant/billing/gateways/epay.rb +285 -0
- data/lib/active_merchant/billing/gateways/evo_ca.rb +308 -0
- data/lib/active_merchant/billing/gateways/eway.rb +226 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +290 -0
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +563 -0
- data/lib/active_merchant/billing/gateways/exact.rb +224 -0
- data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +218 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +159 -0
- data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
- data/lib/active_merchant/billing/gateways/first_giving.rb +142 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +451 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +485 -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/forte.rb +270 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +259 -0
- data/lib/active_merchant/billing/gateways/global_collect.rb +336 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +194 -0
- data/lib/active_merchant/billing/gateways/hdfc.rb +206 -0
- data/lib/active_merchant/billing/gateways/hps.rb +350 -0
- data/lib/active_merchant/billing/gateways/iats_payments.rb +290 -0
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +218 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +162 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +468 -0
- data/lib/active_merchant/billing/gateways/itransact.rb +447 -0
- data/lib/active_merchant/billing/gateways/iveri.rb +251 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +402 -0
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +437 -0
- data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
- data/lib/active_merchant/billing/gateways/kushki.rb +219 -0
- data/lib/active_merchant/billing/gateways/latitude19.rb +411 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +449 -0
- data/lib/active_merchant/billing/gateways/litle.rb +507 -0
- data/lib/active_merchant/billing/gateways/mastercard.rb +267 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +277 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +194 -0
- data/lib/active_merchant/billing/gateways/merchant_one.rb +113 -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 +286 -0
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +210 -0
- data/lib/active_merchant/billing/gateways/mercury.rb +356 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +303 -0
- data/lib/active_merchant/billing/gateways/micropayment.rb +183 -0
- data/lib/active_merchant/billing/gateways/migs.rb +332 -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 +217 -0
- data/lib/active_merchant/billing/gateways/monei.rb +338 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +377 -0
- data/lib/active_merchant/billing/gateways/moneris_us.rb +352 -0
- data/lib/active_merchant/billing/gateways/money_movers.rb +151 -0
- data/lib/active_merchant/billing/gateways/mundipagg.rb +293 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +301 -0
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +165 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +199 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
- data/lib/active_merchant/billing/gateways/netbanx.rb +294 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +232 -0
- data/lib/active_merchant/billing/gateways/netpay.rb +222 -0
- data/lib/active_merchant/billing/gateways/network_merchants.rb +241 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +324 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +478 -0
- data/lib/active_merchant/billing/gateways/omise.rb +324 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +228 -0
- data/lib/active_merchant/billing/gateways/opp.rb +388 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +332 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +1006 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +47 -0
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
- data/lib/active_merchant/billing/gateways/pagarme.rb +246 -0
- data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
- data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +280 -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_junction_v2.rb +188 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +111 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +200 -0
- data/lib/active_merchant/billing/gateways/payeezy.rb +410 -0
- data/lib/active_merchant/billing/gateways/payex.rb +410 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +383 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +235 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +43 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +220 -0
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +14 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +20 -0
- data/lib/active_merchant/billing/gateways/payment_express.rb +369 -0
- data/lib/active_merchant/billing/gateways/paymentez.rb +300 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +371 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +128 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +717 -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 +269 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +160 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +207 -0
- data/lib/active_merchant/billing/gateways/payu_in.rb +248 -0
- data/lib/active_merchant/billing/gateways/payu_latam.rb +449 -0
- data/lib/active_merchant/billing/gateways/payway.rb +207 -0
- data/lib/active_merchant/billing/gateways/pin.rb +234 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +284 -0
- data/lib/active_merchant/billing/gateways/pro_pay.rb +326 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +296 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +303 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +276 -0
- data/lib/active_merchant/billing/gateways/quickbooks.rb +290 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +25 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +301 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
- data/lib/active_merchant/billing/gateways/qvalent.rb +289 -0
- data/lib/active_merchant/billing/gateways/realex.rb +374 -0
- data/lib/active_merchant/billing/gateways/redsys.rb +534 -0
- data/lib/active_merchant/billing/gateways/s5.rb +246 -0
- data/lib/active_merchant/billing/gateways/safe_charge.rb +262 -0
- data/lib/active_merchant/billing/gateways/sage.rb +448 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +142 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +267 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +200 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +292 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +104 -0
- data/lib/active_merchant/billing/gateways/securion_pay.rb +264 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +280 -0
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +306 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +790 -0
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +267 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +152 -0
- data/lib/active_merchant/billing/gateways/telr.rb +274 -0
- data/lib/active_merchant/billing/gateways/tns.rb +22 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +239 -0
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +608 -0
- data/lib/active_merchant/billing/gateways/transact_pro.rb +224 -0
- data/lib/active_merchant/billing/gateways/transax.rb +22 -0
- data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
- data/lib/active_merchant/billing/gateways/trexle.rb +218 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +490 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1620 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +355 -0
- data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +225 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +176 -0
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +245 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
- data/lib/active_merchant/billing/gateways/wepay.rb +237 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +432 -0
- data/lib/active_merchant/billing/gateways/world_net.rb +344 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +634 -0
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +215 -0
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
- data/lib/active_merchant/billing/model.rb +30 -0
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -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 +195 -0
- data/lib/active_merchant/country.rb +336 -0
- data/lib/active_merchant/empty.rb +20 -0
- data/lib/active_merchant/errors.rb +35 -0
- data/lib/active_merchant/net_http_ssl_connection.rb +10 -0
- data/lib/active_merchant/network_connection_retries.rb +80 -0
- data/lib/active_merchant/post_data.rb +25 -0
- data/lib/active_merchant/posts_data.rb +92 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/certs/cacert.pem +3988 -0
- data/lib/support/gateway_support.rb +69 -0
- data/lib/support/outbound_hosts.rb +28 -0
- data/lib/support/ssl_verify.rb +92 -0
- data/lib/support/ssl_version.rb +87 -0
- metadata +435 -0
@@ -0,0 +1,259 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class GarantiGateway < Gateway
|
4
|
+
self.live_url = 'https://sanalposprov.garanti.com.tr/VPServlet'
|
5
|
+
self.test_url = 'https://sanalposprovtest.garanti.com.tr/VPServlet'
|
6
|
+
|
7
|
+
# The countries the gateway supports merchants from as 2 digit ISO country codes
|
8
|
+
self.supported_countries = ['US', 'TR']
|
9
|
+
|
10
|
+
# The card types supported by the payment gateway
|
11
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
12
|
+
|
13
|
+
# The homepage URL of the gateway
|
14
|
+
self.homepage_url = 'https://sanalposweb.garanti.com.tr'
|
15
|
+
|
16
|
+
# The name of the gateway
|
17
|
+
self.display_name = 'Garanti Sanal POS'
|
18
|
+
|
19
|
+
self.default_currency = 'TRL'
|
20
|
+
|
21
|
+
self.money_format = :cents
|
22
|
+
|
23
|
+
CURRENCY_CODES = {
|
24
|
+
'YTL' => 949,
|
25
|
+
'TRL' => 949,
|
26
|
+
'TL' => 949,
|
27
|
+
'USD' => 840,
|
28
|
+
'EUR' => 978,
|
29
|
+
'GBP' => 826,
|
30
|
+
'JPY' => 392
|
31
|
+
}
|
32
|
+
|
33
|
+
def initialize(options = {})
|
34
|
+
requires!(options, :login, :password, :terminal_id, :merchant_id)
|
35
|
+
super
|
36
|
+
end
|
37
|
+
|
38
|
+
def purchase(money, credit_card, options = {})
|
39
|
+
options = options.merge(:gvp_order_type => 'sales')
|
40
|
+
commit(money, build_sale_request(money, credit_card, options))
|
41
|
+
end
|
42
|
+
|
43
|
+
def authorize(money, credit_card, options = {})
|
44
|
+
options = options.merge(:gvp_order_type => 'preauth')
|
45
|
+
commit(money, build_authorize_request(money, credit_card, options))
|
46
|
+
end
|
47
|
+
|
48
|
+
def capture(money, ref_id, options = {})
|
49
|
+
options = options.merge(:gvp_order_type => 'postauth')
|
50
|
+
commit(money, build_capture_request(money, ref_id, options))
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def security_data
|
56
|
+
rjusted_terminal_id = @options[:terminal_id].to_s.rjust(9, '0')
|
57
|
+
Digest::SHA1.hexdigest(@options[:password].to_s + rjusted_terminal_id).upcase
|
58
|
+
end
|
59
|
+
|
60
|
+
def generate_hash_data(order_id, terminal_id, credit_card_number, amount, security_data)
|
61
|
+
data = [order_id, terminal_id, credit_card_number, amount, security_data].join
|
62
|
+
Digest::SHA1.hexdigest(data).upcase
|
63
|
+
end
|
64
|
+
|
65
|
+
def build_xml_request(money, credit_card, options, &block)
|
66
|
+
card_number = credit_card.respond_to?(:number) ? credit_card.number : ''
|
67
|
+
hash_data = generate_hash_data(format_order_id(options[:order_id]), @options[:terminal_id], card_number, amount(money), security_data)
|
68
|
+
|
69
|
+
xml = Builder::XmlMarkup.new(:indent => 2)
|
70
|
+
xml.instruct! :xml, :version => '1.0', :encoding => 'UTF-8'
|
71
|
+
|
72
|
+
xml.tag! 'GVPSRequest' do
|
73
|
+
xml.tag! 'Mode', test? ? 'TEST' : 'PROD'
|
74
|
+
xml.tag! 'Version', 'V0.01'
|
75
|
+
xml.tag! 'Terminal' do
|
76
|
+
xml.tag! 'ProvUserID', 'PROVAUT'
|
77
|
+
xml.tag! 'HashData', hash_data
|
78
|
+
xml.tag! 'UserID', @options[:login]
|
79
|
+
xml.tag! 'ID', @options[:terminal_id]
|
80
|
+
xml.tag! 'MerchantID', @options[:merchant_id]
|
81
|
+
end
|
82
|
+
|
83
|
+
if block_given?
|
84
|
+
yield xml
|
85
|
+
else
|
86
|
+
xml.target!
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def build_sale_request(money, credit_card, options)
|
92
|
+
build_xml_request(money, credit_card, options) do |xml|
|
93
|
+
add_customer_data(xml, options)
|
94
|
+
add_order_data(xml, options) do
|
95
|
+
add_addresses(xml, options)
|
96
|
+
end
|
97
|
+
add_credit_card(xml, credit_card)
|
98
|
+
add_transaction_data(xml, money, options)
|
99
|
+
|
100
|
+
xml.target!
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def build_authorize_request(money, credit_card, options)
|
105
|
+
build_xml_request(money, credit_card, options) do |xml|
|
106
|
+
add_customer_data(xml, options)
|
107
|
+
add_order_data(xml, options) do
|
108
|
+
add_addresses(xml, options)
|
109
|
+
end
|
110
|
+
add_credit_card(xml, credit_card)
|
111
|
+
add_transaction_data(xml, money, options)
|
112
|
+
|
113
|
+
xml.target!
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def build_capture_request(money, ref_id, options)
|
118
|
+
options = options.merge(:order_id => ref_id)
|
119
|
+
build_xml_request(money, ref_id, options) do |xml|
|
120
|
+
add_customer_data(xml, options)
|
121
|
+
add_order_data(xml, options)
|
122
|
+
add_transaction_data(xml, money, options)
|
123
|
+
|
124
|
+
xml.target!
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def add_customer_data(xml, options)
|
129
|
+
xml.tag! 'Customer' do
|
130
|
+
xml.tag! 'IPAddress', options[:ip] || '1.1.1.1'
|
131
|
+
xml.tag! 'EmailAddress', options[:email]
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def add_order_data(xml, options, &block)
|
136
|
+
xml.tag! 'Order' do
|
137
|
+
xml.tag! 'OrderID', format_order_id(options[:order_id])
|
138
|
+
xml.tag! 'GroupID'
|
139
|
+
|
140
|
+
if block_given?
|
141
|
+
yield xml
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def add_credit_card(xml, credit_card)
|
147
|
+
xml.tag! 'Card' do
|
148
|
+
xml.tag! 'Number', credit_card.number
|
149
|
+
xml.tag! 'ExpireDate', [format_exp(credit_card.month), format_exp(credit_card.year)].join
|
150
|
+
xml.tag! 'CVV2', credit_card.verification_value
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def format_exp(value)
|
155
|
+
format(value, :two_digits)
|
156
|
+
end
|
157
|
+
|
158
|
+
# OrderId field must be A-Za-z0-9_ format and max 36 char
|
159
|
+
def format_order_id(order_id)
|
160
|
+
order_id.to_s.gsub(/[^A-Za-z0-9_]/, '')[0...36]
|
161
|
+
end
|
162
|
+
|
163
|
+
def add_addresses(xml, options)
|
164
|
+
xml.tag! 'AddressList' do
|
165
|
+
if billing_address = options[:billing_address] || options[:address]
|
166
|
+
xml.tag! 'Address' do
|
167
|
+
xml.tag! 'Type', 'B'
|
168
|
+
add_address(xml, billing_address)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
if options[:shipping_address]
|
173
|
+
xml.tag! 'Address' do
|
174
|
+
xml.tag! 'Type', 'S'
|
175
|
+
add_address(xml, options[:shipping_address])
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
def add_address(xml, address)
|
182
|
+
xml.tag! 'Name', normalize(address[:name])
|
183
|
+
address_text = address[:address1]
|
184
|
+
address_text << " #{address[:address2]}" if address[:address2]
|
185
|
+
xml.tag! 'Text', normalize(address_text)
|
186
|
+
xml.tag! 'City', normalize(address[:city])
|
187
|
+
xml.tag! 'District', normalize(address[:state])
|
188
|
+
xml.tag! 'PostalCode', address[:zip]
|
189
|
+
xml.tag! 'Country', normalize(address[:country])
|
190
|
+
xml.tag! 'Company', normalize(address[:company])
|
191
|
+
xml.tag! 'PhoneNumber', address[:phone].to_s.gsub(/[^0-9]/, '') if address[:phone]
|
192
|
+
end
|
193
|
+
|
194
|
+
def normalize(text)
|
195
|
+
return unless text
|
196
|
+
|
197
|
+
if ActiveSupport::Inflector.method(:transliterate).arity == -2
|
198
|
+
ActiveSupport::Inflector.transliterate(text, '')
|
199
|
+
else
|
200
|
+
text.gsub(/[^\x00-\x7F]+/, '')
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
def add_transaction_data(xml, money, options)
|
205
|
+
xml.tag! 'Transaction' do
|
206
|
+
xml.tag! 'Type', options[:gvp_order_type]
|
207
|
+
xml.tag! 'Amount', amount(money)
|
208
|
+
xml.tag! 'CurrencyCode', currency_code(options[:currency] || currency(money))
|
209
|
+
xml.tag! 'CardholderPresentCode', 0
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
def currency_code(currency)
|
214
|
+
CURRENCY_CODES[currency] || CURRENCY_CODES[default_currency]
|
215
|
+
end
|
216
|
+
|
217
|
+
def commit(money, request)
|
218
|
+
url = test? ? self.test_url : self.live_url
|
219
|
+
raw_response = ssl_post(url, 'data=' + request)
|
220
|
+
response = parse(raw_response)
|
221
|
+
|
222
|
+
success = success?(response)
|
223
|
+
|
224
|
+
Response.new(success,
|
225
|
+
success ? 'Approved' : "Declined (Reason: #{response[:reason_code]} - #{response[:error_msg]} - #{response[:sys_err_msg]})",
|
226
|
+
response,
|
227
|
+
:test => test?,
|
228
|
+
:authorization => response[:order_id])
|
229
|
+
end
|
230
|
+
|
231
|
+
def parse(body)
|
232
|
+
xml = REXML::Document.new(strip_invalid_xml_chars(body))
|
233
|
+
|
234
|
+
response = {}
|
235
|
+
xml.root.elements.to_a.each do |node|
|
236
|
+
parse_element(response, node)
|
237
|
+
end
|
238
|
+
response
|
239
|
+
end
|
240
|
+
|
241
|
+
def parse_element(response, node)
|
242
|
+
if node.has_elements?
|
243
|
+
node.elements.each { |element| parse_element(response, element) }
|
244
|
+
else
|
245
|
+
response[node.name.underscore.to_sym] = node.text
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
def success?(response)
|
250
|
+
response[:message] == 'Approved'
|
251
|
+
end
|
252
|
+
|
253
|
+
def strip_invalid_xml_chars(xml)
|
254
|
+
xml.gsub(/&(?!(?:[a-z]+|#[0-9]+|x[a-zA-Z0-9]+);)/, '&')
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
@@ -0,0 +1,336 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class GlobalCollectGateway < Gateway
|
4
|
+
self.display_name = 'GlobalCollect'
|
5
|
+
self.homepage_url = 'http://www.globalcollect.com/'
|
6
|
+
|
7
|
+
self.test_url = 'https://eu.sandbox.api-ingenico.com'
|
8
|
+
self.live_url = 'https://api.globalcollect.com'
|
9
|
+
|
10
|
+
self.supported_countries = ['AD', 'AE', 'AG', 'AI', 'AL', 'AM', 'AO', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IS', 'IT', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PL', 'PN', 'PS', 'PT', 'PW', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SR', 'ST', 'SV', 'SZ', 'TC', 'TD', 'TG', 'TH', 'TJ', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'US', 'UY', 'UZ', 'VC', 'VE', 'VG', 'VI', 'VN', 'WF', 'WS', 'ZA', 'ZM', 'ZW']
|
11
|
+
self.default_currency = 'USD'
|
12
|
+
self.money_format = :cents
|
13
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :naranja, :cabal]
|
14
|
+
|
15
|
+
def initialize(options={})
|
16
|
+
requires!(options, :merchant_id, :api_key_id, :secret_api_key)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def purchase(money, payment, options={})
|
21
|
+
MultiResponse.run do |r|
|
22
|
+
r.process { authorize(money, payment, options) }
|
23
|
+
r.process { capture(money, r.authorization, options) } unless capture_requested?(r)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def authorize(money, payment, options={})
|
28
|
+
post = nestable_hash
|
29
|
+
add_order(post, money, options)
|
30
|
+
add_payment(post, payment, options)
|
31
|
+
add_customer_data(post, options, payment)
|
32
|
+
add_address(post, payment, options)
|
33
|
+
add_creator_info(post, options)
|
34
|
+
add_fraud_fields(post, options)
|
35
|
+
|
36
|
+
commit(:authorize, post)
|
37
|
+
end
|
38
|
+
|
39
|
+
def capture(money, authorization, options={})
|
40
|
+
post = nestable_hash
|
41
|
+
add_order(post, money, options, capture: true)
|
42
|
+
add_customer_data(post, options)
|
43
|
+
add_creator_info(post, options)
|
44
|
+
commit(:capture, post, authorization)
|
45
|
+
end
|
46
|
+
|
47
|
+
def refund(money, authorization, options={})
|
48
|
+
post = nestable_hash
|
49
|
+
add_amount(post, money, options)
|
50
|
+
add_refund_customer_data(post, options)
|
51
|
+
add_creator_info(post, options)
|
52
|
+
commit(:refund, post, authorization)
|
53
|
+
end
|
54
|
+
|
55
|
+
def void(authorization, options={})
|
56
|
+
post = nestable_hash
|
57
|
+
add_creator_info(post, options)
|
58
|
+
commit(:void, post, authorization)
|
59
|
+
end
|
60
|
+
|
61
|
+
def verify(payment, options={})
|
62
|
+
MultiResponse.run(:use_first_response) do |r|
|
63
|
+
r.process { authorize(100, payment, options) }
|
64
|
+
r.process { void(r.authorization, options) }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def supports_scrubbing?
|
69
|
+
true
|
70
|
+
end
|
71
|
+
|
72
|
+
def scrub(transcript)
|
73
|
+
transcript.
|
74
|
+
gsub(%r((Authorization: )[^\\]*)i, '\1[FILTERED]').
|
75
|
+
gsub(%r(("cardNumber\\+":\\+")\d+), '\1[FILTERED]').
|
76
|
+
gsub(%r(("cvv\\+":\\+")\d+), '\1[FILTERED]')
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
BRAND_MAP = {
|
82
|
+
'visa' => '1',
|
83
|
+
'american_express' => '2',
|
84
|
+
'master' => '3',
|
85
|
+
'discover' => '128',
|
86
|
+
'jcb' => '125',
|
87
|
+
'diners_club' => '132'
|
88
|
+
}
|
89
|
+
|
90
|
+
def add_order(post, money, options, capture: false)
|
91
|
+
if capture
|
92
|
+
post['amount'] = amount(money)
|
93
|
+
else
|
94
|
+
add_amount(post['order'], money, options)
|
95
|
+
end
|
96
|
+
post['order']['references'] = {
|
97
|
+
'merchantReference' => options[:order_id],
|
98
|
+
'descriptor' => options[:description] # Max 256 chars
|
99
|
+
}
|
100
|
+
post['order']['references']['invoiceData'] = {
|
101
|
+
'invoiceNumber' => options[:invoice]
|
102
|
+
}
|
103
|
+
end
|
104
|
+
|
105
|
+
def add_creator_info(post, options)
|
106
|
+
post['sdkIdentifier'] = options[:sdk_identifier] if options[:sdk_identifier]
|
107
|
+
post['sdkCreator'] = options[:sdk_creator] if options[:sdk_creator]
|
108
|
+
post['integrator'] = options[:integrator] if options[:integrator]
|
109
|
+
post['shoppingCartExtension'] = {}
|
110
|
+
post['shoppingCartExtension']['creator'] = options[:creator] if options[:creator]
|
111
|
+
post['shoppingCartExtension']['name'] = options[:name] if options[:name]
|
112
|
+
post['shoppingCartExtension']['version'] = options[:version] if options[:version]
|
113
|
+
post['shoppingCartExtension']['extensionID'] = options[:extension_ID] if options[:extension_ID]
|
114
|
+
end
|
115
|
+
|
116
|
+
def add_amount(post, money, options={})
|
117
|
+
post['amountOfMoney'] = {
|
118
|
+
'amount' => amount(money),
|
119
|
+
'currencyCode' => options[:currency] || currency(money)
|
120
|
+
}
|
121
|
+
end
|
122
|
+
|
123
|
+
def add_payment(post, payment, options)
|
124
|
+
year = format(payment.year, :two_digits)
|
125
|
+
month = format(payment.month, :two_digits)
|
126
|
+
expirydate = "#{month}#{year}"
|
127
|
+
pre_authorization = options[:pre_authorization] ? 'PRE_AUTHORIZATION' : 'FINAL_AUTHORIZATION'
|
128
|
+
|
129
|
+
post['cardPaymentMethodSpecificInput'] = {
|
130
|
+
'paymentProductId' => BRAND_MAP[payment.brand],
|
131
|
+
'skipAuthentication' => 'true', # refers to 3DSecure
|
132
|
+
'skipFraudService' => 'true',
|
133
|
+
'authorizationMode' => pre_authorization
|
134
|
+
}
|
135
|
+
post['cardPaymentMethodSpecificInput']['card'] = {
|
136
|
+
'cvv' => payment.verification_value,
|
137
|
+
'cardNumber' => payment.number,
|
138
|
+
'expiryDate' => expirydate,
|
139
|
+
'cardholderName' => payment.name
|
140
|
+
}
|
141
|
+
end
|
142
|
+
|
143
|
+
def add_customer_data(post, options, payment = nil)
|
144
|
+
if payment
|
145
|
+
post['order']['customer']['personalInformation']['name']['firstName'] = payment.first_name[0..14] if payment.first_name
|
146
|
+
post['order']['customer']['personalInformation']['name']['surname'] = payment.last_name[0..69] if payment.last_name
|
147
|
+
end
|
148
|
+
post['order']['customer']['merchantCustomerId'] = options[:customer] if options[:customer]
|
149
|
+
post['order']['customer']['companyInformation']['name'] = options[:company] if options[:company]
|
150
|
+
post['order']['customer']['contactDetails']['emailAddress'] = options[:email] if options[:email]
|
151
|
+
if address = options[:billing_address] || options[:address]
|
152
|
+
post['order']['customer']['contactDetails']['phoneNumber'] = address[:phone] if address[:phone]
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def add_refund_customer_data(post, options)
|
157
|
+
if address = options[:billing_address] || options[:address]
|
158
|
+
post['customer']['address'] = {
|
159
|
+
'countryCode' => address[:country]
|
160
|
+
}
|
161
|
+
post['customer']['contactDetails']['emailAddress'] = options[:email] if options[:email]
|
162
|
+
if address = options[:billing_address] || options[:address]
|
163
|
+
post['customer']['contactDetails']['phoneNumber'] = address[:phone] if address[:phone]
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def add_address(post, creditcard, options)
|
169
|
+
shipping_address = options[:shipping_address]
|
170
|
+
if billing_address = options[:billing_address] || options[:address]
|
171
|
+
post['order']['customer']['billingAddress'] = {
|
172
|
+
'street' => billing_address[:address1],
|
173
|
+
'additionalInfo' => billing_address[:address2],
|
174
|
+
'zip' => billing_address[:zip],
|
175
|
+
'city' => billing_address[:city],
|
176
|
+
'state' => billing_address[:state],
|
177
|
+
'countryCode' => billing_address[:country]
|
178
|
+
}
|
179
|
+
end
|
180
|
+
if shipping_address
|
181
|
+
post['order']['customer']['shippingAddress'] = {
|
182
|
+
'street' => shipping_address[:address1],
|
183
|
+
'additionalInfo' => shipping_address[:address2],
|
184
|
+
'zip' => shipping_address[:zip],
|
185
|
+
'city' => shipping_address[:city],
|
186
|
+
'state' => shipping_address[:state],
|
187
|
+
'countryCode' => shipping_address[:country]
|
188
|
+
}
|
189
|
+
post['order']['customer']['shippingAddress']['name'] = {
|
190
|
+
'firstName' => shipping_address[:firstname],
|
191
|
+
'surname' => shipping_address[:lastname]
|
192
|
+
}
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
def add_fraud_fields(post, options)
|
197
|
+
fraud_fields = {}
|
198
|
+
fraud_fields.merge!(options[:fraud_fields]) if options[:fraud_fields]
|
199
|
+
fraud_fields[:customerIpAddress] = options[:ip] if options[:ip]
|
200
|
+
|
201
|
+
post['fraudFields'] = fraud_fields unless fraud_fields.empty?
|
202
|
+
end
|
203
|
+
|
204
|
+
def parse(body)
|
205
|
+
JSON.parse(body)
|
206
|
+
end
|
207
|
+
|
208
|
+
def url(action, authorization)
|
209
|
+
(test? ? test_url : live_url) + uri(action, authorization)
|
210
|
+
end
|
211
|
+
|
212
|
+
def uri(action, authorization)
|
213
|
+
uri = "/v1/#{@options[:merchant_id]}/"
|
214
|
+
case action
|
215
|
+
when :authorize
|
216
|
+
uri + 'payments'
|
217
|
+
when :capture
|
218
|
+
uri + "payments/#{authorization}/approve"
|
219
|
+
when :refund
|
220
|
+
uri + "payments/#{authorization}/refund"
|
221
|
+
when :void
|
222
|
+
uri + "payments/#{authorization}/cancel"
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
def commit(action, post, authorization = nil)
|
227
|
+
begin
|
228
|
+
raw_response = ssl_post(url(action, authorization), post.to_json, headers(action, post, authorization))
|
229
|
+
response = parse(raw_response)
|
230
|
+
rescue ResponseError => e
|
231
|
+
if e.response.code.to_i >= 400
|
232
|
+
response = parse(e.response.body)
|
233
|
+
end
|
234
|
+
rescue JSON::ParserError
|
235
|
+
response = json_error(raw_response)
|
236
|
+
end
|
237
|
+
|
238
|
+
succeeded = success_from(response)
|
239
|
+
Response.new(
|
240
|
+
succeeded,
|
241
|
+
message_from(succeeded, response),
|
242
|
+
response,
|
243
|
+
authorization: authorization_from(succeeded, response),
|
244
|
+
error_code: error_code_from(succeeded, response),
|
245
|
+
test: test?
|
246
|
+
)
|
247
|
+
end
|
248
|
+
|
249
|
+
def json_error(raw_response)
|
250
|
+
{
|
251
|
+
'error_message' => 'Invalid response received from the Ingenico ePayments (formerly GlobalCollect) API. Please contact Ingenico ePayments if you continue to receive this message.' \
|
252
|
+
" (The raw response returned by the API was #{raw_response.inspect})",
|
253
|
+
'status' => 'REJECTED'
|
254
|
+
}
|
255
|
+
end
|
256
|
+
|
257
|
+
def headers(action, post, authorization = nil)
|
258
|
+
{
|
259
|
+
'Content-Type' => content_type,
|
260
|
+
'Authorization' => auth_digest(action, post, authorization),
|
261
|
+
'Date' => date
|
262
|
+
}
|
263
|
+
end
|
264
|
+
|
265
|
+
def auth_digest(action, post, authorization = nil)
|
266
|
+
data = <<-EOS
|
267
|
+
POST
|
268
|
+
#{content_type}
|
269
|
+
#{date}
|
270
|
+
#{uri(action, authorization)}
|
271
|
+
EOS
|
272
|
+
digest = OpenSSL::Digest.new('sha256')
|
273
|
+
key = @options[:secret_api_key]
|
274
|
+
"GCS v1HMAC:#{@options[:api_key_id]}:#{Base64.strict_encode64(OpenSSL::HMAC.digest(digest, key, data))}"
|
275
|
+
end
|
276
|
+
|
277
|
+
def date
|
278
|
+
@date ||= Time.now.strftime('%a, %d %b %Y %H:%M:%S %Z') # Must be same in digest and HTTP header
|
279
|
+
end
|
280
|
+
|
281
|
+
def content_type
|
282
|
+
'application/json'
|
283
|
+
end
|
284
|
+
|
285
|
+
def success_from(response)
|
286
|
+
!response['errorId'] && response['status'] != 'REJECTED'
|
287
|
+
end
|
288
|
+
|
289
|
+
def message_from(succeeded, response)
|
290
|
+
if succeeded
|
291
|
+
'Succeeded'
|
292
|
+
else
|
293
|
+
if errors = response['errors']
|
294
|
+
errors.first.try(:[], 'message')
|
295
|
+
elsif response['error_message']
|
296
|
+
response['error_message']
|
297
|
+
elsif response['status']
|
298
|
+
'Status: ' + response['status']
|
299
|
+
else
|
300
|
+
'No message available'
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
def authorization_from(succeeded, response)
|
306
|
+
if succeeded
|
307
|
+
response['id'] || response['payment']['id'] || response['paymentResult']['payment']['id']
|
308
|
+
elsif response['errorId']
|
309
|
+
response['errorId']
|
310
|
+
else
|
311
|
+
'GATEWAY ERROR'
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
def error_code_from(succeeded, response)
|
316
|
+
unless succeeded
|
317
|
+
if errors = response['errors']
|
318
|
+
errors.first.try(:[], 'code')
|
319
|
+
elsif status = response.try(:[], 'statusOutput').try(:[], 'statusCode')
|
320
|
+
status.to_s
|
321
|
+
else
|
322
|
+
'No error code available'
|
323
|
+
end
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
def nestable_hash
|
328
|
+
Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }
|
329
|
+
end
|
330
|
+
|
331
|
+
def capture_requested?(response)
|
332
|
+
response.params.try(:[], 'payment').try(:[], 'status') == 'CAPTURE_REQUESTED'
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|