swiss-crm-activemerchant 1.0.12
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 +4033 -0
- data/CONTRIBUTORS +568 -0
- data/MIT-LICENSE +20 -0
- data/README.md +252 -0
- data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
- data/lib/active_merchant/billing/avs_result.rb +95 -0
- data/lib/active_merchant/billing/base.rb +48 -0
- data/lib/active_merchant/billing/check.rb +112 -0
- data/lib/active_merchant/billing/compatibility.rb +118 -0
- data/lib/active_merchant/billing/credit_card.rb +451 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +512 -0
- data/lib/active_merchant/billing/cvv_result.rb +37 -0
- data/lib/active_merchant/billing/gateway.rb +332 -0
- data/lib/active_merchant/billing/gateways/adyen.rb +774 -0
- data/lib/active_merchant/billing/gateways/airwallex.rb +370 -0
- data/lib/active_merchant/billing/gateways/alelo.rb +256 -0
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +1125 -0
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +424 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +977 -0
- data/lib/active_merchant/billing/gateways/axcessms.rb +242 -0
- data/lib/active_merchant/billing/gateways/balanced.rb +263 -0
- data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -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 +397 -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/beanstream_core.rb +474 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +238 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -0
- data/lib/active_merchant/billing/gateways/blue_snap.rb +644 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +190 -0
- data/lib/active_merchant/billing/gateways/borgun.rb +272 -0
- data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +28 -0
- data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +952 -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 +338 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +21 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +394 -0
- data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
- data/lib/active_merchant/billing/gateways/cardprocess.rb +256 -0
- data/lib/active_merchant/billing/gateways/cashnet.rb +235 -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 +328 -0
- data/lib/active_merchant/billing/gateways/checkout.rb +212 -0
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +587 -0
- data/lib/active_merchant/billing/gateways/citrus_pay.rb +21 -0
- data/lib/active_merchant/billing/gateways/clearhaus.rb +219 -0
- data/lib/active_merchant/billing/gateways/commerce_hub.rb +366 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
- data/lib/active_merchant/billing/gateways/conekta.rb +230 -0
- data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
- data/lib/active_merchant/billing/gateways/credorax.rb +526 -0
- data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
- data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
- data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +1148 -0
- data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +454 -0
- data/lib/active_merchant/billing/gateways/d_local.rb +343 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +302 -0
- data/lib/active_merchant/billing/gateways/decidir.rb +358 -0
- data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
- data/lib/active_merchant/billing/gateways/digitzs.rb +295 -0
- data/lib/active_merchant/billing/gateways/ebanx.rb +346 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +475 -0
- data/lib/active_merchant/billing/gateways/element.rb +406 -0
- data/lib/active_merchant/billing/gateways/epay.rb +296 -0
- data/lib/active_merchant/billing/gateways/evo_ca.rb +307 -0
- data/lib/active_merchant/billing/gateways/eway.rb +226 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +289 -0
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +578 -0
- data/lib/active_merchant/billing/gateways/exact.rb +219 -0
- data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +223 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +158 -0
- data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
- data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +452 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -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/fluidpay.rb +275 -0
- data/lib/active_merchant/billing/gateways/forte.rb +286 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +256 -0
- data/lib/active_merchant/billing/gateways/global_collect.rb +580 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +193 -0
- data/lib/active_merchant/billing/gateways/hdfc.rb +205 -0
- data/lib/active_merchant/billing/gateways/hps.rb +472 -0
- data/lib/active_merchant/billing/gateways/iats_payments.rb +312 -0
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +213 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +159 -0
- data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +467 -0
- data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
- data/lib/active_merchant/billing/gateways/iveri.rb +290 -0
- data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +395 -0
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
- data/lib/active_merchant/billing/gateways/klarna.rb +317 -0
- data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
- data/lib/active_merchant/billing/gateways/kushki.rb +297 -0
- data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +448 -0
- data/lib/active_merchant/billing/gateways/litle.rb +643 -0
- data/lib/active_merchant/billing/gateways/mastercard.rb +286 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +348 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +228 -0
- data/lib/active_merchant/billing/gateways/merchant_one.rb +110 -0
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +313 -0
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +284 -0
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +248 -0
- data/lib/active_merchant/billing/gateways/mercury.rb +352 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +293 -0
- data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
- data/lib/active_merchant/billing/gateways/migs.rb +329 -0
- data/lib/active_merchant/billing/gateways/mit.rb +260 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +215 -0
- data/lib/active_merchant/billing/gateways/moka.rb +290 -0
- data/lib/active_merchant/billing/gateways/monei.rb +424 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +488 -0
- data/lib/active_merchant/billing/gateways/money_movers.rb +150 -0
- data/lib/active_merchant/billing/gateways/mundipagg.rb +366 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +299 -0
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +198 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
- data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +229 -0
- data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
- data/lib/active_merchant/billing/gateways/network_merchants.rb +238 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +396 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +509 -0
- data/lib/active_merchant/billing/gateways/omise.rb +323 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +246 -0
- data/lib/active_merchant/billing/gateways/opp.rb +394 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +331 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +45 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +1267 -0
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
- data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
- data/lib/active_merchant/billing/gateways/pago_facil.rb +120 -0
- data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
- data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -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_junction_v2.rb +206 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +110 -0
- data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +224 -0
- data/lib/active_merchant/billing/gateways/payeezy.rb +513 -0
- data/lib/active_merchant/billing/gateways/payex.rb +409 -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 +42 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +473 -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 +373 -0
- data/lib/active_merchant/billing/gateways/paymentez.rb +365 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +369 -0
- data/lib/active_merchant/billing/gateways/paynetworx.rb +228 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +718 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +69 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +136 -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 +272 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
- data/lib/active_merchant/billing/gateways/paypal_standard.rb +281 -0
- data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +159 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +204 -0
- data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
- data/lib/active_merchant/billing/gateways/payu_latam.rb +482 -0
- data/lib/active_merchant/billing/gateways/payway.rb +207 -0
- data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
- data/lib/active_merchant/billing/gateways/pin.rb +273 -0
- data/lib/active_merchant/billing/gateways/pixxels.rb +263 -0
- data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
- data/lib/active_merchant/billing/gateways/priority.rb +392 -0
- data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +295 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +302 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +274 -0
- data/lib/active_merchant/billing/gateways/quickbooks.rb +377 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +297 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +24 -0
- data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
- data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
- data/lib/active_merchant/billing/gateways/reach.rb +277 -0
- data/lib/active_merchant/billing/gateways/realex.rb +400 -0
- data/lib/active_merchant/billing/gateways/redsys.rb +723 -0
- data/lib/active_merchant/billing/gateways/s5.rb +247 -0
- data/lib/active_merchant/billing/gateways/safe_charge.rb +298 -0
- data/lib/active_merchant/billing/gateways/sage.rb +446 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +141 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +260 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +191 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +290 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +103 -0
- data/lib/active_merchant/billing/gateways/securion_pay.rb +305 -0
- data/lib/active_merchant/billing/gateways/shift4.rb +345 -0
- data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +274 -0
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +354 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +866 -0
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +602 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +151 -0
- data/lib/active_merchant/billing/gateways/telr.rb +273 -0
- data/lib/active_merchant/billing/gateways/tns.rb +23 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +240 -0
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +612 -0
- data/lib/active_merchant/billing/gateways/transact_pro.rb +222 -0
- data/lib/active_merchant/billing/gateways/transax.rb +21 -0
- data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
- data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +500 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +24 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1612 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +367 -0
- data/lib/active_merchant/billing/gateways/vanco.rb +303 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +224 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +250 -0
- data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
- data/lib/active_merchant/billing/gateways/wepay.rb +235 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +430 -0
- data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
- data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +1050 -0
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
- data/lib/active_merchant/billing/gateways.rb +14 -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 +121 -0
- data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
- data/lib/active_merchant/billing.rb +16 -0
- data/lib/active_merchant/connection.rb +194 -0
- data/lib/active_merchant/country.rb +338 -0
- data/lib/active_merchant/empty.rb +20 -0
- data/lib/active_merchant/errors.rb +38 -0
- data/lib/active_merchant/net_http_ssl_connection.rb +11 -0
- data/lib/active_merchant/network_connection_retries.rb +78 -0
- data/lib/active_merchant/post_data.rb +26 -0
- data/lib/active_merchant/posts_data.rb +92 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/active_merchant.rb +63 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/certs/cacert.pem +3214 -0
- data/lib/support/gateway_support.rb +69 -0
- data/lib/support/outbound_hosts.rb +28 -0
- data/lib/support/ssl_verify.rb +88 -0
- data/lib/support/ssl_version.rb +86 -0
- metadata +506 -0
@@ -0,0 +1,1148 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
# Initial setup instructions can be found in
|
4
|
+
# http://apps.cybersource.com/library/documentation/dev_guides/SOAP_Toolkits/SOAP_toolkits.pdf
|
5
|
+
#
|
6
|
+
# Important Notes
|
7
|
+
# * For checks you can purchase and store.
|
8
|
+
# * AVS and CVV only work against the production server. You will always
|
9
|
+
# get back X for AVS and no response for CVV against the test server.
|
10
|
+
# * Nexus is the list of states or provinces where you have a physical
|
11
|
+
# presence. Nexus is used to calculate tax. Leave blank to tax everyone.
|
12
|
+
# * If you want to calculate VAT for overseas customers you must supply a
|
13
|
+
# registration number in the options hash as vat_reg_number.
|
14
|
+
# * productCode is a value in the line_items hash that is used to tell
|
15
|
+
# CyberSource what kind of item you are selling. It is used when
|
16
|
+
# calculating tax/VAT.
|
17
|
+
# * All transactions use dollar values.
|
18
|
+
# * The order of the XML elements does matter, make sure to follow the order in
|
19
|
+
# the documentation exactly.
|
20
|
+
class CyberSourceGateway < Gateway
|
21
|
+
self.test_url = 'https://ics2wstesta.ic3.com/commerce/1.x/transactionProcessor'
|
22
|
+
self.live_url = 'https://ics2wsa.ic3.com/commerce/1.x/transactionProcessor'
|
23
|
+
|
24
|
+
# Schema files can be found here: https://ics2ws.ic3.com/commerce/1.x/transactionProcessor/
|
25
|
+
TEST_XSD_VERSION = '1.201'
|
26
|
+
PRODUCTION_XSD_VERSION = '1.201'
|
27
|
+
ECI_BRAND_MAPPING = {
|
28
|
+
visa: 'vbv',
|
29
|
+
master: 'spa',
|
30
|
+
maestro: 'spa',
|
31
|
+
american_express: 'aesk',
|
32
|
+
jcb: 'js',
|
33
|
+
discover: 'pb',
|
34
|
+
diners_club: 'pb'
|
35
|
+
}.freeze
|
36
|
+
DEFAULT_COLLECTION_INDICATOR = 2
|
37
|
+
|
38
|
+
self.supported_cardtypes = %i[visa master american_express discover diners_club jcb dankort maestro elo]
|
39
|
+
self.supported_countries = %w(US AE BR CA CN DK FI FR DE IN JP MX NO SE GB SG LB PK)
|
40
|
+
|
41
|
+
self.default_currency = 'USD'
|
42
|
+
self.currencies_without_fractions = %w(JPY)
|
43
|
+
|
44
|
+
self.homepage_url = 'http://www.cybersource.com'
|
45
|
+
self.display_name = 'CyberSource'
|
46
|
+
|
47
|
+
@@credit_card_codes = {
|
48
|
+
visa: '001',
|
49
|
+
master: '002',
|
50
|
+
american_express: '003',
|
51
|
+
discover: '004',
|
52
|
+
diners_club: '005',
|
53
|
+
jcb: '007',
|
54
|
+
dankort: '034',
|
55
|
+
maestro: '042',
|
56
|
+
elo: '054'
|
57
|
+
}
|
58
|
+
|
59
|
+
@@decision_codes = {
|
60
|
+
accept: 'ACCEPT',
|
61
|
+
review: 'REVIEW'
|
62
|
+
}
|
63
|
+
|
64
|
+
@@response_codes = {
|
65
|
+
r100: 'Successful transaction',
|
66
|
+
r101: 'Request is missing one or more required fields',
|
67
|
+
r102: 'One or more fields contains invalid data',
|
68
|
+
r104: 'The merchantReferenceCode sent with this authorization request matches the merchantReferenceCode of another authorization request that you sent in the last 15 minutes.', r110: 'Partial amount was approved',
|
69
|
+
r150: 'General failure',
|
70
|
+
r151: 'The request was received but a server time-out occurred',
|
71
|
+
r152: 'The request was received, but a service timed out',
|
72
|
+
r200: 'The authorization request was approved by the issuing bank but declined by CyberSource because it did not pass the AVS check',
|
73
|
+
r201: 'The issuing bank has questions about the request',
|
74
|
+
r202: 'Expired card',
|
75
|
+
r203: 'General decline of the card',
|
76
|
+
r204: 'Insufficient funds in the account',
|
77
|
+
r205: 'Stolen or lost card',
|
78
|
+
r207: 'Issuing bank unavailable',
|
79
|
+
r208: 'Inactive card or card not authorized for card-not-present transactions',
|
80
|
+
r209: 'American Express Card Identifiction Digits (CID) did not match',
|
81
|
+
r210: 'The card has reached the credit limit',
|
82
|
+
r211: 'Invalid card verification number',
|
83
|
+
r220: 'Generic Decline.',
|
84
|
+
r221: "The customer matched an entry on the processor's negative file",
|
85
|
+
r222: 'customer\'s account is frozen',
|
86
|
+
r230: 'The authorization request was approved by the issuing bank but declined by CyberSource because it did not pass the card verification check',
|
87
|
+
r231: 'Invalid account number',
|
88
|
+
r232: 'The card type is not accepted by the payment processor',
|
89
|
+
r233: 'General decline by the processor',
|
90
|
+
r234: 'A problem exists with your CyberSource merchant configuration',
|
91
|
+
r235: 'The requested amount exceeds the originally authorized amount',
|
92
|
+
r236: 'Processor failure',
|
93
|
+
r237: 'The authorization has already been reversed',
|
94
|
+
r238: 'The authorization has already been captured',
|
95
|
+
r239: 'The requested transaction amount must match the previous transaction amount',
|
96
|
+
r240: 'The card type sent is invalid or does not correlate with the credit card number',
|
97
|
+
r241: 'The request ID is invalid',
|
98
|
+
r242: 'You requested a capture, but there is no corresponding, unused authorization record.',
|
99
|
+
r243: 'The transaction has already been settled or reversed',
|
100
|
+
r244: 'The bank account number failed the validation check',
|
101
|
+
r246: 'The capture or credit is not voidable because the capture or credit information has already been submitted to your processor',
|
102
|
+
r247: 'You requested a credit for a capture that was previously voided',
|
103
|
+
r248: 'The boleto request was declined by your processor.',
|
104
|
+
r250: 'The request was received, but a time-out occurred with the payment processor',
|
105
|
+
r251: 'The Pinless Debit card\'s use frequency or maximum amount per use has been exceeded.',
|
106
|
+
r254: 'Your CyberSource account is prohibited from processing stand-alone refunds',
|
107
|
+
r255: 'Your CyberSource account is not configured to process the service in the country you specified',
|
108
|
+
r400: 'Soft Decline - Fraud score exceeds threshold.',
|
109
|
+
r450: 'Apartment number missing or not found.',
|
110
|
+
r451: 'Insufficient address information.',
|
111
|
+
r452: 'House/Box number not found on street.',
|
112
|
+
r453: 'Multiple address matches were found.',
|
113
|
+
r454: 'P.O. Box identifier not found or out of range.',
|
114
|
+
r455: 'Route service identifier not found or out of range.',
|
115
|
+
r456: 'Street name not found in Postal code.',
|
116
|
+
r457: 'Postal code not found in database.',
|
117
|
+
r458: 'Unable to verify or correct address.',
|
118
|
+
r459: 'Multiple addres matches were found (international)',
|
119
|
+
r460: 'Address match not found (no reason given)',
|
120
|
+
r461: 'Unsupported character set',
|
121
|
+
r475: 'The cardholder is enrolled in Payer Authentication. Please authenticate the cardholder before continuing with the transaction.',
|
122
|
+
r476: 'Encountered a Payer Authentication problem. Payer could not be authenticated.',
|
123
|
+
r478: 'Strong customer authentication (SCA) is required for this transaction.',
|
124
|
+
r480: 'The order is marked for review by Decision Manager',
|
125
|
+
r481: 'The order has been rejected by Decision Manager',
|
126
|
+
r490: 'Your aggregator or acquirer is not accepting transactions from you at this time.',
|
127
|
+
r491: 'Your aggregator or acquirer is not accepting this transaction.',
|
128
|
+
r520: 'Soft Decline - The authorization request was approved by the issuing bank but declined by CyberSource based on your Smart Authorization settings.',
|
129
|
+
r700: 'The customer matched the Denied Parties List',
|
130
|
+
r701: 'Export bill_country/ship_country match',
|
131
|
+
r702: 'Export email_country match',
|
132
|
+
r703: 'Export hostname_country/ip_country match'
|
133
|
+
}
|
134
|
+
|
135
|
+
# These are the options that can be used when creating a new CyberSource
|
136
|
+
# Gateway object.
|
137
|
+
#
|
138
|
+
# :login => your username
|
139
|
+
#
|
140
|
+
# :password => the transaction key you generated in the Business Center
|
141
|
+
#
|
142
|
+
# :test => true sets the gateway to test mode
|
143
|
+
#
|
144
|
+
# :vat_reg_number => your VAT registration number
|
145
|
+
#
|
146
|
+
# :nexus => "WI CA QC" sets the states/provinces where you have a physical
|
147
|
+
# presence for tax purposes
|
148
|
+
#
|
149
|
+
# :ignore_avs => true don't want to use AVS so continue processing even
|
150
|
+
# if AVS would have failed
|
151
|
+
#
|
152
|
+
# :ignore_cvv => true don't want to use CVV so continue processing even
|
153
|
+
# if CVV would have failed
|
154
|
+
def initialize(options = {})
|
155
|
+
requires!(options, :login, :password)
|
156
|
+
super
|
157
|
+
end
|
158
|
+
|
159
|
+
def authorize(money, creditcard_or_reference, options = {})
|
160
|
+
setup_address_hash(options)
|
161
|
+
commit(build_auth_request(money, creditcard_or_reference, options), :authorize, money, options)
|
162
|
+
end
|
163
|
+
|
164
|
+
def capture(money, authorization, options = {})
|
165
|
+
setup_address_hash(options)
|
166
|
+
commit(build_capture_request(money, authorization, options), :capture, money, options)
|
167
|
+
end
|
168
|
+
|
169
|
+
def purchase(money, payment_method_or_reference, options = {})
|
170
|
+
setup_address_hash(options)
|
171
|
+
commit(build_purchase_request(money, payment_method_or_reference, options), :purchase, money, options)
|
172
|
+
end
|
173
|
+
|
174
|
+
def void(identification, options = {})
|
175
|
+
commit(build_void_request(identification, options), :void, nil, options)
|
176
|
+
end
|
177
|
+
|
178
|
+
def refund(money, identification, options = {})
|
179
|
+
commit(build_refund_request(money, identification, options), :refund, money, options)
|
180
|
+
end
|
181
|
+
|
182
|
+
def adjust(money, authorization, options = {})
|
183
|
+
commit(build_adjust_request(money, authorization, options), :adjust, money, options)
|
184
|
+
end
|
185
|
+
|
186
|
+
def verify(payment, options = {})
|
187
|
+
amount = eligible_for_zero_auth?(payment, options) ? 0 : 100
|
188
|
+
MultiResponse.run(:use_first_response) do |r|
|
189
|
+
r.process { authorize(amount, payment, options) }
|
190
|
+
r.process(:ignore_result) { void(r.authorization, options) } unless amount == 0
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
# Adds credit to a card or subscription (stand alone credit).
|
195
|
+
def credit(money, creditcard_or_reference, options = {})
|
196
|
+
setup_address_hash(options)
|
197
|
+
commit(build_credit_request(money, creditcard_or_reference, options), :credit, money, options)
|
198
|
+
end
|
199
|
+
|
200
|
+
# Stores a customer subscription/profile with type "on-demand".
|
201
|
+
# To charge the card while creating a profile, pass
|
202
|
+
# options[:setup_fee] => money
|
203
|
+
def store(payment_method, options = {})
|
204
|
+
setup_address_hash(options)
|
205
|
+
commit(build_create_subscription_request(payment_method, options), :store, nil, options)
|
206
|
+
end
|
207
|
+
|
208
|
+
# Updates a customer subscription/profile
|
209
|
+
def update(reference, creditcard, options = {})
|
210
|
+
requires!(options, :order_id)
|
211
|
+
setup_address_hash(options)
|
212
|
+
commit(build_update_subscription_request(reference, creditcard, options), :update, nil, options)
|
213
|
+
end
|
214
|
+
|
215
|
+
# Removes a customer subscription/profile
|
216
|
+
def unstore(reference, options = {})
|
217
|
+
requires!(options, :order_id)
|
218
|
+
commit(build_delete_subscription_request(reference, options), :unstore, nil, options)
|
219
|
+
end
|
220
|
+
|
221
|
+
# Retrieves a customer subscription/profile
|
222
|
+
def retrieve(reference, options = {})
|
223
|
+
requires!(options, :order_id)
|
224
|
+
commit(build_retrieve_subscription_request(reference, options), :retrieve, nil, options)
|
225
|
+
end
|
226
|
+
|
227
|
+
# CyberSource requires that you provide line item information for tax
|
228
|
+
# calculations. If you do not have prices for each item or want to
|
229
|
+
# simplify the situation then pass in one fake line item that costs the
|
230
|
+
# subtotal of the order
|
231
|
+
#
|
232
|
+
# The line_item hash goes in the options hash and should look like
|
233
|
+
#
|
234
|
+
# :line_items => [
|
235
|
+
# {
|
236
|
+
# :declared_value => '1',
|
237
|
+
# :quantity => '2',
|
238
|
+
# :code => 'default',
|
239
|
+
# :description => 'Giant Walrus',
|
240
|
+
# :sku => 'WA323232323232323'
|
241
|
+
# },
|
242
|
+
# {
|
243
|
+
# :declared_value => '6',
|
244
|
+
# :quantity => '1',
|
245
|
+
# :code => 'default',
|
246
|
+
# :description => 'Marble Snowcone',
|
247
|
+
# :sku => 'FAKE1232132113123'
|
248
|
+
# }
|
249
|
+
# ]
|
250
|
+
#
|
251
|
+
# This functionality is only supported by this particular gateway may
|
252
|
+
# be changed at any time
|
253
|
+
def calculate_tax(creditcard, options)
|
254
|
+
requires!(options, :line_items)
|
255
|
+
setup_address_hash(options)
|
256
|
+
commit(build_tax_calculation_request(creditcard, options), :calculate_tax, nil, options)
|
257
|
+
end
|
258
|
+
|
259
|
+
def supports_scrubbing?
|
260
|
+
true
|
261
|
+
end
|
262
|
+
|
263
|
+
def scrub(transcript)
|
264
|
+
transcript.
|
265
|
+
gsub(%r((<wsse:Password [^>]*>)[^<]*(</wsse:Password>))i, '\1[FILTERED]\2').
|
266
|
+
gsub(%r((<accountNumber>)[^<]*(</accountNumber>))i, '\1[FILTERED]\2').
|
267
|
+
gsub(%r((<cvNumber>)[^<]*(</cvNumber>))i, '\1[FILTERED]\2').
|
268
|
+
gsub(%r((<cavv>)[^<]*(</cavv>))i, '\1[FILTERED]\2').
|
269
|
+
gsub(%r((<xid>)[^<]*(</xid>))i, '\1[FILTERED]\2').
|
270
|
+
gsub(%r((<authenticationData>)[^<]*(</authenticationData>))i, '\1[FILTERED]\2')
|
271
|
+
end
|
272
|
+
|
273
|
+
def supports_network_tokenization?
|
274
|
+
true
|
275
|
+
end
|
276
|
+
|
277
|
+
def verify_credentials
|
278
|
+
response = void('0')
|
279
|
+
response.params['reasonCode'] == '102'
|
280
|
+
end
|
281
|
+
|
282
|
+
private
|
283
|
+
|
284
|
+
# Create all required address hash key value pairs
|
285
|
+
# If a value of nil is received, that value will be passed on to the gateway and will not be replaced with a default value
|
286
|
+
# Billing address fields received without an override value or with an empty string value will be replaced with the default_address values
|
287
|
+
def setup_address_hash(options)
|
288
|
+
default_address = {
|
289
|
+
address1: 'Unspecified',
|
290
|
+
city: 'Unspecified',
|
291
|
+
state: 'NC',
|
292
|
+
zip: '00000',
|
293
|
+
country: 'US'
|
294
|
+
}
|
295
|
+
|
296
|
+
submitted_address = options[:billing_address] || options[:address] || default_address
|
297
|
+
options[:billing_address] = default_address.merge(submitted_address.symbolize_keys) { |_k, default, submitted| check_billing_field_value(default, submitted) }
|
298
|
+
options[:shipping_address] = options[:shipping_address] || {}
|
299
|
+
end
|
300
|
+
|
301
|
+
def check_billing_field_value(default, submitted)
|
302
|
+
if submitted.nil?
|
303
|
+
nil
|
304
|
+
elsif submitted.blank?
|
305
|
+
default
|
306
|
+
else
|
307
|
+
submitted
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
def build_auth_request(money, creditcard_or_reference, options)
|
312
|
+
xml = Builder::XmlMarkup.new indent: 2
|
313
|
+
add_customer_id(xml, options)
|
314
|
+
add_payment_method_or_subscription(xml, money, creditcard_or_reference, options)
|
315
|
+
add_other_tax(xml, options)
|
316
|
+
add_threeds_2_ucaf_data(xml, creditcard_or_reference, options)
|
317
|
+
add_decision_manager_fields(xml, options)
|
318
|
+
add_mdd_fields(xml, options)
|
319
|
+
add_auth_service(xml, creditcard_or_reference, options)
|
320
|
+
add_threeds_services(xml, options)
|
321
|
+
add_business_rules_data(xml, creditcard_or_reference, options)
|
322
|
+
add_airline_data(xml, options)
|
323
|
+
add_sales_slip_number(xml, options)
|
324
|
+
add_payment_network_token(xml) if network_tokenization?(creditcard_or_reference)
|
325
|
+
add_tax_management_indicator(xml, options)
|
326
|
+
add_stored_credential_subsequent_auth(xml, options)
|
327
|
+
add_issuer_additional_data(xml, options)
|
328
|
+
add_partner_solution_id(xml)
|
329
|
+
add_stored_credential_options(xml, options)
|
330
|
+
add_merchant_description(xml, options)
|
331
|
+
xml.target!
|
332
|
+
end
|
333
|
+
|
334
|
+
def build_adjust_request(money, authorization, options)
|
335
|
+
_, request_id = authorization.split(';')
|
336
|
+
|
337
|
+
xml = Builder::XmlMarkup.new indent: 2
|
338
|
+
add_purchase_data(xml, money, true, options)
|
339
|
+
add_incremental_auth_service(xml, request_id, options)
|
340
|
+
xml.target!
|
341
|
+
end
|
342
|
+
|
343
|
+
def build_tax_calculation_request(creditcard, options)
|
344
|
+
xml = Builder::XmlMarkup.new indent: 2
|
345
|
+
add_address(xml, creditcard, options[:billing_address], options, false)
|
346
|
+
add_address(xml, creditcard, options[:shipping_address], options, true)
|
347
|
+
add_line_item_data(xml, options)
|
348
|
+
add_purchase_data(xml, 0, false, options)
|
349
|
+
add_tax_service(xml)
|
350
|
+
add_business_rules_data(xml, creditcard, options)
|
351
|
+
add_tax_management_indicator(xml, options)
|
352
|
+
xml.target!
|
353
|
+
end
|
354
|
+
|
355
|
+
def build_capture_request(money, authorization, options)
|
356
|
+
order_id, request_id, request_token = authorization.split(';')
|
357
|
+
options[:order_id] = order_id
|
358
|
+
|
359
|
+
xml = Builder::XmlMarkup.new indent: 2
|
360
|
+
add_purchase_data(xml, money, true, options)
|
361
|
+
add_other_tax(xml, options)
|
362
|
+
add_mdd_fields(xml, options)
|
363
|
+
add_capture_service(xml, request_id, request_token, options)
|
364
|
+
add_business_rules_data(xml, authorization, options)
|
365
|
+
add_tax_management_indicator(xml, options)
|
366
|
+
add_issuer_additional_data(xml, options)
|
367
|
+
add_merchant_description(xml, options)
|
368
|
+
add_partner_solution_id(xml)
|
369
|
+
|
370
|
+
xml.target!
|
371
|
+
end
|
372
|
+
|
373
|
+
def build_purchase_request(money, payment_method_or_reference, options)
|
374
|
+
xml = Builder::XmlMarkup.new indent: 2
|
375
|
+
add_customer_id(xml, options)
|
376
|
+
add_payment_method_or_subscription(xml, money, payment_method_or_reference, options)
|
377
|
+
add_other_tax(xml, options)
|
378
|
+
add_threeds_2_ucaf_data(xml, payment_method_or_reference, options)
|
379
|
+
add_decision_manager_fields(xml, options)
|
380
|
+
add_mdd_fields(xml, options)
|
381
|
+
if (!payment_method_or_reference.is_a?(String) && card_brand(payment_method_or_reference) == 'check') || reference_is_a_check?(payment_method_or_reference)
|
382
|
+
add_check_service(xml)
|
383
|
+
add_airline_data(xml, options)
|
384
|
+
add_sales_slip_number(xml, options)
|
385
|
+
add_tax_management_indicator(xml, options)
|
386
|
+
add_issuer_additional_data(xml, options)
|
387
|
+
add_partner_solution_id(xml)
|
388
|
+
options[:payment_method] = :check
|
389
|
+
else
|
390
|
+
add_purchase_service(xml, payment_method_or_reference, options)
|
391
|
+
add_threeds_services(xml, options)
|
392
|
+
add_business_rules_data(xml, payment_method_or_reference, options)
|
393
|
+
add_airline_data(xml, options)
|
394
|
+
add_sales_slip_number(xml, options)
|
395
|
+
add_payment_network_token(xml) if network_tokenization?(payment_method_or_reference)
|
396
|
+
add_tax_management_indicator(xml, options)
|
397
|
+
add_stored_credential_subsequent_auth(xml, options)
|
398
|
+
add_issuer_additional_data(xml, options)
|
399
|
+
add_partner_solution_id(xml)
|
400
|
+
add_stored_credential_options(xml, options)
|
401
|
+
options[:payment_method] = :credit_card
|
402
|
+
end
|
403
|
+
|
404
|
+
add_merchant_description(xml, options)
|
405
|
+
|
406
|
+
xml.target!
|
407
|
+
end
|
408
|
+
|
409
|
+
def reference_is_a_check?(payment_method_or_reference)
|
410
|
+
payment_method_or_reference.is_a?(String) && payment_method_or_reference.split(';')[7] == 'check'
|
411
|
+
end
|
412
|
+
|
413
|
+
def build_void_request(identification, options)
|
414
|
+
order_id, request_id, request_token, action, money, currency = identification.split(';')
|
415
|
+
options[:order_id] = order_id
|
416
|
+
|
417
|
+
xml = Builder::XmlMarkup.new indent: 2
|
418
|
+
case action
|
419
|
+
when 'capture', 'purchase'
|
420
|
+
add_mdd_fields(xml, options)
|
421
|
+
add_void_service(xml, request_id, request_token)
|
422
|
+
else
|
423
|
+
add_purchase_data(xml, money, true, options.merge(currency: currency || default_currency))
|
424
|
+
add_mdd_fields(xml, options)
|
425
|
+
add_auth_reversal_service(xml, request_id, request_token)
|
426
|
+
end
|
427
|
+
add_issuer_additional_data(xml, options)
|
428
|
+
add_partner_solution_id(xml)
|
429
|
+
|
430
|
+
xml.target!
|
431
|
+
end
|
432
|
+
|
433
|
+
def build_refund_request(money, identification, options)
|
434
|
+
order_id, request_id, request_token = identification.split(';')
|
435
|
+
options[:order_id] = order_id
|
436
|
+
|
437
|
+
xml = Builder::XmlMarkup.new indent: 2
|
438
|
+
add_purchase_data(xml, money, true, options)
|
439
|
+
add_credit_service(xml, request_id: request_id,
|
440
|
+
request_token: request_token,
|
441
|
+
use_check_service: reference_is_a_check?(identification))
|
442
|
+
add_partner_solution_id(xml)
|
443
|
+
|
444
|
+
xml.target!
|
445
|
+
end
|
446
|
+
|
447
|
+
def build_credit_request(money, creditcard_or_reference, options)
|
448
|
+
xml = Builder::XmlMarkup.new indent: 2
|
449
|
+
|
450
|
+
add_payment_method_or_subscription(xml, money, creditcard_or_reference, options)
|
451
|
+
add_mdd_fields(xml, options)
|
452
|
+
add_credit_service(xml, use_check_service: creditcard_or_reference.is_a?(Check))
|
453
|
+
add_issuer_additional_data(xml, options)
|
454
|
+
add_merchant_description(xml, options)
|
455
|
+
|
456
|
+
xml.target!
|
457
|
+
end
|
458
|
+
|
459
|
+
def build_create_subscription_request(payment_method, options)
|
460
|
+
default_subscription_params = { frequency: 'on-demand', amount: 0, automatic_renew: false }
|
461
|
+
options[:subscription] = default_subscription_params.update(
|
462
|
+
options[:subscription] || {}
|
463
|
+
)
|
464
|
+
|
465
|
+
xml = Builder::XmlMarkup.new indent: 2
|
466
|
+
add_address(xml, payment_method, options[:billing_address], options)
|
467
|
+
add_purchase_data(xml, options[:setup_fee] || 0, true, options)
|
468
|
+
if card_brand(payment_method) == 'check'
|
469
|
+
add_check(xml, payment_method, options)
|
470
|
+
add_check_payment_method(xml)
|
471
|
+
options[:payment_method] = :check
|
472
|
+
else
|
473
|
+
add_creditcard(xml, payment_method)
|
474
|
+
add_creditcard_payment_method(xml)
|
475
|
+
options[:payment_method] = :credit_card
|
476
|
+
end
|
477
|
+
add_subscription(xml, options)
|
478
|
+
if options[:setup_fee]
|
479
|
+
if card_brand(payment_method) == 'check'
|
480
|
+
add_check_service(xml)
|
481
|
+
else
|
482
|
+
add_purchase_service(xml, payment_method, options)
|
483
|
+
add_payment_network_token(xml) if network_tokenization?(payment_method)
|
484
|
+
end
|
485
|
+
end
|
486
|
+
add_subscription_create_service(xml, options)
|
487
|
+
add_business_rules_data(xml, payment_method, options)
|
488
|
+
add_tax_management_indicator(xml, options)
|
489
|
+
xml.target!
|
490
|
+
end
|
491
|
+
|
492
|
+
def build_update_subscription_request(reference, creditcard, options)
|
493
|
+
xml = Builder::XmlMarkup.new indent: 2
|
494
|
+
add_address(xml, creditcard, options[:billing_address], options) unless options[:billing_address].blank?
|
495
|
+
add_purchase_data(xml, options[:setup_fee], true, options) unless options[:setup_fee].blank?
|
496
|
+
add_creditcard(xml, creditcard) if creditcard
|
497
|
+
add_creditcard_payment_method(xml) if creditcard
|
498
|
+
add_subscription(xml, options, reference)
|
499
|
+
add_subscription_update_service(xml, options)
|
500
|
+
add_business_rules_data(xml, creditcard, options)
|
501
|
+
add_tax_management_indicator(xml, options)
|
502
|
+
xml.target!
|
503
|
+
end
|
504
|
+
|
505
|
+
def build_delete_subscription_request(reference, options)
|
506
|
+
xml = Builder::XmlMarkup.new indent: 2
|
507
|
+
add_subscription(xml, options, reference)
|
508
|
+
add_subscription_delete_service(xml, options)
|
509
|
+
xml.target!
|
510
|
+
end
|
511
|
+
|
512
|
+
def build_retrieve_subscription_request(reference, options)
|
513
|
+
xml = Builder::XmlMarkup.new indent: 2
|
514
|
+
add_subscription(xml, options, reference)
|
515
|
+
add_subscription_retrieve_service(xml, options)
|
516
|
+
xml.target!
|
517
|
+
end
|
518
|
+
|
519
|
+
def add_business_rules_data(xml, payment_method, options)
|
520
|
+
prioritized_options = [options, @options]
|
521
|
+
|
522
|
+
xml.tag! 'businessRules' do
|
523
|
+
xml.tag!('ignoreAVSResult', 'true') if extract_option(prioritized_options, :ignore_avs).to_s == 'true'
|
524
|
+
xml.tag!('ignoreCVResult', 'true') if extract_option(prioritized_options, :ignore_cvv).to_s == 'true'
|
525
|
+
end
|
526
|
+
end
|
527
|
+
|
528
|
+
def extract_option(prioritized_options, option_name)
|
529
|
+
options_matching_key = prioritized_options.detect do |options|
|
530
|
+
options.has_key? option_name
|
531
|
+
end
|
532
|
+
options_matching_key[option_name] if options_matching_key
|
533
|
+
end
|
534
|
+
|
535
|
+
def add_line_item_data(xml, options)
|
536
|
+
return unless options[:line_items]
|
537
|
+
|
538
|
+
options[:line_items].each_with_index do |value, index|
|
539
|
+
xml.tag! 'item', { 'id' => index } do
|
540
|
+
xml.tag! 'unitPrice', localized_amount(value[:declared_value].to_i, options[:currency] || default_currency)
|
541
|
+
xml.tag! 'quantity', value[:quantity]
|
542
|
+
xml.tag! 'productCode', value[:code] || 'shipping_only'
|
543
|
+
xml.tag! 'productName', value[:description]
|
544
|
+
xml.tag! 'productSKU', value[:sku]
|
545
|
+
xml.tag! 'taxAmount', value[:tax_amount] if value[:tax_amount]
|
546
|
+
xml.tag! 'nationalTax', value[:national_tax] if value[:national_tax]
|
547
|
+
end
|
548
|
+
end
|
549
|
+
end
|
550
|
+
|
551
|
+
def add_merchant_data(xml, options)
|
552
|
+
xml.tag! 'merchantID', @options[:login]
|
553
|
+
xml.tag! 'merchantReferenceCode', options[:order_id] || generate_unique_id
|
554
|
+
xml.tag! 'clientLibrary', 'Ruby Active Merchant'
|
555
|
+
xml.tag! 'clientLibraryVersion', VERSION
|
556
|
+
xml.tag! 'clientEnvironment', RUBY_PLATFORM
|
557
|
+
|
558
|
+
add_merchant_descriptor(xml, options)
|
559
|
+
end
|
560
|
+
|
561
|
+
def add_merchant_descriptor(xml, options)
|
562
|
+
return unless options[:merchant_descriptor] || options[:user_po] || options[:taxable] || options[:reference_data_code] || options[:invoice_number]
|
563
|
+
|
564
|
+
xml.tag! 'invoiceHeader' do
|
565
|
+
xml.tag! 'merchantDescriptor', options[:merchant_descriptor] if options[:merchant_descriptor]
|
566
|
+
xml.tag! 'userPO', options[:user_po] if options[:user_po]
|
567
|
+
xml.tag! 'taxable', options[:taxable] if options[:taxable]
|
568
|
+
xml.tag! 'referenceDataCode', options[:reference_data_code] if options[:reference_data_code]
|
569
|
+
xml.tag! 'invoiceNumber', options[:invoice_number] if options[:invoice_number]
|
570
|
+
end
|
571
|
+
end
|
572
|
+
|
573
|
+
def add_customer_id(xml, options)
|
574
|
+
return unless options[:customer_id]
|
575
|
+
|
576
|
+
xml.tag! 'customerID', options[:customer_id]
|
577
|
+
end
|
578
|
+
|
579
|
+
def add_merchant_description(xml, options)
|
580
|
+
return unless options[:merchant_descriptor_name] || options[:merchant_descriptor_address1] || options[:merchant_descriptor_locality]
|
581
|
+
|
582
|
+
xml.tag! 'merchantInformation' do
|
583
|
+
xml.tag! 'merchantDescriptor' do
|
584
|
+
xml.tag! 'name', options[:merchant_descriptor_name] if options[:merchant_descriptor_name]
|
585
|
+
xml.tag! 'address1', options[:merchant_descriptor_address1] if options[:merchant_descriptor_address1]
|
586
|
+
xml.tag! 'locality', options[:merchant_descriptor_locality] if options[:merchant_descriptor_locality]
|
587
|
+
end
|
588
|
+
end
|
589
|
+
end
|
590
|
+
|
591
|
+
def add_sales_slip_number(xml, options)
|
592
|
+
xml.tag! 'salesSlipNumber', options[:sales_slip_number] if options[:sales_slip_number]
|
593
|
+
end
|
594
|
+
|
595
|
+
def add_airline_data(xml, options)
|
596
|
+
return unless options[:airline_agent_code]
|
597
|
+
|
598
|
+
xml.tag! 'airlineData' do
|
599
|
+
xml.tag! 'agentCode', options[:airline_agent_code]
|
600
|
+
end
|
601
|
+
end
|
602
|
+
|
603
|
+
def add_tax_management_indicator(xml, options)
|
604
|
+
return unless options[:tax_management_indicator]
|
605
|
+
|
606
|
+
xml.tag! 'taxManagementIndicator', options[:tax_management_indicator] if options[:tax_management_indicator]
|
607
|
+
end
|
608
|
+
|
609
|
+
def add_purchase_data(xml, money = 0, include_grand_total = false, options = {})
|
610
|
+
xml.tag! 'purchaseTotals' do
|
611
|
+
xml.tag! 'currency', options[:currency] || currency(money)
|
612
|
+
xml.tag!('discountManagementIndicator', options[:discount_management_indicator]) if options[:discount_management_indicator]
|
613
|
+
xml.tag!('taxAmount', options[:purchase_tax_amount]) if options[:purchase_tax_amount]
|
614
|
+
xml.tag!('grandTotalAmount', localized_amount(money.to_i, options[:currency] || default_currency)) if include_grand_total
|
615
|
+
xml.tag!('originalAmount', options[:original_amount]) if options[:original_amount]
|
616
|
+
xml.tag!('invoiceAmount', options[:invoice_amount]) if options[:invoice_amount]
|
617
|
+
end
|
618
|
+
end
|
619
|
+
|
620
|
+
def add_address(xml, payment_method, address, options, shipTo = false)
|
621
|
+
first_name, last_name = address_names(address[:name], payment_method)
|
622
|
+
bill_to_merchant_tax_id = options[:merchant_tax_id] unless shipTo
|
623
|
+
|
624
|
+
xml.tag! shipTo ? 'shipTo' : 'billTo' do
|
625
|
+
xml.tag! 'firstName', first_name if first_name
|
626
|
+
xml.tag! 'lastName', last_name if last_name
|
627
|
+
xml.tag! 'street1', address[:address1]
|
628
|
+
xml.tag! 'street2', address[:address2] unless address[:address2].blank?
|
629
|
+
xml.tag! 'city', address[:city]
|
630
|
+
xml.tag! 'state', address[:state]
|
631
|
+
xml.tag! 'postalCode', address[:zip]
|
632
|
+
xml.tag! 'country', lookup_country_code(address[:country]) unless address[:country].blank?
|
633
|
+
xml.tag! 'company', address[:company] unless address[:company].blank?
|
634
|
+
xml.tag! 'companyTaxID', address[:companyTaxID] unless address[:company_tax_id].blank?
|
635
|
+
xml.tag! 'phoneNumber', address[:phone] unless address[:phone].blank?
|
636
|
+
xml.tag! 'email', options[:email].presence || 'null@cybersource.com'
|
637
|
+
xml.tag! 'ipAddress', options[:ip] unless options[:ip].blank? || shipTo
|
638
|
+
xml.tag! 'driversLicenseNumber', options[:drivers_license_number] unless options[:drivers_license_number].blank?
|
639
|
+
xml.tag! 'driversLicenseState', options[:drivers_license_state] unless options[:drivers_license_state].blank?
|
640
|
+
xml.tag! 'merchantTaxID', bill_to_merchant_tax_id unless bill_to_merchant_tax_id.blank?
|
641
|
+
end
|
642
|
+
end
|
643
|
+
|
644
|
+
def address_names(address_name, payment_method)
|
645
|
+
names = split_names(address_name)
|
646
|
+
return names if names.any?(&:present?)
|
647
|
+
|
648
|
+
[
|
649
|
+
payment_method&.first_name,
|
650
|
+
payment_method&.last_name
|
651
|
+
]
|
652
|
+
end
|
653
|
+
|
654
|
+
def add_creditcard(xml, creditcard)
|
655
|
+
xml.tag! 'card' do
|
656
|
+
xml.tag! 'accountNumber', creditcard.number
|
657
|
+
xml.tag! 'expirationMonth', format(creditcard.month, :two_digits)
|
658
|
+
xml.tag! 'expirationYear', format(creditcard.year, :four_digits)
|
659
|
+
xml.tag!('cvNumber', creditcard.verification_value) unless @options[:ignore_cvv].to_s == 'true' || creditcard.verification_value.blank?
|
660
|
+
xml.tag! 'cardType', @@credit_card_codes[card_brand(creditcard).to_sym]
|
661
|
+
end
|
662
|
+
end
|
663
|
+
|
664
|
+
def add_decision_manager_fields(xml, options)
|
665
|
+
return unless options[:decision_manager_enabled]
|
666
|
+
|
667
|
+
xml.tag! 'decisionManager' do
|
668
|
+
xml.tag! 'enabled', options[:decision_manager_enabled] if options[:decision_manager_enabled]
|
669
|
+
xml.tag! 'profile', options[:decision_manager_profile] if options[:decision_manager_profile]
|
670
|
+
end
|
671
|
+
end
|
672
|
+
|
673
|
+
def add_issuer_additional_data(xml, options)
|
674
|
+
return unless options[:issuer_additional_data]
|
675
|
+
|
676
|
+
xml.tag! 'issuer' do
|
677
|
+
xml.tag! 'additionalData', options[:issuer_additional_data]
|
678
|
+
end
|
679
|
+
end
|
680
|
+
|
681
|
+
def add_other_tax(xml, options)
|
682
|
+
return unless options[:local_tax_amount] || options[:national_tax_amount] || options[:national_tax_indicator]
|
683
|
+
|
684
|
+
xml.tag! 'otherTax' do
|
685
|
+
xml.tag! 'vatTaxRate', options[:vat_tax_rate] if options[:vat_tax_rate]
|
686
|
+
xml.tag! 'localTaxAmount', options[:local_tax_amount] if options[:local_tax_amount]
|
687
|
+
xml.tag! 'nationalTaxAmount', options[:national_tax_amount] if options[:national_tax_amount]
|
688
|
+
xml.tag! 'nationalTaxIndicator', options[:national_tax_indicator] if options[:national_tax_indicator]
|
689
|
+
end
|
690
|
+
end
|
691
|
+
|
692
|
+
def add_mdd_fields(xml, options)
|
693
|
+
return unless options.keys.any? { |key| key.to_s.start_with?('mdd_field') && options[key] }
|
694
|
+
|
695
|
+
xml.tag! 'merchantDefinedData' do
|
696
|
+
(1..100).each do |each|
|
697
|
+
key = "mdd_field_#{each}".to_sym
|
698
|
+
xml.tag!('mddField', options[key], 'id' => each) if options[key]
|
699
|
+
end
|
700
|
+
end
|
701
|
+
end
|
702
|
+
|
703
|
+
def add_check(xml, check, options)
|
704
|
+
xml.tag! 'check' do
|
705
|
+
xml.tag! 'accountNumber', check.account_number
|
706
|
+
xml.tag! 'accountType', check.account_type == 'checking' ? 'C' : 'S'
|
707
|
+
xml.tag! 'bankTransitNumber', format_routing_number(check.routing_number, options)
|
708
|
+
xml.tag! 'secCode', options[:sec_code] if options[:sec_code]
|
709
|
+
end
|
710
|
+
end
|
711
|
+
|
712
|
+
def add_tax_service(xml)
|
713
|
+
xml.tag! 'taxService', { 'run' => 'true' } do
|
714
|
+
xml.tag!('nexus', @options[:nexus]) unless @options[:nexus].blank?
|
715
|
+
xml.tag!('sellerRegistration', @options[:vat_reg_number]) unless @options[:vat_reg_number].blank?
|
716
|
+
end
|
717
|
+
end
|
718
|
+
|
719
|
+
def add_auth_service(xml, payment_method, options)
|
720
|
+
if network_tokenization?(payment_method)
|
721
|
+
add_auth_network_tokenization(xml, payment_method, options)
|
722
|
+
else
|
723
|
+
xml.tag! 'ccAuthService', { 'run' => 'true' } do
|
724
|
+
if options[:three_d_secure]
|
725
|
+
add_normalized_threeds_2_data(xml, payment_method, options)
|
726
|
+
else
|
727
|
+
indicator = options[:commerce_indicator] || stored_credential_commerce_indicator(options)
|
728
|
+
xml.tag!('commerceIndicator', indicator) if indicator
|
729
|
+
end
|
730
|
+
xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id]
|
731
|
+
xml.tag!('mobileRemotePaymentType', options[:mobile_remote_payment_type]) if options[:mobile_remote_payment_type]
|
732
|
+
end
|
733
|
+
end
|
734
|
+
end
|
735
|
+
|
736
|
+
def add_incremental_auth_service(xml, authorization, options)
|
737
|
+
xml.tag! 'ccIncrementalAuthService', { 'run' => 'true' } do
|
738
|
+
xml.tag! 'authRequestID', authorization
|
739
|
+
end
|
740
|
+
xml.tag! 'subsequentAuthReason', options[:auth_reason]
|
741
|
+
end
|
742
|
+
|
743
|
+
def add_normalized_threeds_2_data(xml, payment_method, options)
|
744
|
+
threeds_2_options = options[:three_d_secure]
|
745
|
+
cc_brand = card_brand(payment_method).to_sym
|
746
|
+
|
747
|
+
return if threeds_2_options[:cavv].blank? && infer_commerce_indicator?(options, cc_brand)
|
748
|
+
|
749
|
+
xid = threeds_2_options[:xid]
|
750
|
+
|
751
|
+
xml.tag!('cavv', threeds_2_options[:cavv]) if threeds_2_options[:cavv] && cc_brand != :master
|
752
|
+
xml.tag!('cavvAlgorithm', threeds_2_options[:cavv_algorithm]) if threeds_2_options[:cavv_algorithm]
|
753
|
+
xml.tag!('paSpecificationVersion', threeds_2_options[:version]) if threeds_2_options[:version]
|
754
|
+
xml.tag!('directoryServerTransactionID', threeds_2_options[:ds_transaction_id]) if threeds_2_options[:ds_transaction_id]
|
755
|
+
xml.tag!('commerceIndicator', options[:commerce_indicator] || ECI_BRAND_MAPPING[cc_brand])
|
756
|
+
xml.tag!('eciRaw', threeds_2_options[:eci]) if threeds_2_options[:eci]
|
757
|
+
|
758
|
+
if xid.present?
|
759
|
+
xml.tag!('xid', xid)
|
760
|
+
elsif threeds_2_options[:version]&.start_with?('2') && cc_brand != :master
|
761
|
+
cavv = threeds_2_options[:cavv]
|
762
|
+
xml.tag!('xid', cavv) if cavv.present?
|
763
|
+
end
|
764
|
+
|
765
|
+
xml.tag!('veresEnrolled', threeds_2_options[:enrolled]) if threeds_2_options[:enrolled]
|
766
|
+
xml.tag!('paresStatus', threeds_2_options[:authentication_response_status]) if threeds_2_options[:authentication_response_status]
|
767
|
+
end
|
768
|
+
|
769
|
+
def infer_commerce_indicator?(options, cc_brand)
|
770
|
+
options[:commerce_indicator].blank? && ECI_BRAND_MAPPING[cc_brand].present?
|
771
|
+
end
|
772
|
+
|
773
|
+
def add_threeds_2_ucaf_data(xml, payment_method, options)
|
774
|
+
return unless options[:three_d_secure] && card_brand(payment_method).to_sym == :master
|
775
|
+
|
776
|
+
xml.tag! 'ucaf' do
|
777
|
+
xml.tag!('authenticationData', options[:three_d_secure][:cavv])
|
778
|
+
xml.tag!('collectionIndicator', options[:collection_indicator] || DEFAULT_COLLECTION_INDICATOR)
|
779
|
+
end
|
780
|
+
end
|
781
|
+
|
782
|
+
def stored_credential_commerce_indicator(options)
|
783
|
+
return unless options[:stored_credential]
|
784
|
+
|
785
|
+
return if options[:stored_credential][:initial_transaction]
|
786
|
+
|
787
|
+
case options[:stored_credential][:reason_type]
|
788
|
+
when 'installment' then 'install'
|
789
|
+
when 'recurring' then 'recurring'
|
790
|
+
end
|
791
|
+
end
|
792
|
+
|
793
|
+
def network_tokenization?(payment_method)
|
794
|
+
payment_method.is_a?(NetworkTokenizationCreditCard)
|
795
|
+
end
|
796
|
+
|
797
|
+
def add_auth_network_tokenization(xml, payment_method, options)
|
798
|
+
return unless network_tokenization?(payment_method)
|
799
|
+
|
800
|
+
brand = card_brand(payment_method).to_sym
|
801
|
+
|
802
|
+
case brand
|
803
|
+
when :visa
|
804
|
+
xml.tag! 'ccAuthService', { 'run' => 'true' } do
|
805
|
+
xml.tag!('cavv', payment_method.payment_cryptogram)
|
806
|
+
xml.tag!('commerceIndicator', ECI_BRAND_MAPPING[brand])
|
807
|
+
xml.tag!('xid', payment_method.payment_cryptogram)
|
808
|
+
xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id]
|
809
|
+
end
|
810
|
+
when :master
|
811
|
+
xml.tag! 'ucaf' do
|
812
|
+
xml.tag!('authenticationData', payment_method.payment_cryptogram)
|
813
|
+
xml.tag!('collectionIndicator', DEFAULT_COLLECTION_INDICATOR)
|
814
|
+
end
|
815
|
+
xml.tag! 'ccAuthService', { 'run' => 'true' } do
|
816
|
+
xml.tag!('commerceIndicator', ECI_BRAND_MAPPING[brand])
|
817
|
+
xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id]
|
818
|
+
end
|
819
|
+
when :american_express
|
820
|
+
cryptogram = Base64.decode64(payment_method.payment_cryptogram)
|
821
|
+
xml.tag! 'ccAuthService', { 'run' => 'true' } do
|
822
|
+
xml.tag!('cavv', Base64.encode64(cryptogram[0...20]))
|
823
|
+
xml.tag!('commerceIndicator', ECI_BRAND_MAPPING[brand])
|
824
|
+
xml.tag!('xid', Base64.encode64(cryptogram[20...40])) if cryptogram.bytes.count > 20
|
825
|
+
xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id]
|
826
|
+
end
|
827
|
+
else
|
828
|
+
raise ArgumentError.new("Payment method #{brand} is not supported, check https://developer.cybersource.com/docs/cybs/en-us/payments/developer/all/rest/payments/CreatingOnlineAuth/CreatingAuthReqPNT.html")
|
829
|
+
end
|
830
|
+
end
|
831
|
+
|
832
|
+
def add_payment_network_token(xml)
|
833
|
+
xml.tag! 'paymentNetworkToken' do
|
834
|
+
xml.tag!('transactionType', '1')
|
835
|
+
end
|
836
|
+
end
|
837
|
+
|
838
|
+
def add_capture_service(xml, request_id, request_token, options)
|
839
|
+
xml.tag! 'ccCaptureService', { 'run' => 'true' } do
|
840
|
+
xml.tag! 'authRequestID', request_id
|
841
|
+
xml.tag! 'authRequestToken', request_token
|
842
|
+
xml.tag! 'gratuityAmount', options[:gratuity_amount] if options[:gratuity_amount]
|
843
|
+
xml.tag! 'reconciliationID', options[:reconciliation_id] if options[:reconciliation_id]
|
844
|
+
end
|
845
|
+
end
|
846
|
+
|
847
|
+
def add_purchase_service(xml, payment_method, options)
|
848
|
+
add_auth_service(xml, payment_method, options)
|
849
|
+
xml.tag! 'ccCaptureService', { 'run' => 'true' } do
|
850
|
+
xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id]
|
851
|
+
end
|
852
|
+
end
|
853
|
+
|
854
|
+
def add_void_service(xml, request_id, request_token)
|
855
|
+
xml.tag! 'voidService', { 'run' => 'true' } do
|
856
|
+
xml.tag! 'voidRequestID', request_id
|
857
|
+
xml.tag! 'voidRequestToken', request_token
|
858
|
+
end
|
859
|
+
end
|
860
|
+
|
861
|
+
def add_auth_reversal_service(xml, request_id, request_token)
|
862
|
+
xml.tag! 'ccAuthReversalService', { 'run' => 'true' } do
|
863
|
+
xml.tag! 'authRequestID', request_id
|
864
|
+
xml.tag! 'authRequestToken', request_token
|
865
|
+
end
|
866
|
+
end
|
867
|
+
|
868
|
+
def add_credit_service(xml, options = {})
|
869
|
+
service = options[:use_check_service] ? 'ecCreditService' : 'ccCreditService'
|
870
|
+
request_tag = options[:use_check_service] ? 'debitRequestID' : 'captureRequestID'
|
871
|
+
options.delete :request_token if options[:use_check_service]
|
872
|
+
|
873
|
+
xml.tag! service, { 'run' => 'true' } do
|
874
|
+
xml.tag! request_tag, options[:request_id] if options[:request_id]
|
875
|
+
xml.tag! 'captureRequestToken', options[:request_token] if options[:request_token]
|
876
|
+
end
|
877
|
+
end
|
878
|
+
|
879
|
+
def add_check_service(xml)
|
880
|
+
xml.tag! 'ecDebitService', { 'run' => 'true' }
|
881
|
+
end
|
882
|
+
|
883
|
+
def add_subscription_create_service(xml, options)
|
884
|
+
xml.tag! 'paySubscriptionCreateService', { 'run' => 'true' }
|
885
|
+
end
|
886
|
+
|
887
|
+
def add_subscription_update_service(xml, options)
|
888
|
+
xml.tag! 'paySubscriptionUpdateService', { 'run' => 'true' }
|
889
|
+
end
|
890
|
+
|
891
|
+
def add_subscription_delete_service(xml, options)
|
892
|
+
xml.tag! 'paySubscriptionDeleteService', { 'run' => 'true' }
|
893
|
+
end
|
894
|
+
|
895
|
+
def add_subscription_retrieve_service(xml, options)
|
896
|
+
xml.tag! 'paySubscriptionRetrieveService', { 'run' => 'true' }
|
897
|
+
end
|
898
|
+
|
899
|
+
def add_subscription(xml, options, reference = nil)
|
900
|
+
options[:subscription] ||= {}
|
901
|
+
|
902
|
+
xml.tag! 'recurringSubscriptionInfo' do
|
903
|
+
if reference
|
904
|
+
subscription_id = reference.split(';')[6]
|
905
|
+
xml.tag! 'subscriptionID', subscription_id
|
906
|
+
end
|
907
|
+
|
908
|
+
xml.tag! 'status', options[:subscription][:status] if options[:subscription][:status]
|
909
|
+
xml.tag! 'amount', localized_amount(options[:subscription][:amount].to_i, options[:currency] || default_currency) if options[:subscription][:amount]
|
910
|
+
xml.tag! 'numberOfPayments', options[:subscription][:occurrences] if options[:subscription][:occurrences]
|
911
|
+
xml.tag! 'automaticRenew', options[:subscription][:automatic_renew] if options[:subscription][:automatic_renew]
|
912
|
+
xml.tag! 'frequency', options[:subscription][:frequency] if options[:subscription][:frequency]
|
913
|
+
xml.tag! 'startDate', options[:subscription][:start_date].strftime('%Y%m%d') if options[:subscription][:start_date]
|
914
|
+
xml.tag! 'endDate', options[:subscription][:end_date].strftime('%Y%m%d') if options[:subscription][:end_date]
|
915
|
+
xml.tag! 'approvalRequired', options[:subscription][:approval_required] || false
|
916
|
+
xml.tag! 'event', options[:subscription][:event] if options[:subscription][:event]
|
917
|
+
xml.tag! 'billPayment', options[:subscription][:bill_payment] if options[:subscription][:bill_payment]
|
918
|
+
end
|
919
|
+
end
|
920
|
+
|
921
|
+
def add_creditcard_payment_method(xml)
|
922
|
+
xml.tag! 'subscription' do
|
923
|
+
xml.tag! 'paymentMethod', 'credit card'
|
924
|
+
end
|
925
|
+
end
|
926
|
+
|
927
|
+
def add_check_payment_method(xml)
|
928
|
+
xml.tag! 'subscription' do
|
929
|
+
xml.tag! 'paymentMethod', 'check'
|
930
|
+
end
|
931
|
+
end
|
932
|
+
|
933
|
+
def add_payment_method_or_subscription(xml, money, payment_method_or_reference, options)
|
934
|
+
if payment_method_or_reference.is_a?(String)
|
935
|
+
add_purchase_data(xml, money, true, options)
|
936
|
+
add_installments(xml, options)
|
937
|
+
add_subscription(xml, options, payment_method_or_reference)
|
938
|
+
elsif card_brand(payment_method_or_reference) == 'check'
|
939
|
+
add_address(xml, payment_method_or_reference, options[:billing_address], options)
|
940
|
+
add_purchase_data(xml, money, true, options)
|
941
|
+
add_installments(xml, options)
|
942
|
+
add_check(xml, payment_method_or_reference, options)
|
943
|
+
else
|
944
|
+
add_address(xml, payment_method_or_reference, options[:billing_address], options)
|
945
|
+
add_address(xml, payment_method_or_reference, options[:shipping_address], options, true)
|
946
|
+
add_line_item_data(xml, options)
|
947
|
+
add_purchase_data(xml, money, true, options)
|
948
|
+
add_installments(xml, options)
|
949
|
+
add_creditcard(xml, payment_method_or_reference)
|
950
|
+
end
|
951
|
+
end
|
952
|
+
|
953
|
+
def add_installments(xml, options)
|
954
|
+
return unless %i[installment_total_count installment_total_amount installment_plan_type first_installment_date installment_annual_interest_rate installment_grace_period_duration].any? { |gsf| options.include?(gsf) }
|
955
|
+
|
956
|
+
xml.tag! 'installment' do
|
957
|
+
xml.tag!('totalCount', options[:installment_total_count]) if options[:installment_total_count]
|
958
|
+
xml.tag!('totalAmount', options[:installment_total_amount]) if options[:installment_total_amount]
|
959
|
+
xml.tag!('planType', options[:installment_plan_type]) if options[:installment_plan_type]
|
960
|
+
xml.tag!('firstInstallmentDate', options[:first_installment_date]) if options[:first_installment_date]
|
961
|
+
xml.tag!('annualInterestRate', options[:installment_annual_interest_rate]) if options[:installment_annual_interest_rate]
|
962
|
+
xml.tag!('gracePeriodDuration', options[:installment_grace_period_duration]) if options[:installment_grace_period_duration]
|
963
|
+
end
|
964
|
+
end
|
965
|
+
|
966
|
+
def add_threeds_services(xml, options)
|
967
|
+
xml.tag! 'payerAuthEnrollService', { 'run' => 'true' } if options[:payer_auth_enroll_service]
|
968
|
+
if options[:payer_auth_validate_service]
|
969
|
+
xml.tag! 'payerAuthValidateService', { 'run' => 'true' } do
|
970
|
+
xml.tag! 'signedPARes', options[:pares]
|
971
|
+
end
|
972
|
+
end
|
973
|
+
end
|
974
|
+
|
975
|
+
def lookup_country_code(country_field)
|
976
|
+
country_code = Country.find(country_field) rescue nil
|
977
|
+
country_code&.code(:alpha2)
|
978
|
+
end
|
979
|
+
|
980
|
+
def add_stored_credential_subsequent_auth(xml, options = {})
|
981
|
+
return unless options[:stored_credential] || options[:stored_credential_overrides]
|
982
|
+
|
983
|
+
stored_credential_subsequent_auth = 'true' if options.dig(:stored_credential, :initiator) == 'merchant'
|
984
|
+
|
985
|
+
override_subsequent_auth = options.dig(:stored_credential_overrides, :subsequent_auth)
|
986
|
+
|
987
|
+
xml.subsequentAuth override_subsequent_auth.nil? ? stored_credential_subsequent_auth : override_subsequent_auth
|
988
|
+
end
|
989
|
+
|
990
|
+
def add_stored_credential_options(xml, options = {})
|
991
|
+
return unless options[:stored_credential] || options[:stored_credential_overrides]
|
992
|
+
|
993
|
+
stored_credential_subsequent_auth_first = 'true' if options.dig(:stored_credential, :initial_transaction)
|
994
|
+
stored_credential_transaction_id = options.dig(:stored_credential, :network_transaction_id) if options.dig(:stored_credential, :initiator) == 'merchant'
|
995
|
+
stored_credential_subsequent_auth_stored_cred = 'true' if options.dig(:stored_credential, :initiator) == 'cardholder' && !options.dig(:stored_credential, :initial_transaction) || options.dig(:stored_credential, :initiator) == 'merchant' && options.dig(:stored_credential, :reason_type) == 'unscheduled'
|
996
|
+
|
997
|
+
override_subsequent_auth_first = options.dig(:stored_credential_overrides, :subsequent_auth_first)
|
998
|
+
override_subsequent_auth_transaction_id = options.dig(:stored_credential_overrides, :subsequent_auth_transaction_id)
|
999
|
+
override_subsequent_auth_stored_cred = options.dig(:stored_credential_overrides, :subsequent_auth_stored_credential)
|
1000
|
+
|
1001
|
+
xml.subsequentAuthFirst override_subsequent_auth_first.nil? ? stored_credential_subsequent_auth_first : override_subsequent_auth_first
|
1002
|
+
xml.subsequentAuthTransactionID override_subsequent_auth_transaction_id.nil? ? stored_credential_transaction_id : override_subsequent_auth_transaction_id
|
1003
|
+
xml.subsequentAuthStoredCredential override_subsequent_auth_stored_cred.nil? ? stored_credential_subsequent_auth_stored_cred : override_subsequent_auth_stored_cred
|
1004
|
+
end
|
1005
|
+
|
1006
|
+
def add_partner_solution_id(xml)
|
1007
|
+
return unless application_id
|
1008
|
+
|
1009
|
+
xml.tag!('partnerSolutionID', application_id)
|
1010
|
+
end
|
1011
|
+
|
1012
|
+
# Where we actually build the full SOAP request using builder
|
1013
|
+
def build_request(body, options)
|
1014
|
+
xsd_version = test? ? TEST_XSD_VERSION : PRODUCTION_XSD_VERSION
|
1015
|
+
|
1016
|
+
xml = Builder::XmlMarkup.new indent: 2
|
1017
|
+
xml.instruct!
|
1018
|
+
xml.tag! 's:Envelope', { 'xmlns:s' => 'http://schemas.xmlsoap.org/soap/envelope/' } do
|
1019
|
+
xml.tag! 's:Header' do
|
1020
|
+
xml.tag! 'wsse:Security', { 's:mustUnderstand' => '1', 'xmlns:wsse' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' } do
|
1021
|
+
xml.tag! 'wsse:UsernameToken' do
|
1022
|
+
xml.tag! 'wsse:Username', @options[:login]
|
1023
|
+
xml.tag! 'wsse:Password', @options[:password], 'Type' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'
|
1024
|
+
end
|
1025
|
+
end
|
1026
|
+
end
|
1027
|
+
xml.tag! 's:Body', { 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema' } do
|
1028
|
+
xml.tag! 'requestMessage', { 'xmlns' => "urn:schemas-cybersource-com:transaction-data-#{xsd_version}" } do
|
1029
|
+
add_merchant_data(xml, options)
|
1030
|
+
xml << body
|
1031
|
+
end
|
1032
|
+
end
|
1033
|
+
end
|
1034
|
+
xml.target!
|
1035
|
+
end
|
1036
|
+
|
1037
|
+
# Contact CyberSource, make the SOAP request, and parse the reply into a
|
1038
|
+
# Response object
|
1039
|
+
def commit(request, action, amount, options)
|
1040
|
+
begin
|
1041
|
+
raw_response = ssl_post(test? ? self.test_url : self.live_url, build_request(request, options))
|
1042
|
+
rescue ResponseError => e
|
1043
|
+
raw_response = e.response.body
|
1044
|
+
end
|
1045
|
+
|
1046
|
+
begin
|
1047
|
+
response = parse(raw_response)
|
1048
|
+
rescue REXML::ParseException => e
|
1049
|
+
response = { message: e.to_s }
|
1050
|
+
end
|
1051
|
+
|
1052
|
+
success = success?(response)
|
1053
|
+
message = message_from(response)
|
1054
|
+
authorization = success || in_fraud_review?(response) ? authorization_from(response, action, amount, options) : nil
|
1055
|
+
|
1056
|
+
message = auto_void?(authorization_from(response, action, amount, options), response, message, options)
|
1057
|
+
|
1058
|
+
Response.new(success, message, response,
|
1059
|
+
test: test?,
|
1060
|
+
authorization: authorization,
|
1061
|
+
fraud_review: in_fraud_review?(response),
|
1062
|
+
avs_result: { code: response[:avsCode] },
|
1063
|
+
cvv_result: response[:cvCode])
|
1064
|
+
end
|
1065
|
+
|
1066
|
+
def auto_void?(authorization, response, message, options = {})
|
1067
|
+
return message unless response[:reasonCode] == '230' && options[:auto_void_230]
|
1068
|
+
|
1069
|
+
response = void(authorization, options)
|
1070
|
+
response&.success? ? message += ' - transaction has been auto-voided.' : message += ' - transaction could not be auto-voided.'
|
1071
|
+
message
|
1072
|
+
end
|
1073
|
+
|
1074
|
+
# Parse the SOAP response
|
1075
|
+
# Technique inspired by the Paypal Gateway
|
1076
|
+
def parse(xml)
|
1077
|
+
reply = {}
|
1078
|
+
xml = REXML::Document.new(xml)
|
1079
|
+
if root = REXML::XPath.first(xml, '//c:replyMessage')
|
1080
|
+
root.elements.to_a.each do |node|
|
1081
|
+
case node.expanded_name
|
1082
|
+
when 'c:reasonCode'
|
1083
|
+
reply[:reasonCode] = node.text
|
1084
|
+
reply[:message] = reason_message(node.text)
|
1085
|
+
else
|
1086
|
+
parse_element(reply, node)
|
1087
|
+
end
|
1088
|
+
end
|
1089
|
+
elsif root = REXML::XPath.first(xml, '//soap:Fault')
|
1090
|
+
parse_element(reply, root)
|
1091
|
+
reply[:message] = "#{reply[:faultcode]}: #{reply[:faultstring]}"
|
1092
|
+
end
|
1093
|
+
return reply
|
1094
|
+
end
|
1095
|
+
|
1096
|
+
def parse_element(reply, node)
|
1097
|
+
if node.has_elements?
|
1098
|
+
node.elements.each { |e| parse_element(reply, e) }
|
1099
|
+
else
|
1100
|
+
if /item/.match?(node.parent.name)
|
1101
|
+
parent = node.parent.name
|
1102
|
+
parent += '_' + node.parent.attributes['id'] if node.parent.attributes['id']
|
1103
|
+
parent += '_'
|
1104
|
+
end
|
1105
|
+
reply["#{parent}#{node.name}".to_sym] ||= node.text
|
1106
|
+
end
|
1107
|
+
return reply
|
1108
|
+
end
|
1109
|
+
|
1110
|
+
def reason_message(reason_code)
|
1111
|
+
return if reason_code.blank?
|
1112
|
+
|
1113
|
+
@@response_codes[:"r#{reason_code}"]
|
1114
|
+
end
|
1115
|
+
|
1116
|
+
def authorization_from(response, action, amount, options)
|
1117
|
+
[options[:order_id], response[:requestID], response[:requestToken], action, amount,
|
1118
|
+
options[:currency], response[:subscriptionID], options[:payment_method]].join(';')
|
1119
|
+
end
|
1120
|
+
|
1121
|
+
def in_fraud_review?(response)
|
1122
|
+
response[:decision] == @@decision_codes[:review]
|
1123
|
+
end
|
1124
|
+
|
1125
|
+
def success?(response)
|
1126
|
+
response[:decision] == @@decision_codes[:accept]
|
1127
|
+
end
|
1128
|
+
|
1129
|
+
def message_from(response)
|
1130
|
+
if response[:reasonCode] == '101' && response[:missingField]
|
1131
|
+
"#{response[:message]}: #{response[:missingField]}"
|
1132
|
+
elsif response[:reasonCode] == '102' && response[:invalidField]
|
1133
|
+
"#{response[:message]}: #{response[:invalidField]}"
|
1134
|
+
else
|
1135
|
+
response[:message]
|
1136
|
+
end
|
1137
|
+
end
|
1138
|
+
|
1139
|
+
def eligible_for_zero_auth?(payment_method, options = {})
|
1140
|
+
payment_method.is_a?(CreditCard) && options[:zero_amount_auth]
|
1141
|
+
end
|
1142
|
+
|
1143
|
+
def format_routing_number(routing_number, options)
|
1144
|
+
options[:currency] == 'CAD' && routing_number.length > 8 ? routing_number[-8..-1] : routing_number
|
1145
|
+
end
|
1146
|
+
end
|
1147
|
+
end
|
1148
|
+
end
|