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,388 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class OppGateway < Gateway
|
4
|
+
# = Open Payment Platform
|
5
|
+
#
|
6
|
+
# The Open Payment Platform includes a powerful omni-channel transaction processing API,
|
7
|
+
# enabling you to quickly and flexibly build new applications and services on the platform.
|
8
|
+
#
|
9
|
+
# This plugin enables connectivity to the Open Payment Platform for activemerchant.
|
10
|
+
#
|
11
|
+
# For any questions or comments please contact support@payon.com
|
12
|
+
#
|
13
|
+
# == Usage
|
14
|
+
#
|
15
|
+
# gateway = ActiveMerchant::Billing::OppGateway.new(
|
16
|
+
# user_id: 'merchant user id',
|
17
|
+
# password: 'password',
|
18
|
+
# entity_id: 'entity id',
|
19
|
+
# )
|
20
|
+
#
|
21
|
+
# # set up credit card object as in main ActiveMerchant example
|
22
|
+
# creditcard = ActiveMerchant::Billing::CreditCard.new(
|
23
|
+
# :type => 'visa',
|
24
|
+
# :number => '4242424242424242',
|
25
|
+
# :month => 8,
|
26
|
+
# :year => 2009,
|
27
|
+
# :first_name => 'Bob',
|
28
|
+
# :last_name => 'Bobsen'
|
29
|
+
# :verification_value: '123')
|
30
|
+
#
|
31
|
+
# # Request: complete example, including address, billing address, shipping address
|
32
|
+
# complete_request_options = {
|
33
|
+
# order_id: "your merchant/shop order id", # alternative is to set merchantInvoiceId
|
34
|
+
# merchant_transaction_id: "your merchant/shop transaction id",
|
35
|
+
# address: address,
|
36
|
+
# description: 'Store Purchase - Books',
|
37
|
+
# risk_workflow: false,
|
38
|
+
# test_mode: 'EXTERNAL' # or 'INTERNAL', valid only for test system
|
39
|
+
# create_registration: false, # payment details will be stored on the server an latter can be referenced
|
40
|
+
#
|
41
|
+
# billing_address: {
|
42
|
+
# address1: '123 Test Street',
|
43
|
+
# city: 'Test',
|
44
|
+
# state: 'TE',
|
45
|
+
# zip: 'AB12CD',
|
46
|
+
# country: 'GB',
|
47
|
+
# },
|
48
|
+
# shipping_address: {
|
49
|
+
# name: 'Muton DeMicelis',
|
50
|
+
# address1: 'My Street On Upiter, Apt 3.14/2.78',
|
51
|
+
# city: 'Munich',
|
52
|
+
# state: 'Bov',
|
53
|
+
# zip: '81675',
|
54
|
+
# country: 'DE',
|
55
|
+
# },
|
56
|
+
# customer: {
|
57
|
+
# merchant_customer_id: "your merchant/customer id",
|
58
|
+
# givenname: 'Jane',
|
59
|
+
# surname: 'Jones',
|
60
|
+
# birth_date: '1965-05-01',
|
61
|
+
# phone: '(?!?)555-5555',
|
62
|
+
# mobile: '(?!?)234-23423',
|
63
|
+
# email: 'jane@jones.com',
|
64
|
+
# company_name: 'JJ Ltd.',
|
65
|
+
# identification_doctype: 'PASSPORT',
|
66
|
+
# identification_docid: 'FakeID2342431234123',
|
67
|
+
# ip: 101.102.103.104,
|
68
|
+
# },
|
69
|
+
# }
|
70
|
+
#
|
71
|
+
# # Request: minimal example
|
72
|
+
# minimal_request_options = {
|
73
|
+
# order_id: "your merchant/shop order id", # alternative is to set merchantInvoiceId
|
74
|
+
# description: 'Store Purchase - Books',
|
75
|
+
# }
|
76
|
+
#
|
77
|
+
# options =
|
78
|
+
# # run request
|
79
|
+
# response = gateway.purchase(754, creditcard, options) # charge 7,54 EUR
|
80
|
+
#
|
81
|
+
# response.success? # Check whether the transaction was successful
|
82
|
+
# response.error_code # Retrieve the error message - it's mapped to Gateway::STANDARD_ERROR_CODE
|
83
|
+
# response.message # Retrieve the message returned by opp
|
84
|
+
# response.authorization # Retrieve the unique transaction ID returned by opp
|
85
|
+
# response.params['result']['code'] # Retrieve original return code returned by opp server
|
86
|
+
#
|
87
|
+
# == Errors
|
88
|
+
# If transaction is not successful, response.error_code contains mapped to Gateway::STANDARD_ERROR_CODE error message.
|
89
|
+
# Complete list of opp error codes can be viewed on https://docs.oppwa.com/
|
90
|
+
# Because this list is much bigger than Gateway::STANDARD_ERROR_CODE, only fraction is mapped to Gateway::STANDARD_ERROR_CODE.
|
91
|
+
# All other codes are mapped as Gateway::STANDARD_ERROR_CODE[:processing_error], so if this is the case,
|
92
|
+
# you may check the original result code from OPP that can be found in response.params['result']['code']
|
93
|
+
#
|
94
|
+
# == Special features
|
95
|
+
# For purchase method risk check can be forced when options[:risk_workflow] = true
|
96
|
+
# This will split (on OPP server side) the transaction into two separate transactions: authorize and capture,
|
97
|
+
# but capture will be executed only if risk checks are successful.
|
98
|
+
#
|
99
|
+
# For testing you may use the test account details listed fixtures.yml under opp. It is important to note that there are two test modes available:
|
100
|
+
# options[:test_mode]='EXTERNAL' causes test transactions to be forwarded to the processor's test system for 'end-to-end' testing
|
101
|
+
# options[:test_mode]='INTERNAL' causes transactions to be sent to opp simulators, which is useful when switching to the live endpoint for connectivity testing.
|
102
|
+
# If no test_mode parameter is sent, test_mode=INTERNAL is the default behaviour.
|
103
|
+
#
|
104
|
+
# Billing Address, Shipping Address, Custom Parameters are supported as described under https://docs.oppwa.com/parameters
|
105
|
+
# See complete example above for details.
|
106
|
+
#
|
107
|
+
# == Tokenization
|
108
|
+
# When create_registration is set to true, the payment details will be stored and a token will be returned in registrationId response field,
|
109
|
+
# which can subsequently be used to reference the stored payment.
|
110
|
+
|
111
|
+
self.test_url = 'https://test.oppwa.com/v1/payments'
|
112
|
+
self.live_url = 'https://oppwa.com/v1/payments'
|
113
|
+
|
114
|
+
self.supported_countries = %w(AD AI AG AR AU AT BS BB BE BZ BM BR BN BG CA HR CY CZ DK DM EE FI FR DE GR GD GY HK HU IS IN IL IT JP LV LI LT LU MY MT MX MC MS NL PA PL PT KN LC MF VC SM SG SK SI ZA ES SR SE CH TR GB US UY)
|
115
|
+
self.default_currency = 'EUR'
|
116
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :discover, :jcb, :maestro, :dankort]
|
117
|
+
|
118
|
+
self.homepage_url = 'https://docs.oppwa.com'
|
119
|
+
self.display_name = 'Open Payment Platform'
|
120
|
+
|
121
|
+
def initialize(options={})
|
122
|
+
requires!(options, :user_id, :password, :entity_id)
|
123
|
+
super
|
124
|
+
end
|
125
|
+
|
126
|
+
def purchase(money, payment, options={})
|
127
|
+
# debit
|
128
|
+
if payment.is_a?(String)
|
129
|
+
options[:registrationId] = payment
|
130
|
+
end
|
131
|
+
execute_dbpa(options[:risk_workflow] ? 'PA.CP': 'DB',
|
132
|
+
money, payment, options)
|
133
|
+
end
|
134
|
+
|
135
|
+
def authorize(money, payment, options={})
|
136
|
+
# preauthorization PA
|
137
|
+
execute_dbpa('PA', money, payment, options)
|
138
|
+
end
|
139
|
+
|
140
|
+
def capture(money, authorization, options={})
|
141
|
+
# capture CP
|
142
|
+
execute_referencing('CP', money, authorization, options)
|
143
|
+
end
|
144
|
+
|
145
|
+
def refund(money, authorization, options={})
|
146
|
+
# refund RF
|
147
|
+
execute_referencing('RF', money, authorization, options)
|
148
|
+
end
|
149
|
+
|
150
|
+
def void(authorization, options={})
|
151
|
+
# reversal RV
|
152
|
+
execute_referencing('RV', nil, authorization, options)
|
153
|
+
end
|
154
|
+
|
155
|
+
def verify(credit_card, options={})
|
156
|
+
MultiResponse.run(:use_first_response) do |r|
|
157
|
+
r.process { authorize(100, credit_card, options) }
|
158
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def store(credit_card, options = {})
|
163
|
+
execute_store(credit_card, options.merge(store: true))
|
164
|
+
end
|
165
|
+
|
166
|
+
def supports_scrubbing?
|
167
|
+
true
|
168
|
+
end
|
169
|
+
|
170
|
+
def scrub(transcript)
|
171
|
+
transcript.
|
172
|
+
gsub(%r((authentication\.password=)\w+), '\1[FILTERED]').
|
173
|
+
gsub(%r((card\.number=)\d+), '\1[FILTERED]').
|
174
|
+
gsub(%r((card\.cvv=)\d+), '\1[FILTERED]')
|
175
|
+
end
|
176
|
+
|
177
|
+
private
|
178
|
+
|
179
|
+
def execute_store(payment, options)
|
180
|
+
post = {}
|
181
|
+
add_payment_method(post, payment, options)
|
182
|
+
add_address(post, options)
|
183
|
+
add_options(post, options)
|
184
|
+
add_3d_secure(post, options)
|
185
|
+
commit(post, nil, options)
|
186
|
+
end
|
187
|
+
|
188
|
+
def execute_dbpa(txtype, money, payment, options)
|
189
|
+
post = {}
|
190
|
+
post[:paymentType] = txtype
|
191
|
+
add_invoice(post, money, options)
|
192
|
+
add_payment_method(post, payment, options)
|
193
|
+
add_address(post, options)
|
194
|
+
add_customer_data(post, payment, options)
|
195
|
+
add_options(post, options)
|
196
|
+
add_3d_secure(post, options)
|
197
|
+
commit(post, nil, options)
|
198
|
+
end
|
199
|
+
|
200
|
+
def execute_referencing(txtype, money, authorization, options)
|
201
|
+
post = {}
|
202
|
+
post[:paymentType] = txtype
|
203
|
+
add_invoice(post, money, options)
|
204
|
+
commit(post, authorization, options)
|
205
|
+
end
|
206
|
+
|
207
|
+
def add_authentication(post)
|
208
|
+
post[:authentication] = { entityId: @options[:entity_id], password: @options[:password], userId: @options[:user_id]}
|
209
|
+
end
|
210
|
+
|
211
|
+
def add_customer_data(post, payment, options)
|
212
|
+
if options[:customer]
|
213
|
+
post[:customer] = {
|
214
|
+
merchantCustomerId: options[:customer][:merchant_customer_id],
|
215
|
+
givenName: options[:customer][:givenname] || payment.first_name,
|
216
|
+
surname: options[:customer][:surname] || payment.last_name,
|
217
|
+
birthDate: options[:customer][:birth_date],
|
218
|
+
phone: options[:customer][:phone],
|
219
|
+
mobile: options[:customer][:mobile],
|
220
|
+
email: options[:customer][:email] || options[:email],
|
221
|
+
companyName: options[:customer][:company_name],
|
222
|
+
identificationDocType: options[:customer][:identification_doctype],
|
223
|
+
identificationDocId: options[:customer][:identification_docid],
|
224
|
+
ip: options[:customer][:ip] || options[:ip]
|
225
|
+
}
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
def add_address(post, options)
|
230
|
+
if billing_address = options[:billing_address] || options[:address]
|
231
|
+
address(post, billing_address, 'billing')
|
232
|
+
end
|
233
|
+
if shipping_address = options[:shipping_address]
|
234
|
+
address(post, shipping_address, 'shipping')
|
235
|
+
if shipping_address[:name]
|
236
|
+
firstname, lastname = shipping_address[:name].split(' ')
|
237
|
+
post[:shipping] = { givenName: firstname, surname: lastname }
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
def address(post, address, prefix)
|
243
|
+
post[prefix] = {
|
244
|
+
street1: address[:address1],
|
245
|
+
street2: address[:address2],
|
246
|
+
city: address[:city],
|
247
|
+
state: address[:state],
|
248
|
+
postcode: address[:zip],
|
249
|
+
country: address[:country],
|
250
|
+
}
|
251
|
+
end
|
252
|
+
|
253
|
+
def add_invoice(post, money, options)
|
254
|
+
post[:amount] = amount(money)
|
255
|
+
post[:currency] = options[:currency] || currency(money) unless post[:paymentType] == 'RV'
|
256
|
+
post[:descriptor] = options[:description] || options[:descriptor]
|
257
|
+
post[:merchantInvoiceId] = options[:merchantInvoiceId] || options[:order_id]
|
258
|
+
post[:merchantTransactionId] = options[:merchant_transaction_id] || generate_unique_id
|
259
|
+
end
|
260
|
+
|
261
|
+
def add_payment_method(post, payment, options)
|
262
|
+
return if payment.is_a?(String)
|
263
|
+
if options[:registrationId]
|
264
|
+
post[:card] = {
|
265
|
+
cvv: payment.verification_value,
|
266
|
+
}
|
267
|
+
else
|
268
|
+
post[:paymentBrand] = payment.brand.upcase
|
269
|
+
post[:card] = {
|
270
|
+
holder: payment.name,
|
271
|
+
number: payment.number,
|
272
|
+
expiryMonth: '%02d' % payment.month,
|
273
|
+
expiryYear: payment.year,
|
274
|
+
cvv: payment.verification_value,
|
275
|
+
}
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
def add_3d_secure(post, options)
|
280
|
+
return unless options[:eci] && options[:cavv] && options[:xid]
|
281
|
+
|
282
|
+
post[:threeDSecure] = {
|
283
|
+
eci: options[:eci],
|
284
|
+
verificationId: options[:cavv],
|
285
|
+
xid: options[:xid]
|
286
|
+
}
|
287
|
+
end
|
288
|
+
|
289
|
+
def add_options(post, options)
|
290
|
+
post[:createRegistration] = options[:create_registration] if options[:create_registration] && !options[:registrationId]
|
291
|
+
post[:testMode] = options[:test_mode] if test? && options[:test_mode]
|
292
|
+
options.each { |key, value| post[key] = value if key.to_s.match('customParameters\[[a-zA-Z0-9\._]{3,64}\]') }
|
293
|
+
post['customParameters[SHOPPER_pluginId]'] = 'activemerchant'
|
294
|
+
post['customParameters[custom_disable3DSecure]'] = options[:disable_3d_secure] if options[:disable_3d_secure]
|
295
|
+
end
|
296
|
+
|
297
|
+
def build_url(url, authorization, options)
|
298
|
+
if options[:store]
|
299
|
+
url.gsub(/payments/, 'registrations')
|
300
|
+
elsif options[:registrationId]
|
301
|
+
"#{url.gsub(/payments/, 'registrations')}/#{options[:registrationId]}/payments"
|
302
|
+
elsif authorization
|
303
|
+
"#{url}/#{authorization}"
|
304
|
+
else
|
305
|
+
url
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
def commit(post, authorization, options)
|
310
|
+
url = build_url(test? ? test_url : live_url, authorization, options)
|
311
|
+
add_authentication(post)
|
312
|
+
post = flatten_hash(post)
|
313
|
+
|
314
|
+
response = begin
|
315
|
+
parse(
|
316
|
+
ssl_post(
|
317
|
+
url,
|
318
|
+
post.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&'),
|
319
|
+
'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'
|
320
|
+
)
|
321
|
+
)
|
322
|
+
rescue ResponseError => e
|
323
|
+
parse(e.response.body)
|
324
|
+
end
|
325
|
+
|
326
|
+
success = success_from(response)
|
327
|
+
|
328
|
+
Response.new(
|
329
|
+
success,
|
330
|
+
message_from(response),
|
331
|
+
response,
|
332
|
+
authorization: authorization_from(response),
|
333
|
+
test: test?,
|
334
|
+
error_code: success ? nil : error_code_from(response)
|
335
|
+
)
|
336
|
+
end
|
337
|
+
|
338
|
+
def parse(body)
|
339
|
+
JSON.parse(body)
|
340
|
+
rescue JSON::ParserError
|
341
|
+
json_error(body)
|
342
|
+
end
|
343
|
+
|
344
|
+
def json_error(body)
|
345
|
+
message = "Invalid response received #{body.inspect}"
|
346
|
+
{ 'result' => {'description' => message, 'code' => 'unknown' } }
|
347
|
+
end
|
348
|
+
|
349
|
+
def success_from(response)
|
350
|
+
return false unless response['result']
|
351
|
+
|
352
|
+
success_regex = /^(000\.000\.|000\.100\.1|000\.[36])/
|
353
|
+
|
354
|
+
if success_regex =~ response['result']['code']
|
355
|
+
true
|
356
|
+
else
|
357
|
+
false
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
def message_from(response)
|
362
|
+
return 'Failed' unless response['result']
|
363
|
+
|
364
|
+
response['result']['description']
|
365
|
+
end
|
366
|
+
|
367
|
+
def authorization_from(response)
|
368
|
+
response['id']
|
369
|
+
end
|
370
|
+
|
371
|
+
def error_code_from(response)
|
372
|
+
response['result']['code']
|
373
|
+
end
|
374
|
+
|
375
|
+
def flatten_hash(hash)
|
376
|
+
hash.each_with_object({}) do |(k, v), h|
|
377
|
+
if v.is_a? Hash
|
378
|
+
flatten_hash(v).map do |h_k, h_v|
|
379
|
+
h["#{k}.#{h_k}".to_sym] = h_v
|
380
|
+
end
|
381
|
+
else
|
382
|
+
h[k] = v
|
383
|
+
end
|
384
|
+
end
|
385
|
+
end
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|
@@ -0,0 +1,332 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class OptimalPaymentGateway < Gateway
|
4
|
+
self.test_url = 'https://webservices.test.optimalpayments.com/creditcardWS/CreditCardServlet/v1'
|
5
|
+
self.live_url = 'https://webservices.optimalpayments.com/creditcardWS/CreditCardServlet/v1'
|
6
|
+
|
7
|
+
# The countries the gateway supports merchants from as 2 digit ISO country codes
|
8
|
+
self.supported_countries = ['CA', 'US', 'GB', 'AU', 'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK',
|
9
|
+
'EE', 'FI', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT',
|
10
|
+
'NL', 'NO', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'CH']
|
11
|
+
|
12
|
+
# The card types supported by the payment gateway
|
13
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club]
|
14
|
+
|
15
|
+
# The homepage URL of the gateway
|
16
|
+
self.homepage_url = 'http://www.optimalpayments.com/'
|
17
|
+
|
18
|
+
# The name of the gateway
|
19
|
+
self.display_name = 'Optimal Payments'
|
20
|
+
|
21
|
+
def initialize(options = {})
|
22
|
+
if(options[:login])
|
23
|
+
ActiveMerchant.deprecated("The 'login' option is deprecated in favor of 'store_id' and will be removed in a future version.")
|
24
|
+
options[:store_id] = options[:login]
|
25
|
+
end
|
26
|
+
|
27
|
+
if(options[:account])
|
28
|
+
ActiveMerchant.deprecated("The 'account' option is deprecated in favor of 'account_number' and will be removed in a future version.")
|
29
|
+
options[:account_number] = options[:account]
|
30
|
+
end
|
31
|
+
|
32
|
+
requires!(options, :account_number, :store_id, :password)
|
33
|
+
super
|
34
|
+
end
|
35
|
+
|
36
|
+
def authorize(money, card_or_auth, options = {})
|
37
|
+
parse_card_or_auth(card_or_auth, options)
|
38
|
+
commit("cc#{@stored_data}Authorize", money, options)
|
39
|
+
end
|
40
|
+
alias stored_authorize authorize # back-compat
|
41
|
+
|
42
|
+
def purchase(money, card_or_auth, options = {})
|
43
|
+
parse_card_or_auth(card_or_auth, options)
|
44
|
+
commit("cc#{@stored_data}Purchase", money, options)
|
45
|
+
end
|
46
|
+
alias stored_purchase purchase # back-compat
|
47
|
+
|
48
|
+
def refund(money, authorization, options = {})
|
49
|
+
options[:confirmationNumber] = authorization
|
50
|
+
commit('ccCredit', money, options)
|
51
|
+
end
|
52
|
+
|
53
|
+
def void(authorization, options = {})
|
54
|
+
options[:confirmationNumber] = authorization
|
55
|
+
commit('ccAuthorizeReversal', nil, options)
|
56
|
+
end
|
57
|
+
|
58
|
+
def capture(money, authorization, options = {})
|
59
|
+
options[:confirmationNumber] = authorization
|
60
|
+
commit('ccSettlement', money, options)
|
61
|
+
end
|
62
|
+
|
63
|
+
def verify(credit_card, options = {})
|
64
|
+
parse_card_or_auth(credit_card, options)
|
65
|
+
commit('ccVerification', 0, options)
|
66
|
+
end
|
67
|
+
|
68
|
+
def supports_scrubbing?
|
69
|
+
true
|
70
|
+
end
|
71
|
+
|
72
|
+
def scrub(transcript)
|
73
|
+
transcript.
|
74
|
+
gsub(%r((%3CstorePwd%3E).*(%3C(%2F|/)storePwd%3E))i, '\1[FILTERED]\2').
|
75
|
+
gsub(%r((%3CcardNum%3E)\d*(%3C(%2F|/)cardNum%3E))i, '\1[FILTERED]\2').
|
76
|
+
gsub(%r((%3Ccvd%3E)\d*(%3C(%2F|/)cvd%3E))i, '\1[FILTERED]\2')
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def parse_card_or_auth(card_or_auth, options)
|
82
|
+
if card_or_auth.respond_to?(:number)
|
83
|
+
@credit_card = card_or_auth
|
84
|
+
@stored_data = ''
|
85
|
+
else
|
86
|
+
options[:confirmationNumber] = card_or_auth
|
87
|
+
@stored_data = 'StoredData'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def parse(body)
|
92
|
+
REXML::Document.new(body || '')
|
93
|
+
end
|
94
|
+
|
95
|
+
def commit(action, money, post)
|
96
|
+
post[:order_id] ||= 'order_id'
|
97
|
+
|
98
|
+
xml = case action
|
99
|
+
when 'ccAuthorize', 'ccPurchase', 'ccVerification'
|
100
|
+
cc_auth_request(money, post)
|
101
|
+
when 'ccCredit', 'ccSettlement'
|
102
|
+
cc_post_auth_request(money, post)
|
103
|
+
when 'ccStoredDataAuthorize', 'ccStoredDataPurchase'
|
104
|
+
cc_stored_data_request(money, post)
|
105
|
+
when 'ccAuthorizeReversal'
|
106
|
+
cc_auth_reversal_request(post)
|
107
|
+
# when 'ccCancelSettle', 'ccCancelCredit', 'ccCancelPayment'
|
108
|
+
# cc_cancel_request(money, post)
|
109
|
+
# when 'ccPayment'
|
110
|
+
# cc_payment_request(money, post)
|
111
|
+
# when 'ccAuthenticate'
|
112
|
+
# cc_authenticate_request(money, post)
|
113
|
+
else
|
114
|
+
raise 'Unknown Action'
|
115
|
+
end
|
116
|
+
txnRequest = escape_uri(xml)
|
117
|
+
response = parse(ssl_post(test? ? self.test_url : self.live_url, "txnMode=#{action}&txnRequest=#{txnRequest}"))
|
118
|
+
|
119
|
+
Response.new(successful?(response), message_from(response), hash_from_xml(response),
|
120
|
+
:test => test?,
|
121
|
+
:authorization => authorization_from(response),
|
122
|
+
:avs_result => { :code => avs_result_from(response) },
|
123
|
+
:cvv_result => cvv_result_from(response)
|
124
|
+
)
|
125
|
+
end
|
126
|
+
|
127
|
+
# The upstream is picky and so we can't use CGI.escape like we want to
|
128
|
+
def escape_uri(uri)
|
129
|
+
URI::DEFAULT_PARSER.escape(uri)
|
130
|
+
end
|
131
|
+
|
132
|
+
def successful?(response)
|
133
|
+
REXML::XPath.first(response, '//decision').text == 'ACCEPTED' rescue false
|
134
|
+
end
|
135
|
+
|
136
|
+
def message_from(response)
|
137
|
+
REXML::XPath.each(response, '//detail') do |detail|
|
138
|
+
if detail.is_a?(REXML::Element) && detail.elements['tag'].text == 'InternalResponseDescription'
|
139
|
+
return detail.elements['value'].text
|
140
|
+
end
|
141
|
+
end
|
142
|
+
nil
|
143
|
+
end
|
144
|
+
|
145
|
+
def authorization_from(response)
|
146
|
+
get_text_from_document(response, '//confirmationNumber')
|
147
|
+
end
|
148
|
+
|
149
|
+
def avs_result_from(response)
|
150
|
+
get_text_from_document(response, '//avsResponse')
|
151
|
+
end
|
152
|
+
|
153
|
+
def cvv_result_from(response)
|
154
|
+
get_text_from_document(response, '//cvdResponse')
|
155
|
+
end
|
156
|
+
|
157
|
+
def hash_from_xml(response)
|
158
|
+
hsh = {}
|
159
|
+
%w(confirmationNumber authCode
|
160
|
+
decision code description
|
161
|
+
actionCode avsResponse cvdResponse
|
162
|
+
txnTime duplicateFound
|
163
|
+
).each do |tag|
|
164
|
+
node = REXML::XPath.first(response, "//#{tag}")
|
165
|
+
hsh[tag] = node.text if node
|
166
|
+
end
|
167
|
+
REXML::XPath.each(response, '//detail') do |detail|
|
168
|
+
next unless detail.is_a?(REXML::Element)
|
169
|
+
tag = detail.elements['tag'].text
|
170
|
+
value = detail.elements['value'].text
|
171
|
+
hsh[tag] = value
|
172
|
+
end
|
173
|
+
hsh
|
174
|
+
end
|
175
|
+
|
176
|
+
def xml_document(root_tag)
|
177
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
178
|
+
xml.tag!(root_tag, schema) do
|
179
|
+
yield xml
|
180
|
+
end
|
181
|
+
xml.target!
|
182
|
+
end
|
183
|
+
|
184
|
+
def get_text_from_document(document, node)
|
185
|
+
node = REXML::XPath.first(document, node)
|
186
|
+
node&.text
|
187
|
+
end
|
188
|
+
|
189
|
+
def cc_auth_request(money, opts)
|
190
|
+
xml_document('ccAuthRequestV1') do |xml|
|
191
|
+
build_merchant_account(xml)
|
192
|
+
xml.merchantRefNum opts[:order_id]
|
193
|
+
xml.amount(money/100.0)
|
194
|
+
build_card(xml, opts)
|
195
|
+
build_billing_details(xml, opts)
|
196
|
+
build_shipping_details(xml, opts)
|
197
|
+
xml.customerIP opts[:ip] if opts[:ip]
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def cc_auth_reversal_request(opts)
|
202
|
+
xml_document('ccAuthReversalRequestV1') do |xml|
|
203
|
+
build_merchant_account(xml)
|
204
|
+
xml.confirmationNumber opts[:confirmationNumber]
|
205
|
+
xml.merchantRefNum opts[:order_id]
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
def cc_post_auth_request(money, opts)
|
210
|
+
xml_document('ccPostAuthRequestV1') do |xml|
|
211
|
+
build_merchant_account(xml)
|
212
|
+
xml.confirmationNumber opts[:confirmationNumber]
|
213
|
+
xml.merchantRefNum opts[:order_id]
|
214
|
+
xml.amount(money/100.0)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
def cc_stored_data_request(money, opts)
|
219
|
+
xml_document('ccStoredDataRequestV1') do |xml|
|
220
|
+
build_merchant_account(xml)
|
221
|
+
xml.merchantRefNum opts[:order_id]
|
222
|
+
xml.confirmationNumber opts[:confirmationNumber]
|
223
|
+
xml.amount(money/100.0)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
# untested
|
228
|
+
#
|
229
|
+
# def cc_cancel_request(opts)
|
230
|
+
# xml_document('ccCancelRequestV1') do |xml|
|
231
|
+
# build_merchant_account(xml)
|
232
|
+
# xml.confirmationNumber opts[:confirmationNumber]
|
233
|
+
# end
|
234
|
+
# end
|
235
|
+
#
|
236
|
+
# def cc_payment_request(money, opts)
|
237
|
+
# xml_document('ccPaymentRequestV1') do |xml|
|
238
|
+
# build_merchant_account(xml)
|
239
|
+
# xml.merchantRefNum opts[:order_id]
|
240
|
+
# xml.amount(money/100.0)
|
241
|
+
# build_card(xml, opts)
|
242
|
+
# build_billing_details(xml, opts)
|
243
|
+
# end
|
244
|
+
# end
|
245
|
+
#
|
246
|
+
# def cc_authenticate_request(opts)
|
247
|
+
# xml_document('ccAuthenticateRequestV1') do |xml|
|
248
|
+
# build_merchant_account(xml)
|
249
|
+
# xml.confirmationNumber opts[:confirmationNumber]
|
250
|
+
# xml.paymentResponse 'myPaymentResponse'
|
251
|
+
# end
|
252
|
+
# end
|
253
|
+
|
254
|
+
def schema
|
255
|
+
{ 'xmlns' => 'http://www.optimalpayments.com/creditcard/xmlschema/v1',
|
256
|
+
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
|
257
|
+
'xsi:schemaLocation' => 'http://www.optimalpayments.com/creditcard/xmlschema/v1'
|
258
|
+
}
|
259
|
+
end
|
260
|
+
|
261
|
+
def build_merchant_account(xml)
|
262
|
+
xml.tag! 'merchantAccount' do
|
263
|
+
xml.tag! 'accountNum', @options[:account_number]
|
264
|
+
xml.tag! 'storeID', @options[:store_id]
|
265
|
+
xml.tag! 'storePwd', @options[:password]
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
def build_card(xml, opts)
|
270
|
+
xml.tag! 'card' do
|
271
|
+
xml.tag! 'cardNum', @credit_card.number
|
272
|
+
xml.tag! 'cardExpiry' do
|
273
|
+
xml.tag! 'month', @credit_card.month
|
274
|
+
xml.tag! 'year', @credit_card.year
|
275
|
+
end
|
276
|
+
if brand = card_type(@credit_card.brand)
|
277
|
+
xml.tag! 'cardType', brand
|
278
|
+
end
|
279
|
+
if @credit_card.verification_value?
|
280
|
+
xml.tag! 'cvdIndicator', '1' # Value Provided
|
281
|
+
xml.tag! 'cvd', @credit_card.verification_value
|
282
|
+
else
|
283
|
+
xml.tag! 'cvdIndicator', '0'
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
def build_billing_details(xml, opts)
|
289
|
+
xml.tag! 'billingDetails' do
|
290
|
+
xml.tag! 'cardPayMethod', 'WEB'
|
291
|
+
build_address(xml, opts[:billing_address]) if opts[:billing_address]
|
292
|
+
xml.tag! 'email', opts[:email] if opts[:email]
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
def build_shipping_details(xml, opts)
|
297
|
+
xml.tag! 'shippingDetails' do
|
298
|
+
build_address(xml, opts[:shipping_address])
|
299
|
+
xml.tag! 'email', opts[:email] if opts[:email]
|
300
|
+
end if opts[:shipping_address].present?
|
301
|
+
end
|
302
|
+
|
303
|
+
def build_address(xml, addr)
|
304
|
+
if addr[:name]
|
305
|
+
first_name, last_name = split_names(addr[:name])
|
306
|
+
xml.tag! 'firstName', first_name
|
307
|
+
xml.tag! 'lastName', last_name
|
308
|
+
end
|
309
|
+
xml.tag! 'street', addr[:address1] if addr[:address1].present?
|
310
|
+
xml.tag! 'street2', addr[:address2] if addr[:address2].present?
|
311
|
+
xml.tag! 'city', addr[:city] if addr[:city].present?
|
312
|
+
if addr[:state].present?
|
313
|
+
state_tag = %w(US CA).include?(addr[:country]) ? 'state' : 'region'
|
314
|
+
xml.tag! state_tag, addr[:state]
|
315
|
+
end
|
316
|
+
xml.tag! 'country', addr[:country] if addr[:country].present?
|
317
|
+
xml.tag! 'zip', addr[:zip] if addr[:zip].present?
|
318
|
+
xml.tag! 'phone', addr[:phone] if addr[:phone].present?
|
319
|
+
end
|
320
|
+
|
321
|
+
def card_type(key)
|
322
|
+
{ 'visa' => 'VI',
|
323
|
+
'master' => 'MC',
|
324
|
+
'american_express'=> 'AM',
|
325
|
+
'discover' => 'DI',
|
326
|
+
'diners_club' => 'DC',
|
327
|
+
}[key]
|
328
|
+
end
|
329
|
+
|
330
|
+
end
|
331
|
+
end
|
332
|
+
end
|