activemerchant-nsp 1.27.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +952 -0
- data/CONTRIBUTORS +347 -0
- data/MIT-LICENSE +20 -0
- data/README.md +204 -0
- data/gem-public_cert.pem +20 -0
- data/lib/active_merchant.rb +63 -0
- data/lib/active_merchant/billing.rb +9 -0
- data/lib/active_merchant/billing/avs_result.rb +98 -0
- data/lib/active_merchant/billing/base.rb +56 -0
- data/lib/active_merchant/billing/check.rb +68 -0
- data/lib/active_merchant/billing/credit_card.rb +274 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +21 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +143 -0
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/expiry_date.rb +34 -0
- data/lib/active_merchant/billing/gateway.rb +176 -0
- data/lib/active_merchant/billing/gateways.rb +18 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +695 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +943 -0
- data/lib/active_merchant/billing/gateways/balanced.rb +462 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +308 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +167 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +389 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +492 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +142 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +389 -0
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +23 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +230 -0
- data/lib/active_merchant/billing/gateways/certo_direct.rb +278 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +576 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +597 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +235 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +137 -0
- data/lib/active_merchant/billing/gateways/epay.rb +276 -0
- data/lib/active_merchant/billing/gateways/eway.rb +287 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +265 -0
- data/lib/active_merchant/billing/gateways/exact.rb +227 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +152 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +168 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +177 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +262 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +252 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +13 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +29 -0
- data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +55 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +221 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +257 -0
- data/lib/active_merchant/billing/gateways/itransact.rb +450 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +276 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +451 -0
- data/lib/active_merchant/billing/gateways/litle.rb +290 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +157 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +289 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +323 -0
- data/lib/active_merchant/billing/gateways/migs.rb +263 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +38 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +220 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +250 -0
- data/lib/active_merchant/billing/gateways/moneris_us.rb +211 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +257 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +189 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +239 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +196 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +13 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +427 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +277 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +351 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +46 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +266 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +397 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +201 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +268 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +212 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +224 -0
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +15 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +21 -0
- data/lib/active_merchant/billing/gateways/payment_express.rb +282 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +106 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +653 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +49 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +245 -0
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +43 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +178 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +201 -0
- data/lib/active_merchant/billing/gateways/payway.rb +214 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +295 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +219 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +304 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +297 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +282 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +298 -0
- data/lib/active_merchant/billing/gateways/realex.rb +313 -0
- data/lib/active_merchant/billing/gateways/sage.rb +148 -0
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +115 -0
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +322 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +144 -0
- data/lib/active_merchant/billing/gateways/samurai.rb +121 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +330 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +284 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +458 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +273 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +236 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +127 -0
- data/lib/active_merchant/billing/gateways/transax.rb +23 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +423 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1497 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +206 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +233 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +194 -0
- data/lib/active_merchant/billing/gateways/vindicia.rb +359 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +313 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +271 -0
- data/lib/active_merchant/billing/integrations.rb +17 -0
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +73 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +38 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +228 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +340 -0
- data/lib/active_merchant/billing/integrations/bogus.rb +23 -0
- data/lib/active_merchant/billing/integrations/bogus/helper.rb +17 -0
- data/lib/active_merchant/billing/integrations/bogus/notification.rb +11 -0
- data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/chronopay.rb +23 -0
- data/lib/active_merchant/billing/integrations/chronopay/helper.rb +120 -0
- data/lib/active_merchant/billing/integrations/chronopay/notification.rb +158 -0
- data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/direc_pay.rb +41 -0
- data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +200 -0
- data/lib/active_merchant/billing/integrations/direc_pay/notification.rb +76 -0
- data/lib/active_merchant/billing/integrations/direc_pay/return.rb +32 -0
- data/lib/active_merchant/billing/integrations/direc_pay/status.rb +37 -0
- data/lib/active_merchant/billing/integrations/directebanking.rb +47 -0
- data/lib/active_merchant/billing/integrations/directebanking/helper.rb +90 -0
- data/lib/active_merchant/billing/integrations/directebanking/notification.rb +120 -0
- data/lib/active_merchant/billing/integrations/directebanking/return.rb +11 -0
- data/lib/active_merchant/billing/integrations/dotpay.rb +22 -0
- data/lib/active_merchant/billing/integrations/dotpay/helper.rb +77 -0
- data/lib/active_merchant/billing/integrations/dotpay/notification.rb +86 -0
- data/lib/active_merchant/billing/integrations/dotpay/return.rb +11 -0
- data/lib/active_merchant/billing/integrations/dwolla.rb +30 -0
- data/lib/active_merchant/billing/integrations/dwolla/helper.rb +31 -0
- data/lib/active_merchant/billing/integrations/dwolla/notification.rb +55 -0
- data/lib/active_merchant/billing/integrations/dwolla/return.rb +38 -0
- data/lib/active_merchant/billing/integrations/e_payment_plans.rb +48 -0
- data/lib/active_merchant/billing/integrations/e_payment_plans/helper.rb +34 -0
- data/lib/active_merchant/billing/integrations/e_payment_plans/notification.rb +84 -0
- data/lib/active_merchant/billing/integrations/easy_pay.rb +30 -0
- data/lib/active_merchant/billing/integrations/easy_pay/common.rb +40 -0
- data/lib/active_merchant/billing/integrations/easy_pay/helper.rb +40 -0
- data/lib/active_merchant/billing/integrations/easy_pay/notification.rb +51 -0
- data/lib/active_merchant/billing/integrations/epay.rb +21 -0
- data/lib/active_merchant/billing/integrations/epay/helper.rb +55 -0
- data/lib/active_merchant/billing/integrations/epay/notification.rb +110 -0
- data/lib/active_merchant/billing/integrations/first_data.rb +38 -0
- data/lib/active_merchant/billing/integrations/first_data/helper.rb +63 -0
- data/lib/active_merchant/billing/integrations/first_data/notification.rb +56 -0
- data/lib/active_merchant/billing/integrations/gestpay.rb +25 -0
- data/lib/active_merchant/billing/integrations/gestpay/common.rb +42 -0
- data/lib/active_merchant/billing/integrations/gestpay/helper.rb +70 -0
- data/lib/active_merchant/billing/integrations/gestpay/notification.rb +85 -0
- data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/helper.rb +117 -0
- data/lib/active_merchant/billing/integrations/hi_trust.rb +27 -0
- data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
- data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +59 -0
- data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
- data/lib/active_merchant/billing/integrations/maksuturva.rb +86 -0
- data/lib/active_merchant/billing/integrations/maksuturva/helper.rb +119 -0
- data/lib/active_merchant/billing/integrations/maksuturva/notification.rb +48 -0
- data/lib/active_merchant/billing/integrations/moneybookers.rb +26 -0
- data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +59 -0
- data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +129 -0
- data/lib/active_merchant/billing/integrations/nelnet.rb +40 -0
- data/lib/active_merchant/billing/integrations/nelnet/helper.rb +34 -0
- data/lib/active_merchant/billing/integrations/nelnet/notification.rb +100 -0
- data/lib/active_merchant/billing/integrations/nochex.rb +88 -0
- data/lib/active_merchant/billing/integrations/nochex/helper.rb +68 -0
- data/lib/active_merchant/billing/integrations/nochex/notification.rb +94 -0
- data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/notification.rb +62 -0
- data/lib/active_merchant/billing/integrations/paxum.rb +44 -0
- data/lib/active_merchant/billing/integrations/paxum/common.rb +24 -0
- data/lib/active_merchant/billing/integrations/paxum/helper.rb +42 -0
- data/lib/active_merchant/billing/integrations/paxum/notification.rb +33 -0
- data/lib/active_merchant/billing/integrations/payflow_link.rb +21 -0
- data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +100 -0
- data/lib/active_merchant/billing/integrations/payflow_link/notification.rb +78 -0
- data/lib/active_merchant/billing/integrations/paypal.rb +39 -0
- data/lib/active_merchant/billing/integrations/paypal/helper.rb +119 -0
- data/lib/active_merchant/billing/integrations/paypal/notification.rb +155 -0
- data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/paypal_payments_advanced.rb +20 -0
- data/lib/active_merchant/billing/integrations/paypal_payments_advanced/helper.rb +15 -0
- data/lib/active_merchant/billing/integrations/pxpay.rb +31 -0
- data/lib/active_merchant/billing/integrations/pxpay/helper.rb +110 -0
- data/lib/active_merchant/billing/integrations/pxpay/notification.rb +157 -0
- data/lib/active_merchant/billing/integrations/pxpay/return.rb +25 -0
- data/lib/active_merchant/billing/integrations/quickpay.rb +21 -0
- data/lib/active_merchant/billing/integrations/quickpay/helper.rb +71 -0
- data/lib/active_merchant/billing/integrations/quickpay/notification.rb +74 -0
- data/lib/active_merchant/billing/integrations/return.rb +42 -0
- data/lib/active_merchant/billing/integrations/robokassa.rb +49 -0
- data/lib/active_merchant/billing/integrations/robokassa/common.rb +19 -0
- data/lib/active_merchant/billing/integrations/robokassa/helper.rb +50 -0
- data/lib/active_merchant/billing/integrations/robokassa/notification.rb +55 -0
- data/lib/active_merchant/billing/integrations/robokassa/return.rb +17 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form.rb +37 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +33 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +129 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +210 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/return.rb +31 -0
- data/lib/active_merchant/billing/integrations/two_checkout.rb +44 -0
- data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +91 -0
- data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +139 -0
- data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
- data/lib/active_merchant/billing/integrations/valitor.rb +33 -0
- data/lib/active_merchant/billing/integrations/valitor/helper.rb +86 -0
- data/lib/active_merchant/billing/integrations/valitor/notification.rb +13 -0
- data/lib/active_merchant/billing/integrations/valitor/response_fields.rb +97 -0
- data/lib/active_merchant/billing/integrations/valitor/return.rb +13 -0
- data/lib/active_merchant/billing/integrations/verkkomaksut.rb +20 -0
- data/lib/active_merchant/billing/integrations/verkkomaksut/helper.rb +87 -0
- data/lib/active_merchant/billing/integrations/verkkomaksut/notification.rb +59 -0
- data/lib/active_merchant/billing/integrations/web_pay.rb +45 -0
- data/lib/active_merchant/billing/integrations/web_pay/common.rb +50 -0
- data/lib/active_merchant/billing/integrations/web_pay/helper.rb +68 -0
- data/lib/active_merchant/billing/integrations/web_pay/notification.rb +51 -0
- data/lib/active_merchant/billing/integrations/world_pay.rb +27 -0
- data/lib/active_merchant/billing/integrations/world_pay/helper.rb +100 -0
- data/lib/active_merchant/billing/integrations/world_pay/notification.rb +160 -0
- data/lib/active_merchant/billing/response.rb +64 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/support/gateway_support.rb +65 -0
- data/lib/support/outbound_hosts.rb +25 -0
- data/lib/support/ssl_verify.rb +93 -0
- metadata +482 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class NmiGateway < AuthorizeNetGateway
|
4
|
+
self.test_url = 'https://secure.networkmerchants.com/gateway/transact.dll'
|
5
|
+
self.live_url = 'https://secure.networkmerchants.com/gateway/transact.dll'
|
6
|
+
self.homepage_url = 'http://nmi.com/'
|
7
|
+
self.display_name = 'NMI'
|
8
|
+
self.supported_countries = ['US']
|
9
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
@@ -0,0 +1,427 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'rexml/document'
|
3
|
+
|
4
|
+
module ActiveMerchant #:nodoc:
|
5
|
+
module Billing #:nodoc:
|
6
|
+
# = Ogone DirectLink Gateway
|
7
|
+
#
|
8
|
+
# DirectLink is the API version of the Ogone Payment Platform. It allows server to server
|
9
|
+
# communication between Ogone systems and your e-commerce website.
|
10
|
+
#
|
11
|
+
# This implementation follows the specification provided in the DirectLink integration
|
12
|
+
# guide version 4.3.0 (25 April 2012), available here:
|
13
|
+
# https://secure.ogone.com/ncol/Ogone_DirectLink_EN.pdf
|
14
|
+
#
|
15
|
+
# It also features aliases, which allow to store/unstore credit cards, as specified in
|
16
|
+
# the Alias Manager Option guide version 3.2.1 (25 April 2012) available here:
|
17
|
+
# https://secure.ogone.com/ncol/Ogone_Alias_EN.pdf
|
18
|
+
#
|
19
|
+
# It also implements the 3-D Secure feature, as specified in the DirectLink with
|
20
|
+
# 3-D Secure guide version 3.0 (25 April 2012) available here:
|
21
|
+
# https://secure.ogone.com/ncol/Ogone_DirectLink-3-D_EN.pdf
|
22
|
+
#
|
23
|
+
# It was last tested on Release 4.92 of Ogone DirectLink + AliasManager + Direct Link 3D
|
24
|
+
# (25 April 2012).
|
25
|
+
#
|
26
|
+
# For any questions or comments, please contact one of the following:
|
27
|
+
# - Joel Cogen (joel.cogen@belighted.com)
|
28
|
+
# - Nicolas Jacobeus (nicolas.jacobeus@belighted.com),
|
29
|
+
# - Sébastien Grosjean (public@zencocoon.com),
|
30
|
+
# - Rémy Coutable (remy@jilion.com).
|
31
|
+
#
|
32
|
+
# == Usage
|
33
|
+
#
|
34
|
+
# gateway = ActiveMerchant::Billing::OgoneGateway.new(
|
35
|
+
# :login => "my_ogone_psp_id",
|
36
|
+
# :user => "my_ogone_user_id",
|
37
|
+
# :password => "my_ogone_pswd",
|
38
|
+
# :signature => "my_ogone_sha_signature", # Only if you configured your Ogone environment so.
|
39
|
+
# :signature_encryptor => "sha512", # Can be "none" (default), "sha1", "sha256" or "sha512".
|
40
|
+
# # Must be the same as the one configured in your Ogone account.
|
41
|
+
# )
|
42
|
+
#
|
43
|
+
# # set up credit card object as in main ActiveMerchant example
|
44
|
+
# creditcard = ActiveMerchant::Billing::CreditCard.new(
|
45
|
+
# :type => 'visa',
|
46
|
+
# :number => '4242424242424242',
|
47
|
+
# :month => 8,
|
48
|
+
# :year => 2009,
|
49
|
+
# :first_name => 'Bob',
|
50
|
+
# :last_name => 'Bobsen'
|
51
|
+
# )
|
52
|
+
#
|
53
|
+
# # run request
|
54
|
+
# response = gateway.purchase(1000, creditcard, :order_id => "1") # charge 10 EUR
|
55
|
+
#
|
56
|
+
# If you don't provide an :order_id, the gateway will generate a random one for you.
|
57
|
+
#
|
58
|
+
# puts response.success? # Check whether the transaction was successful
|
59
|
+
# puts response.message # Retrieve the message returned by Ogone
|
60
|
+
# puts response.authorization # Retrieve the unique transaction ID returned by Ogone
|
61
|
+
# puts response.order_id # Retrieve the order ID
|
62
|
+
#
|
63
|
+
# == Alias feature
|
64
|
+
#
|
65
|
+
# To use the alias feature, simply add :billing_id in the options hash:
|
66
|
+
#
|
67
|
+
# # Associate the alias to that credit card
|
68
|
+
# gateway.purchase(1000, creditcard, :order_id => "1", :billing_id => "myawesomecustomer")
|
69
|
+
#
|
70
|
+
# # You can use the alias instead of the credit card for subsequent orders
|
71
|
+
# gateway.purchase(2000, "myawesomecustomer", :order_id => "2")
|
72
|
+
#
|
73
|
+
# # You can also create an alias without making a purchase using store
|
74
|
+
# gateway.store(creditcard, :billing_id => "myawesomecustomer")
|
75
|
+
#
|
76
|
+
# # When using store, you can also let Ogone generate the alias for you
|
77
|
+
# response = gateway.store(creditcard)
|
78
|
+
# puts response.billing_id # Retrieve the generated alias
|
79
|
+
#
|
80
|
+
# == 3-D Secure feature
|
81
|
+
#
|
82
|
+
# To use the 3-D Secure feature, simply add :d3d => true in the options hash:
|
83
|
+
# gateway.purchase(2000, "myawesomecustomer", :order_id => "2", :d3d => true)
|
84
|
+
#
|
85
|
+
# Specific 3-D Secure request options are (please refer to the documentation for more infos about these options):
|
86
|
+
# :win_3ds => :main_window (default), :pop_up or :pop_ix.
|
87
|
+
# :http_accept => "*/*" (default), or any other HTTP_ACCEPT header value.
|
88
|
+
# :http_user_agent => The cardholder's User-Agent string
|
89
|
+
# :accept_url => URL of the web page to show the customer when the payment is authorized.
|
90
|
+
# (or waiting to be authorized).
|
91
|
+
# :decline_url => URL of the web page to show the customer when the acquirer rejects the authorization
|
92
|
+
# more than the maximum permitted number of authorization attempts (10 by default, but can
|
93
|
+
# be changed in the "Global transaction parameters" tab, "Payment retry" section of the
|
94
|
+
# Technical Information page).
|
95
|
+
# :exception_url => URL of the web page to show the customer when the payment result is uncertain.
|
96
|
+
# :paramplus => Field to submit the miscellaneous parameters and their values that you wish to be
|
97
|
+
# returned in the post sale request or final redirection.
|
98
|
+
# :complus => Field to submit a value you wish to be returned in the post sale request or output.
|
99
|
+
# :language => Customer's language, for example: "en_EN"
|
100
|
+
#
|
101
|
+
class OgoneGateway < Gateway
|
102
|
+
|
103
|
+
URLS = {
|
104
|
+
:order => 'https://secure.ogone.com/ncol/%s/orderdirect.asp',
|
105
|
+
:maintenance => 'https://secure.ogone.com/ncol/%s/maintenancedirect.asp'
|
106
|
+
}
|
107
|
+
|
108
|
+
CVV_MAPPING = { 'OK' => 'M',
|
109
|
+
'KO' => 'N',
|
110
|
+
'NO' => 'P' }
|
111
|
+
|
112
|
+
AVS_MAPPING = { 'OK' => 'M',
|
113
|
+
'KO' => 'N',
|
114
|
+
'NO' => 'R' }
|
115
|
+
|
116
|
+
SUCCESS_MESSAGE = "The transaction was successful"
|
117
|
+
|
118
|
+
THREE_D_SECURE_DISPLAY_WAYS = { :main_window => 'MAINW', # display the identification page in the main window
|
119
|
+
# (default value).
|
120
|
+
:pop_up => 'POPUP', # display the identification page in a pop-up window
|
121
|
+
# and return to the main window at the end.
|
122
|
+
:pop_ix => 'POPIX' } # display the identification page in a pop-up window
|
123
|
+
# and remain in the pop-up window.
|
124
|
+
|
125
|
+
OGONE_NO_SIGNATURE_DEPRECATION_MESSAGE = "Signature usage will be the default for a future release of ActiveMerchant. You should either begin using it, or update your configuration to explicitly disable it (signature_encryptor: none)"
|
126
|
+
OGONE_STORE_OPTION_DEPRECATION_MESSAGE = "The 'store' option has been renamed to 'billing_id', and its usage is deprecated."
|
127
|
+
|
128
|
+
self.test_url = URLS[:order] % "test"
|
129
|
+
self.live_url = URLS[:order] % "prod"
|
130
|
+
|
131
|
+
self.supported_countries = ['BE', 'DE', 'FR', 'NL', 'AT', 'CH']
|
132
|
+
# also supports Airplus and UATP
|
133
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :discover, :jcb, :maestro]
|
134
|
+
self.homepage_url = 'http://www.ogone.com/'
|
135
|
+
self.display_name = 'Ogone'
|
136
|
+
self.default_currency = 'EUR'
|
137
|
+
self.money_format = :cents
|
138
|
+
|
139
|
+
def initialize(options = {})
|
140
|
+
requires!(options, :login, :user, :password)
|
141
|
+
@options = options
|
142
|
+
super
|
143
|
+
end
|
144
|
+
|
145
|
+
# Verify and reserve the specified amount on the account, without actually doing the transaction.
|
146
|
+
def authorize(money, payment_source, options = {})
|
147
|
+
post = {}
|
148
|
+
add_invoice(post, options)
|
149
|
+
add_payment_source(post, payment_source, options)
|
150
|
+
add_address(post, payment_source, options)
|
151
|
+
add_customer_data(post, options)
|
152
|
+
add_money(post, money, options)
|
153
|
+
commit('RES', post)
|
154
|
+
end
|
155
|
+
|
156
|
+
# Verify and transfer the specified amount.
|
157
|
+
def purchase(money, payment_source, options = {})
|
158
|
+
post = {}
|
159
|
+
add_invoice(post, options)
|
160
|
+
add_payment_source(post, payment_source, options)
|
161
|
+
add_address(post, payment_source, options)
|
162
|
+
add_customer_data(post, options)
|
163
|
+
add_money(post, money, options)
|
164
|
+
commit('SAL', post)
|
165
|
+
end
|
166
|
+
|
167
|
+
# Complete a previously authorized transaction.
|
168
|
+
def capture(money, authorization, options = {})
|
169
|
+
post = {}
|
170
|
+
add_authorization(post, reference_from(authorization))
|
171
|
+
add_invoice(post, options)
|
172
|
+
add_customer_data(post, options)
|
173
|
+
add_money(post, money, options)
|
174
|
+
commit('SAL', post)
|
175
|
+
end
|
176
|
+
|
177
|
+
# Cancels a previously authorized transaction.
|
178
|
+
def void(identification, options = {})
|
179
|
+
post = {}
|
180
|
+
add_authorization(post, reference_from(identification))
|
181
|
+
commit('DES', post)
|
182
|
+
end
|
183
|
+
|
184
|
+
# Credit the specified account by a specific amount.
|
185
|
+
def credit(money, identification_or_credit_card, options = {})
|
186
|
+
if reference_transaction?(identification_or_credit_card)
|
187
|
+
deprecated CREDIT_DEPRECATION_MESSAGE
|
188
|
+
# Referenced credit: refund of a settled transaction
|
189
|
+
refund(money, identification_or_credit_card, options)
|
190
|
+
else # must be a credit card or card reference
|
191
|
+
perform_non_referenced_credit(money, identification_or_credit_card, options)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
# Refund of a settled transaction
|
196
|
+
def refund(money, reference, options = {})
|
197
|
+
perform_reference_credit(money, reference, options)
|
198
|
+
end
|
199
|
+
|
200
|
+
# Store a credit card by creating an Ogone Alias
|
201
|
+
def store(payment_source, options = {})
|
202
|
+
options.merge!(:alias_operation => 'BYOGONE') unless options.has_key?(:billing_id) || options.has_key?(:store)
|
203
|
+
response = authorize(1, payment_source, options)
|
204
|
+
void(response.authorization) if response.success?
|
205
|
+
response
|
206
|
+
end
|
207
|
+
|
208
|
+
def test?
|
209
|
+
@options[:test] || super
|
210
|
+
end
|
211
|
+
|
212
|
+
private
|
213
|
+
|
214
|
+
def reference_from(authorization)
|
215
|
+
authorization.split(";").first
|
216
|
+
end
|
217
|
+
|
218
|
+
def reference_transaction?(identifier)
|
219
|
+
return false unless identifier.is_a?(String)
|
220
|
+
_, action = identifier.split(";")
|
221
|
+
!action.nil?
|
222
|
+
end
|
223
|
+
|
224
|
+
def perform_reference_credit(money, payment_target, options = {})
|
225
|
+
post = {}
|
226
|
+
add_authorization(post, reference_from(payment_target))
|
227
|
+
add_money(post, money, options)
|
228
|
+
commit('RFD', post)
|
229
|
+
end
|
230
|
+
|
231
|
+
def perform_non_referenced_credit(money, payment_target, options = {})
|
232
|
+
# Non-referenced credit: acts like a reverse purchase
|
233
|
+
post = {}
|
234
|
+
add_invoice(post, options)
|
235
|
+
add_payment_source(post, payment_target, options)
|
236
|
+
add_address(post, payment_target, options)
|
237
|
+
add_customer_data(post, options)
|
238
|
+
add_money(post, money, options)
|
239
|
+
commit('RFD', post)
|
240
|
+
end
|
241
|
+
|
242
|
+
def add_payment_source(post, payment_source, options)
|
243
|
+
if payment_source.is_a?(String)
|
244
|
+
add_alias(post, payment_source, options[:alias_operation])
|
245
|
+
add_eci(post, options[:eci] || '9')
|
246
|
+
else
|
247
|
+
if options.has_key?(:store)
|
248
|
+
deprecated OGONE_STORE_OPTION_DEPRECATION_MESSAGE
|
249
|
+
options[:billing_id] ||= options[:store]
|
250
|
+
end
|
251
|
+
add_alias(post, options[:billing_id], options[:alias_operation])
|
252
|
+
add_eci(post, options[:eci] || '7')
|
253
|
+
add_d3d(post, options) if options[:d3d]
|
254
|
+
add_creditcard(post, payment_source)
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
def add_d3d(post, options)
|
259
|
+
add_pair post, 'FLAG3D', 'Y'
|
260
|
+
win_3ds = THREE_D_SECURE_DISPLAY_WAYS.key?(options[:win_3ds]) ?
|
261
|
+
THREE_D_SECURE_DISPLAY_WAYS[options[:win_3ds]] :
|
262
|
+
THREE_D_SECURE_DISPLAY_WAYS[:main_window]
|
263
|
+
add_pair post, 'WIN3DS', win_3ds
|
264
|
+
|
265
|
+
add_pair post, 'HTTP_ACCEPT', options[:http_accept] || "*/*"
|
266
|
+
add_pair post, 'HTTP_USER_AGENT', options[:http_user_agent] if options[:http_user_agent]
|
267
|
+
add_pair post, 'ACCEPTURL', options[:accept_url] if options[:accept_url]
|
268
|
+
add_pair post, 'DECLINEURL', options[:decline_url] if options[:decline_url]
|
269
|
+
add_pair post, 'EXCEPTIONURL', options[:exception_url] if options[:exception_url]
|
270
|
+
add_pair post, 'PARAMPLUS', options[:paramplus] if options[:paramplus]
|
271
|
+
add_pair post, 'COMPLUS', options[:complus] if options[:complus]
|
272
|
+
add_pair post, 'LANGUAGE', options[:language] if options[:language]
|
273
|
+
end
|
274
|
+
|
275
|
+
def add_eci(post, eci)
|
276
|
+
add_pair post, 'ECI', eci.to_s
|
277
|
+
end
|
278
|
+
|
279
|
+
def add_alias(post, _alias, alias_operation = nil)
|
280
|
+
add_pair post, 'ALIAS', _alias
|
281
|
+
add_pair post, 'ALIASOPERATION', alias_operation unless alias_operation.nil?
|
282
|
+
end
|
283
|
+
|
284
|
+
def add_authorization(post, authorization)
|
285
|
+
add_pair post, 'PAYID', authorization
|
286
|
+
end
|
287
|
+
|
288
|
+
def add_money(post, money, options)
|
289
|
+
add_pair post, 'currency', options[:currency] || @options[:currency] || currency(money)
|
290
|
+
add_pair post, 'amount', amount(money)
|
291
|
+
end
|
292
|
+
|
293
|
+
def add_customer_data(post, options)
|
294
|
+
add_pair post, 'EMAIL', options[:email]
|
295
|
+
add_pair post, 'REMOTE_ADDR', options[:ip]
|
296
|
+
end
|
297
|
+
|
298
|
+
def add_address(post, creditcard, options)
|
299
|
+
return unless options[:billing_address]
|
300
|
+
add_pair post, 'Owneraddress', options[:billing_address][:address1]
|
301
|
+
add_pair post, 'OwnerZip', options[:billing_address][:zip]
|
302
|
+
add_pair post, 'ownertown', options[:billing_address][:city]
|
303
|
+
add_pair post, 'ownercty', options[:billing_address][:country]
|
304
|
+
add_pair post, 'ownertelno', options[:billing_address][:phone]
|
305
|
+
end
|
306
|
+
|
307
|
+
def add_invoice(post, options)
|
308
|
+
add_pair post, 'orderID', options[:order_id] || generate_unique_id[0...30]
|
309
|
+
add_pair post, 'COM', options[:description]
|
310
|
+
end
|
311
|
+
|
312
|
+
def add_creditcard(post, creditcard)
|
313
|
+
add_pair post, 'CN', creditcard.name
|
314
|
+
add_pair post, 'CARDNO', creditcard.number
|
315
|
+
add_pair post, 'ED', "%02d%02s" % [creditcard.month, creditcard.year.to_s[-2..-1]]
|
316
|
+
add_pair post, 'CVC', creditcard.verification_value
|
317
|
+
end
|
318
|
+
|
319
|
+
def parse(body)
|
320
|
+
xml_root = REXML::Document.new(body).root
|
321
|
+
response = convert_attributes_to_hash(xml_root.attributes)
|
322
|
+
|
323
|
+
# Add HTML_ANSWER element (3-D Secure specific to the response's params)
|
324
|
+
# Note: HTML_ANSWER is not an attribute so we add it "by hand" to the response
|
325
|
+
if html_answer = REXML::XPath.first(xml_root, "//HTML_ANSWER")
|
326
|
+
response["HTML_ANSWER"] = html_answer.text
|
327
|
+
end
|
328
|
+
|
329
|
+
response
|
330
|
+
end
|
331
|
+
|
332
|
+
def commit(action, parameters)
|
333
|
+
add_pair parameters, 'PSPID', @options[:login]
|
334
|
+
add_pair parameters, 'USERID', @options[:user]
|
335
|
+
add_pair parameters, 'PSWD', @options[:password]
|
336
|
+
|
337
|
+
url = URLS[parameters['PAYID'] ? :maintenance : :order] % [test? ? "test" : "prod"]
|
338
|
+
response = parse(ssl_post(url, post_data(action, parameters)))
|
339
|
+
|
340
|
+
options = {
|
341
|
+
:authorization => [response["PAYID"], action].join(";"),
|
342
|
+
:test => test?,
|
343
|
+
:avs_result => { :code => AVS_MAPPING[response["AAVCheck"]] },
|
344
|
+
:cvv_result => CVV_MAPPING[response["CVCCheck"]]
|
345
|
+
}
|
346
|
+
OgoneResponse.new(successful?(response), message_from(response), response, options)
|
347
|
+
end
|
348
|
+
|
349
|
+
def successful?(response)
|
350
|
+
response["NCERROR"] == "0"
|
351
|
+
end
|
352
|
+
|
353
|
+
def message_from(response)
|
354
|
+
if successful?(response)
|
355
|
+
SUCCESS_MESSAGE
|
356
|
+
else
|
357
|
+
format_error_message(response["NCERRORPLUS"])
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
def format_error_message(message)
|
362
|
+
raw_message = message.to_s.strip
|
363
|
+
case raw_message
|
364
|
+
when /\|/
|
365
|
+
raw_message.split("|").join(", ").capitalize
|
366
|
+
when /\//
|
367
|
+
raw_message.split("/").first.to_s.capitalize
|
368
|
+
else
|
369
|
+
raw_message.to_s.capitalize
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
def post_data(action, parameters = {})
|
374
|
+
add_pair parameters, 'Operation', action
|
375
|
+
add_signature(parameters)
|
376
|
+
parameters.to_query
|
377
|
+
end
|
378
|
+
|
379
|
+
def add_signature(parameters)
|
380
|
+
if @options[:signature].blank?
|
381
|
+
deprecated(OGONE_NO_SIGNATURE_DEPRECATION_MESSAGE) unless(@options[:signature_encryptor] == "none")
|
382
|
+
return
|
383
|
+
end
|
384
|
+
|
385
|
+
sha_encryptor = case @options[:signature_encryptor]
|
386
|
+
when 'sha256'
|
387
|
+
Digest::SHA256
|
388
|
+
when 'sha512'
|
389
|
+
Digest::SHA512
|
390
|
+
else
|
391
|
+
Digest::SHA1
|
392
|
+
end
|
393
|
+
|
394
|
+
string_to_digest = if @options[:signature_encryptor]
|
395
|
+
parameters.sort { |a, b| a[0].upcase <=> b[0].upcase }.map { |k, v| "#{k.upcase}=#{v}" }.join(@options[:signature])
|
396
|
+
else
|
397
|
+
%w[orderID amount currency CARDNO PSPID Operation ALIAS].map { |key| parameters[key] }.join
|
398
|
+
end
|
399
|
+
string_to_digest << @options[:signature]
|
400
|
+
|
401
|
+
add_pair parameters, 'SHASign', sha_encryptor.hexdigest(string_to_digest).upcase
|
402
|
+
end
|
403
|
+
|
404
|
+
def add_pair(post, key, value)
|
405
|
+
post[key] = value if !value.blank?
|
406
|
+
end
|
407
|
+
|
408
|
+
def convert_attributes_to_hash(rexml_attributes)
|
409
|
+
response_hash = {}
|
410
|
+
rexml_attributes.each do |key, value|
|
411
|
+
response_hash[key] = value
|
412
|
+
end
|
413
|
+
response_hash
|
414
|
+
end
|
415
|
+
end
|
416
|
+
|
417
|
+
class OgoneResponse < Response
|
418
|
+
def order_id
|
419
|
+
@params['orderID']
|
420
|
+
end
|
421
|
+
|
422
|
+
def billing_id
|
423
|
+
@params['ALIAS']
|
424
|
+
end
|
425
|
+
end
|
426
|
+
end
|
427
|
+
end
|
@@ -0,0 +1,277 @@
|
|
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']
|
9
|
+
|
10
|
+
# The card types supported by the payment gateway
|
11
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :solo] # :switch?
|
12
|
+
|
13
|
+
# The homepage URL of the gateway
|
14
|
+
self.homepage_url = 'http://www.optimalpayments.com/'
|
15
|
+
|
16
|
+
# The name of the gateway
|
17
|
+
self.display_name = 'Optimal Payments'
|
18
|
+
|
19
|
+
def initialize(options = {})
|
20
|
+
#requires!(options, :login, :password)
|
21
|
+
@options = options
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
def authorize(money, card_or_auth, options = {})
|
26
|
+
parse_card_or_auth(card_or_auth, options)
|
27
|
+
commit("cc#{@stored_data}Authorize", money, options)
|
28
|
+
end
|
29
|
+
alias stored_authorize authorize # back-compat
|
30
|
+
|
31
|
+
def purchase(money, card_or_auth, options = {})
|
32
|
+
parse_card_or_auth(card_or_auth, options)
|
33
|
+
commit("cc#{@stored_data}Purchase", money, options)
|
34
|
+
end
|
35
|
+
alias stored_purchase purchase # back-compat
|
36
|
+
|
37
|
+
def refund(money, authorization, options = {})
|
38
|
+
options[:confirmationNumber] = authorization
|
39
|
+
commit('ccCredit', money, options)
|
40
|
+
end
|
41
|
+
|
42
|
+
def void(authorization, options = {})
|
43
|
+
options[:confirmationNumber] = authorization
|
44
|
+
commit('ccAuthorizeReversal', nil, options)
|
45
|
+
end
|
46
|
+
|
47
|
+
def capture(money, authorization, options = {})
|
48
|
+
options[:confirmationNumber] = authorization
|
49
|
+
commit('ccSettlement', money, options)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test?
|
53
|
+
super || @options[:test]
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def parse_card_or_auth(card_or_auth, options)
|
59
|
+
if card_or_auth.respond_to?(:number)
|
60
|
+
@credit_card = card_or_auth
|
61
|
+
@stored_data = ""
|
62
|
+
else
|
63
|
+
options[:confirmationNumber] = card_or_auth
|
64
|
+
@stored_data = "StoredData"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def parse(body)
|
69
|
+
REXML::Document.new(body || '')
|
70
|
+
end
|
71
|
+
|
72
|
+
def commit(action, money, post)
|
73
|
+
post[:order_id] ||= 'order_id'
|
74
|
+
|
75
|
+
xml = case action
|
76
|
+
when 'ccAuthorize', 'ccPurchase', 'ccVerification'
|
77
|
+
cc_auth_request(money, post)
|
78
|
+
when 'ccCredit', 'ccSettlement'
|
79
|
+
cc_post_auth_request(money, post)
|
80
|
+
when 'ccStoredDataAuthorize', 'ccStoredDataPurchase'
|
81
|
+
cc_stored_data_request(money, post)
|
82
|
+
when 'ccAuthorizeReversal'
|
83
|
+
cc_auth_reversal_request(post)
|
84
|
+
#when 'ccCancelSettle', 'ccCancelCredit', 'ccCancelPayment'
|
85
|
+
# cc_cancel_request(money, post)
|
86
|
+
#when 'ccPayment'
|
87
|
+
# cc_payment_request(money, post)
|
88
|
+
#when 'ccAuthenticate'
|
89
|
+
# cc_authenticate_request(money, post)
|
90
|
+
else
|
91
|
+
raise 'Unknown Action'
|
92
|
+
end
|
93
|
+
txnRequest = URI.encode(xml)
|
94
|
+
response = parse(ssl_post(test? ? self.test_url : self.live_url, "txnMode=#{action}&txnRequest=#{txnRequest}"))
|
95
|
+
|
96
|
+
Response.new(successful?(response), message_from(response), hash_from_xml(response),
|
97
|
+
:test => test?,
|
98
|
+
:authorization => authorization_from(response)
|
99
|
+
)
|
100
|
+
end
|
101
|
+
|
102
|
+
def successful?(response)
|
103
|
+
REXML::XPath.first(response, '//decision').text == 'ACCEPTED' rescue false
|
104
|
+
end
|
105
|
+
|
106
|
+
def message_from(response)
|
107
|
+
REXML::XPath.each(response, '//detail') do |detail|
|
108
|
+
if detail.is_a?(REXML::Element) && detail.elements['tag'].text == 'InternalResponseDescription'
|
109
|
+
return detail.elements['value'].text
|
110
|
+
end
|
111
|
+
end
|
112
|
+
nil
|
113
|
+
end
|
114
|
+
|
115
|
+
def authorization_from(response)
|
116
|
+
REXML::XPath.first(response, '//confirmationNumber').text rescue nil
|
117
|
+
end
|
118
|
+
|
119
|
+
def hash_from_xml(response)
|
120
|
+
hsh = {}
|
121
|
+
%w(confirmationNumber authCode
|
122
|
+
decision code description
|
123
|
+
actionCode avsResponse cvdResponse
|
124
|
+
txnTime duplicateFound
|
125
|
+
).each do |tag|
|
126
|
+
node = REXML::XPath.first(response, "//#{tag}")
|
127
|
+
hsh[tag] = node.text if node
|
128
|
+
end
|
129
|
+
REXML::XPath.each(response, '//detail') do |detail|
|
130
|
+
next unless detail.is_a?(REXML::Element)
|
131
|
+
tag = detail.elements['tag'].text
|
132
|
+
value = detail.elements['value'].text
|
133
|
+
hsh[tag] = value
|
134
|
+
end
|
135
|
+
hsh
|
136
|
+
end
|
137
|
+
|
138
|
+
def xml_document(root_tag)
|
139
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
140
|
+
xml.tag!(root_tag, schema) do
|
141
|
+
yield xml
|
142
|
+
end
|
143
|
+
xml.target!
|
144
|
+
end
|
145
|
+
|
146
|
+
def cc_auth_request(money, opts)
|
147
|
+
xml_document('ccAuthRequestV1') do |xml|
|
148
|
+
build_merchant_account(xml, @options)
|
149
|
+
xml.merchantRefNum opts[:order_id]
|
150
|
+
xml.amount(money/100.0)
|
151
|
+
build_card(xml, opts)
|
152
|
+
build_billing_details(xml, opts)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def cc_auth_reversal_request(opts)
|
157
|
+
xml_document('ccAuthReversalRequestV1') do |xml|
|
158
|
+
build_merchant_account(xml, @options)
|
159
|
+
xml.confirmationNumber opts[:confirmationNumber]
|
160
|
+
xml.merchantRefNum opts[:order_id]
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def cc_post_auth_request(money, opts)
|
165
|
+
xml_document('ccPostAuthRequestV1') do |xml|
|
166
|
+
build_merchant_account(xml, @options)
|
167
|
+
xml.confirmationNumber opts[:confirmationNumber]
|
168
|
+
xml.merchantRefNum opts[:order_id]
|
169
|
+
xml.amount(money/100.0)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def cc_stored_data_request(money, opts)
|
174
|
+
xml_document('ccStoredDataRequestV1') do |xml|
|
175
|
+
build_merchant_account(xml, @options)
|
176
|
+
xml.merchantRefNum opts[:order_id]
|
177
|
+
xml.confirmationNumber opts[:confirmationNumber]
|
178
|
+
xml.amount(money/100.0)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
# untested
|
183
|
+
#
|
184
|
+
# def cc_cancel_request(opts)
|
185
|
+
# xml_document('ccCancelRequestV1') do |xml|
|
186
|
+
# build_merchant_account(xml, @options)
|
187
|
+
# xml.confirmationNumber opts[:confirmationNumber]
|
188
|
+
# end
|
189
|
+
# end
|
190
|
+
#
|
191
|
+
# def cc_payment_request(money, opts)
|
192
|
+
# xml_document('ccPaymentRequestV1') do |xml|
|
193
|
+
# build_merchant_account(xml, @options)
|
194
|
+
# xml.merchantRefNum opts[:order_id]
|
195
|
+
# xml.amount(money/100.0)
|
196
|
+
# build_card(xml, opts)
|
197
|
+
# build_billing_details(xml, opts)
|
198
|
+
# end
|
199
|
+
# end
|
200
|
+
#
|
201
|
+
# def cc_authenticate_request(opts)
|
202
|
+
# xml_document('ccAuthenticateRequestV1') do |xml|
|
203
|
+
# build_merchant_account(xml, @options)
|
204
|
+
# xml.confirmationNumber opts[:confirmationNumber]
|
205
|
+
# xml.paymentResponse 'myPaymentResponse'
|
206
|
+
# end
|
207
|
+
# end
|
208
|
+
|
209
|
+
def schema
|
210
|
+
{ 'xmlns' => 'http://www.optimalpayments.com/creditcard/xmlschema/v1',
|
211
|
+
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
|
212
|
+
'xsi:schemaLocation' => 'http://www.optimalpayments.com/creditcard/xmlschema/v1'
|
213
|
+
}
|
214
|
+
end
|
215
|
+
|
216
|
+
def build_merchant_account(xml, opts)
|
217
|
+
xml.tag! 'merchantAccount' do
|
218
|
+
xml.tag! 'accountNum' , opts[:account]
|
219
|
+
xml.tag! 'storeID' , opts[:login]
|
220
|
+
xml.tag! 'storePwd' , opts[:password]
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
def build_card(xml, opts)
|
225
|
+
xml.tag! 'card' do
|
226
|
+
xml.tag! 'cardNum' , @credit_card.number
|
227
|
+
xml.tag! 'cardExpiry' do
|
228
|
+
xml.tag! 'month' , @credit_card.month
|
229
|
+
xml.tag! 'year' , @credit_card.year
|
230
|
+
end
|
231
|
+
if brand = card_type(@credit_card.brand)
|
232
|
+
xml.tag! 'cardType' , brand
|
233
|
+
end
|
234
|
+
if @credit_card.verification_value
|
235
|
+
xml.tag! 'cvdIndicator' , '1' # Value Provided
|
236
|
+
xml.tag! 'cvd' , @credit_card.verification_value
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
def build_billing_details(xml, opts)
|
242
|
+
xml.tag! 'billingDetails' do
|
243
|
+
addr = opts[:billing_address]
|
244
|
+
xml.tag! 'cardPayMethod', 'WEB'
|
245
|
+
if addr[:name]
|
246
|
+
xml.tag! 'firstName', CGI.escape(addr[:name].split(' ').first) # TODO: parse properly
|
247
|
+
xml.tag! 'lastName' , CGI.escape(addr[:name].split(' ').last )
|
248
|
+
end
|
249
|
+
xml.tag! 'street' , CGI.escape(addr[:address1]) if addr[:address1].present?
|
250
|
+
xml.tag! 'street2', CGI.escape(addr[:address2]) if addr[:address2].present?
|
251
|
+
xml.tag! 'city' , CGI.escape(addr[:city] ) if addr[:city].present?
|
252
|
+
if addr[:state].present?
|
253
|
+
state_tag = %w(US CA).include?(addr[:country]) ? 'state' : 'region'
|
254
|
+
xml.tag! state_tag, CGI.escape(addr[:state])
|
255
|
+
end
|
256
|
+
xml.tag! 'country', CGI.escape(addr[:country] ) if addr[:country].present?
|
257
|
+
xml.tag! 'zip' , CGI.escape(addr[:zip] ) # this one's actually required
|
258
|
+
xml.tag! 'phone' , CGI.escape(addr[:phone] ) if addr[:phone].present?
|
259
|
+
#xml.tag! 'email' , ''
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
def card_type(key)
|
264
|
+
{ 'visa' => 'VI',
|
265
|
+
'master' => 'MC',
|
266
|
+
'american_express'=> 'AM',
|
267
|
+
'discover' => 'DI',
|
268
|
+
'diners_club' => 'DC',
|
269
|
+
#'switch' => '',
|
270
|
+
'solo' => 'SO'
|
271
|
+
}[key]
|
272
|
+
end
|
273
|
+
|
274
|
+
end
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|