start_activemerchant 1.50.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (218) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +1769 -0
  3. data/CONTRIBUTORS +540 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +226 -0
  6. data/lib/active_merchant.rb +67 -0
  7. data/lib/active_merchant/billing.rb +15 -0
  8. data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
  9. data/lib/active_merchant/billing/avs_result.rb +98 -0
  10. data/lib/active_merchant/billing/base.rb +72 -0
  11. data/lib/active_merchant/billing/check.rb +76 -0
  12. data/lib/active_merchant/billing/compatibility.rb +120 -0
  13. data/lib/active_merchant/billing/credit_card.rb +404 -0
  14. data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
  15. data/lib/active_merchant/billing/credit_card_methods.rb +195 -0
  16. data/lib/active_merchant/billing/cvv_result.rb +38 -0
  17. data/lib/active_merchant/billing/gateway.rb +291 -0
  18. data/lib/active_merchant/billing/gateways.rb +14 -0
  19. data/lib/active_merchant/billing/gateways/allied_wallet.rb +203 -0
  20. data/lib/active_merchant/billing/gateways/app55.rb +176 -0
  21. data/lib/active_merchant/billing/gateways/authorize_net.rb +510 -0
  22. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
  23. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +976 -0
  24. data/lib/active_merchant/billing/gateways/axcessms.rb +181 -0
  25. data/lib/active_merchant/billing/gateways/balanced.rb +256 -0
  26. data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
  27. data/lib/active_merchant/billing/gateways/banwire.rb +105 -0
  28. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +314 -0
  29. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
  30. data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
  31. data/lib/active_merchant/billing/gateways/beanstream.rb +192 -0
  32. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +389 -0
  33. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +58 -0
  34. data/lib/active_merchant/billing/gateways/blue_pay.rb +506 -0
  35. data/lib/active_merchant/billing/gateways/bogus.rb +140 -0
  36. data/lib/active_merchant/billing/gateways/borgun.rb +211 -0
  37. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  38. data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
  39. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -0
  40. data/lib/active_merchant/billing/gateways/braintree_blue.rb +574 -0
  41. data/lib/active_merchant/billing/gateways/braintree_orange.rb +20 -0
  42. data/lib/active_merchant/billing/gateways/bridge_pay.rb +189 -0
  43. data/lib/active_merchant/billing/gateways/card_save.rb +23 -0
  44. data/lib/active_merchant/billing/gateways/card_stream.rb +238 -0
  45. data/lib/active_merchant/billing/gateways/cashnet.rb +202 -0
  46. data/lib/active_merchant/billing/gateways/cc5.rb +201 -0
  47. data/lib/active_merchant/billing/gateways/cecabank.rb +229 -0
  48. data/lib/active_merchant/billing/gateways/cenpos.rb +262 -0
  49. data/lib/active_merchant/billing/gateways/certo_direct.rb +278 -0
  50. data/lib/active_merchant/billing/gateways/checkout.rb +216 -0
  51. data/lib/active_merchant/billing/gateways/checkout_v2.rb +200 -0
  52. data/lib/active_merchant/billing/gateways/commercegate.rb +143 -0
  53. data/lib/active_merchant/billing/gateways/conekta.rb +210 -0
  54. data/lib/active_merchant/billing/gateways/cyber_source.rb +720 -0
  55. data/lib/active_merchant/billing/gateways/data_cash.rb +600 -0
  56. data/lib/active_merchant/billing/gateways/dibs.rb +206 -0
  57. data/lib/active_merchant/billing/gateways/efsnet.rb +219 -0
  58. data/lib/active_merchant/billing/gateways/elavon.rb +348 -0
  59. data/lib/active_merchant/billing/gateways/epay.rb +274 -0
  60. data/lib/active_merchant/billing/gateways/evo_ca.rb +308 -0
  61. data/lib/active_merchant/billing/gateways/eway.rb +214 -0
  62. data/lib/active_merchant/billing/gateways/eway_managed.rb +291 -0
  63. data/lib/active_merchant/billing/gateways/eway_rapid.rb +522 -0
  64. data/lib/active_merchant/billing/gateways/exact.rb +227 -0
  65. data/lib/active_merchant/billing/gateways/ezic.rb +206 -0
  66. data/lib/active_merchant/billing/gateways/fat_zebra.rb +213 -0
  67. data/lib/active_merchant/billing/gateways/federated_canada.rb +160 -0
  68. data/lib/active_merchant/billing/gateways/finansbank.rb +23 -0
  69. data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
  70. data/lib/active_merchant/billing/gateways/first_pay.rb +160 -0
  71. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +413 -0
  72. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  73. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  74. data/lib/active_merchant/billing/gateways/garanti.rb +261 -0
  75. data/lib/active_merchant/billing/gateways/global_transport.rb +179 -0
  76. data/lib/active_merchant/billing/gateways/hdfc.rb +207 -0
  77. data/lib/active_merchant/billing/gateways/hps.rb +287 -0
  78. data/lib/active_merchant/billing/gateways/iats_payments.rb +277 -0
  79. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +246 -0
  80. data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +13 -0
  81. data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +29 -0
  82. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +66 -0
  83. data/lib/active_merchant/billing/gateways/inspire.rb +219 -0
  84. data/lib/active_merchant/billing/gateways/instapay.rb +163 -0
  85. data/lib/active_merchant/billing/gateways/ipp.rb +175 -0
  86. data/lib/active_merchant/billing/gateways/iridium.rb +457 -0
  87. data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
  88. data/lib/active_merchant/billing/gateways/jetpay.rb +275 -0
  89. data/lib/active_merchant/billing/gateways/linkpoint.rb +438 -0
  90. data/lib/active_merchant/billing/gateways/litle.rb +345 -0
  91. data/lib/active_merchant/billing/gateways/maxipago.rb +197 -0
  92. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +170 -0
  93. data/lib/active_merchant/billing/gateways/merchant_one.rb +114 -0
  94. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  95. data/lib/active_merchant/billing/gateways/merchant_ware.rb +319 -0
  96. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +268 -0
  97. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +195 -0
  98. data/lib/active_merchant/billing/gateways/mercury.rb +326 -0
  99. data/lib/active_merchant/billing/gateways/metrics_global.rb +303 -0
  100. data/lib/active_merchant/billing/gateways/migs.rb +280 -0
  101. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
  102. data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
  103. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +219 -0
  104. data/lib/active_merchant/billing/gateways/monei.rb +307 -0
  105. data/lib/active_merchant/billing/gateways/moneris.rb +309 -0
  106. data/lib/active_merchant/billing/gateways/moneris_us.rb +298 -0
  107. data/lib/active_merchant/billing/gateways/money_movers.rb +152 -0
  108. data/lib/active_merchant/billing/gateways/nab_transact.rb +290 -0
  109. data/lib/active_merchant/billing/gateways/net_registry.rb +198 -0
  110. data/lib/active_merchant/billing/gateways/netaxept.rb +181 -0
  111. data/lib/active_merchant/billing/gateways/netbilling.rb +224 -0
  112. data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
  113. data/lib/active_merchant/billing/gateways/network_merchants.rb +242 -0
  114. data/lib/active_merchant/billing/gateways/nmi.rb +256 -0
  115. data/lib/active_merchant/billing/gateways/ogone.rb +435 -0
  116. data/lib/active_merchant/billing/gateways/omise.rb +319 -0
  117. data/lib/active_merchant/billing/gateways/openpay.rb +194 -0
  118. data/lib/active_merchant/billing/gateways/optimal_payment.rb +314 -0
  119. data/lib/active_merchant/billing/gateways/orbital.rb +834 -0
  120. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +47 -0
  121. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +207 -0
  122. data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
  123. data/lib/active_merchant/billing/gateways/pay_conex.rb +246 -0
  124. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +277 -0
  125. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  126. data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
  127. data/lib/active_merchant/billing/gateways/pay_secure.rb +112 -0
  128. data/lib/active_merchant/billing/gateways/paybox_direct.rb +188 -0
  129. data/lib/active_merchant/billing/gateways/payex.rb +412 -0
  130. data/lib/active_merchant/billing/gateways/payflow.rb +308 -0
  131. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +220 -0
  132. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
  133. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  134. data/lib/active_merchant/billing/gateways/payflow_express.rb +224 -0
  135. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +15 -0
  136. data/lib/active_merchant/billing/gateways/payflow_uk.rb +21 -0
  137. data/lib/active_merchant/billing/gateways/payment_express.rb +353 -0
  138. data/lib/active_merchant/billing/gateways/paymill.rb +282 -0
  139. data/lib/active_merchant/billing/gateways/paypal.rb +129 -0
  140. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +679 -0
  141. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +65 -0
  142. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
  143. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  144. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
  145. data/lib/active_merchant/billing/gateways/paypal_express.rb +264 -0
  146. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
  147. data/lib/active_merchant/billing/gateways/payscout.rb +162 -0
  148. data/lib/active_merchant/billing/gateways/paystation.rb +199 -0
  149. data/lib/active_merchant/billing/gateways/payu_in.rb +247 -0
  150. data/lib/active_merchant/billing/gateways/payway.rb +207 -0
  151. data/lib/active_merchant/billing/gateways/pin.rb +207 -0
  152. data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
  153. data/lib/active_merchant/billing/gateways/psigate.rb +216 -0
  154. data/lib/active_merchant/billing/gateways/psl_card.rb +303 -0
  155. data/lib/active_merchant/billing/gateways/qbms.rb +292 -0
  156. data/lib/active_merchant/billing/gateways/quantum.rb +276 -0
  157. data/lib/active_merchant/billing/gateways/quickbooks.rb +280 -0
  158. data/lib/active_merchant/billing/gateways/quickpay.rb +26 -0
  159. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +188 -0
  160. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +240 -0
  161. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +227 -0
  162. data/lib/active_merchant/billing/gateways/qvalent.rb +179 -0
  163. data/lib/active_merchant/billing/gateways/realex.rb +298 -0
  164. data/lib/active_merchant/billing/gateways/redsys.rb +406 -0
  165. data/lib/active_merchant/billing/gateways/s5.rb +226 -0
  166. data/lib/active_merchant/billing/gateways/sage.rb +173 -0
  167. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +89 -0
  168. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +115 -0
  169. data/lib/active_merchant/billing/gateways/sage/sage_vault.rb +149 -0
  170. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
  171. data/lib/active_merchant/billing/gateways/sage_pay.rb +399 -0
  172. data/lib/active_merchant/billing/gateways/sallie_mae.rb +143 -0
  173. data/lib/active_merchant/billing/gateways/secure_net.rb +263 -0
  174. data/lib/active_merchant/billing/gateways/secure_pay.rb +201 -0
  175. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +281 -0
  176. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +105 -0
  177. data/lib/active_merchant/billing/gateways/skip_jack.rb +451 -0
  178. data/lib/active_merchant/billing/gateways/smart_ps.rb +283 -0
  179. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
  180. data/lib/active_merchant/billing/gateways/spreedly_core.rb +247 -0
  181. data/lib/active_merchant/billing/gateways/stripe.rb +489 -0
  182. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +157 -0
  183. data/lib/active_merchant/billing/gateways/tns.rb +227 -0
  184. data/lib/active_merchant/billing/gateways/trans_first.rb +126 -0
  185. data/lib/active_merchant/billing/gateways/transax.rb +23 -0
  186. data/lib/active_merchant/billing/gateways/transnational.rb +10 -0
  187. data/lib/active_merchant/billing/gateways/trust_commerce.rb +416 -0
  188. data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
  189. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1516 -0
  190. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +259 -0
  191. data/lib/active_merchant/billing/gateways/vanco.rb +280 -0
  192. data/lib/active_merchant/billing/gateways/verifi.rb +225 -0
  193. data/lib/active_merchant/billing/gateways/viaklix.rb +183 -0
  194. data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
  195. data/lib/active_merchant/billing/gateways/wepay.rb +205 -0
  196. data/lib/active_merchant/billing/gateways/wirecard.rb +420 -0
  197. data/lib/active_merchant/billing/gateways/worldpay.rb +331 -0
  198. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +204 -0
  199. data/lib/active_merchant/billing/gateways/worldpay_us.rb +181 -0
  200. data/lib/active_merchant/billing/model.rb +30 -0
  201. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +24 -0
  202. data/lib/active_merchant/billing/payment_token.rb +21 -0
  203. data/lib/active_merchant/billing/rails.rb +3 -0
  204. data/lib/active_merchant/billing/response.rb +92 -0
  205. data/lib/active_merchant/connection.rb +172 -0
  206. data/lib/active_merchant/country.rb +332 -0
  207. data/lib/active_merchant/empty.rb +20 -0
  208. data/lib/active_merchant/errors.rb +35 -0
  209. data/lib/active_merchant/network_connection_retries.rb +79 -0
  210. data/lib/active_merchant/post_data.rb +24 -0
  211. data/lib/active_merchant/posts_data.rb +84 -0
  212. data/lib/active_merchant/version.rb +3 -0
  213. data/lib/activemerchant.rb +1 -0
  214. data/lib/certs/cacert.pem +3866 -0
  215. data/lib/support/gateway_support.rb +71 -0
  216. data/lib/support/outbound_hosts.rb +28 -0
  217. data/lib/support/ssl_verify.rb +93 -0
  218. metadata +387 -0
@@ -0,0 +1,13 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIICQDCCAakCBELvbPYwDQYJKoZIhvcNAQEEBQAwZzELMAkGA1UEBhMCREUxDzANBgNVBAgTBkhl
3
+ c3NlbjESMBAGA1UEBxMJRnJhbmtmdXJ0MQ4wDAYDVQQKEwVpREVBTDEOMAwGA1UECxMFaURFQUwx
4
+ EzARBgNVBAMTCmlERUFMIFJhYm8wHhcNMDUwODAyMTI1NDE0WhcNMTUwNzMxMTI1NDE0WjBnMQsw
5
+ CQYDVQQGEwJERTEPMA0GA1UECBMGSGVzc2VuMRIwEAYDVQQHEwlGcmFua2Z1cnQxDjAMBgNVBAoT
6
+ BWlERUFMMQ4wDAYDVQQLEwVpREVBTDETMBEGA1UEAxMKaURFQUwgUmFibzCBnzANBgkqhkiG9w0B
7
+ AQEFAAOBjQAwgYkCgYEA486iIKVhr8RNjxH+PZ3yTWx/8k2fqDFm8XU8I1Z5esRmPFnXmlgA8cG7
8
+ e9AaBPaLoP7Dc8dRQoUO66KMakzGI/WAVdHIJiiKrz8xOcioIgrzPSqec7aqse3J28UraEHkGESJ
9
+ 7dAW7Pw/shrmpmkzKsunLt6AkXss4W3JUndZUN0CAwEAATANBgkqhkiG9w0BAQQFAAOBgQCGy/FK
10
+ Lotp2ZOTtuLMgvDy74eicq/Znv4bLfpglzAPHycRHcHsXuer/lNHyvpKf2gdYe+IFalUW3OJZWIM
11
+ jpm4UniJ16RPdgwWVRJEdPr/P7JXMIqD2IEOgujuuTQ7x0VgCf9XrsPsP9ZR5DIPcDDhbrpSE0yF
12
+ Do77nwG61xMaGA==
13
+ -----END CERTIFICATE-----
@@ -0,0 +1,29 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class IdealResponse < Response
4
+
5
+ def issuer_list
6
+ list = @params.values[0]['Directory']['Issuer']
7
+ case list
8
+ when Hash
9
+ return [list]
10
+ when Array
11
+ return list
12
+ end
13
+ end
14
+
15
+ def service_url
16
+ @params.values[0]['Issuer']['issuerAuthenticationURL']
17
+ end
18
+
19
+ def transaction
20
+ @params.values[0]['Transaction']
21
+ end
22
+
23
+ def error
24
+ @params.values[0]['Error']
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,66 @@
1
+ require 'active_merchant/billing/gateways/ideal/ideal_base'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ # First, make sure you have everything setup correctly and all of your dependencies in place with:
6
+ #
7
+ # require 'rubygems'
8
+ # require 'active_merchant'
9
+ #
10
+ # ActiveMerchant expects the amounts to be given as an Integer in cents. In this case, 10 EUR becomes 1000.
11
+ #
12
+ # Create certificates for authentication:
13
+ #
14
+ # The PEM file expected should contain both the certificate and the generated PEM file.
15
+ # Some sample shell commands to generate the certificates:
16
+ #
17
+ # openssl genrsa -aes128 -out priv.pem -passout pass:[YOUR PASSWORD] 1024
18
+ # openssl req -x509 -new -key priv.pem -passin pass:[YOUR PASSWORD] -days 3000 -out cert.cer
19
+ # cat cert.cer priv.pem > ideal.pem
20
+ #
21
+ # Following the steps above, upload cert.cer to the ideal web interface and pass the path of ideal.pem to the :pem option.
22
+ #
23
+ # Configure the gateway using your iDEAL bank account info and security settings:
24
+ #
25
+ # Create gateway:
26
+ # gateway = ActiveMerchant::Billing::IdealRabobankGateway.new(
27
+ # :login => '123456789', # 9 digit merchant number
28
+ # :pem => File.read(Rails.root + 'config/ideal.pem'),
29
+ # :password => 'password' # password for the PEM key
30
+ # )
31
+ #
32
+ # Get list of issuers to fill selection list on your payment form:
33
+ # response = gateway.issuers
34
+ # list = response.issuer_list
35
+ #
36
+ # Request transaction:
37
+ #
38
+ # options = {
39
+ # :issuer_id => '0001',
40
+ # :expiration_period => 'PT10M',
41
+ # :return_url => 'http://www.return.url',
42
+ # :order_id => '1234567890123456',
43
+ # :currency => 'EUR',
44
+ # :description => 'Een omschrijving',
45
+ # :entrance_code => '1234'
46
+ # }
47
+ #
48
+ # response = gateway.setup_purchase(amount, options)
49
+ # transaction_id = response.transaction['transactionID']
50
+ # redirect_url = response.service_url
51
+ #
52
+ # Mandatory status request will confirm transaction:
53
+ # response = gateway.capture(transaction_id)
54
+ #
55
+ # Implementation contains some simplifications
56
+ # - does not support multiple subID per merchant
57
+ # - language is fixed to 'nl'
58
+ class IdealRabobankGateway < IdealBaseGateway
59
+ class_attribute :test_url, :live_url
60
+
61
+ self.test_url = 'https://idealtest.rabobank.nl/ideal/iDeal'
62
+ self.live_url = 'https://ideal.rabobank.nl/ideal/iDeal'
63
+ self.server_pem = File.read(File.dirname(__FILE__) + '/ideal/ideal_rabobank.pem')
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,219 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'check.rb')
2
+ module ActiveMerchant #:nodoc:
3
+ module Billing #:nodoc:
4
+ class InspireGateway < Gateway
5
+ self.live_url = self.test_url = 'https://secure.inspiregateway.net/api/transact.php'
6
+
7
+ self.supported_countries = ['US']
8
+ self.supported_cardtypes = [:visa, :master, :american_express]
9
+ self.homepage_url = 'http://www.inspiregateway.com'
10
+ self.display_name = 'Inspire Commerce'
11
+
12
+ # Creates a new InspireGateway
13
+ #
14
+ # The gateway requires that a valid login and password be passed
15
+ # in the +options+ hash.
16
+ #
17
+ # ==== Options
18
+ #
19
+ # * <tt>:login</tt> -- The Inspire Username.
20
+ # * <tt>:password</tt> -- The Inspire Passowrd.
21
+ # See the Inspire Integration Guide for details. (default: +false+)
22
+ def initialize(options = {})
23
+ requires!(options, :login, :password)
24
+ super
25
+ end
26
+
27
+ # Pass :store => true in the options to store the
28
+ # payment info at Inspire Gateway and get a generated
29
+ # customer_vault_id in the response.
30
+ # Pass :store => some_number_or_string to specify the
31
+ # customer_vault_id InspireGateway should use (make sure it's
32
+ # unique).
33
+ def authorize(money, creditcard, options = {})
34
+ post = {}
35
+ add_invoice(post, options)
36
+ add_payment_source(post, creditcard,options)
37
+ add_address(post, creditcard, options)
38
+ add_customer_data(post, options)
39
+
40
+ commit('auth', money, post)
41
+ end
42
+
43
+ def purchase(money, payment_source, options = {})
44
+ post = {}
45
+ add_invoice(post, options)
46
+ add_payment_source(post, payment_source, options)
47
+ add_address(post, payment_source, options)
48
+ add_customer_data(post, options)
49
+
50
+ commit('sale', money, post)
51
+ end
52
+
53
+ def capture(money, authorization, options = {})
54
+ post ={}
55
+ post[:transactionid] = authorization
56
+ commit('capture', money, post)
57
+ end
58
+
59
+ def void(authorization, options = {})
60
+ post ={}
61
+ post[:transactionid] = authorization
62
+ commit('void', nil, post)
63
+ end
64
+
65
+ def refund(money, authorization, options = {})
66
+ post = {}
67
+ post[:transactionid] = authorization
68
+ commit('refund', money, post)
69
+ end
70
+
71
+ # Update the values (such as CC expiration) stored at
72
+ # InspireGateway. The CC number must be supplied in the
73
+ # CreditCard object.
74
+ def update(vault_id, creditcard, options = {})
75
+ post = {}
76
+ post[:customer_vault] = "update_customer"
77
+ add_customer_vault_id(post, vault_id)
78
+ add_creditcard(post, creditcard, options)
79
+ add_address(post, creditcard, options)
80
+ add_customer_data(post, options)
81
+
82
+ commit(nil, nil, post)
83
+ end
84
+
85
+ def delete(vault_id)
86
+ post = {}
87
+ post[:customer_vault] = "delete_customer"
88
+ add_customer_vault_id(post, vault_id)
89
+ commit(nil, nil, post)
90
+ end
91
+
92
+ # To match the other stored-value gateways, like TrustCommerce,
93
+ # store and unstore need to be defined
94
+ def store(creditcard, options = {})
95
+ billing_id = options.delete(:billing_id).to_s || true
96
+ authorize(100, creditcard, options.merge(:store => billing_id))
97
+ end
98
+
99
+ alias_method :unstore, :delete
100
+
101
+ private
102
+ def add_customer_data(post, options)
103
+ if options.has_key? :email
104
+ post[:email] = options[:email]
105
+ end
106
+
107
+ if options.has_key? :ip
108
+ post[:ipaddress] = options[:ip]
109
+ end
110
+ end
111
+
112
+ def add_address(post, creditcard, options)
113
+ if address = options[:billing_address] || options[:address]
114
+ post[:address1] = address[:address1].to_s
115
+ post[:address2] = address[:address2].to_s unless address[:address2].blank?
116
+ post[:company] = address[:company].to_s
117
+ post[:phone] = address[:phone].to_s
118
+ post[:zip] = address[:zip].to_s
119
+ post[:city] = address[:city].to_s
120
+ post[:country] = address[:country].to_s
121
+ post[:state] = address[:state].blank? ? 'n/a' : address[:state]
122
+ end
123
+ end
124
+
125
+ def add_invoice(post, options)
126
+ post[:orderid] = options[:order_id].to_s.gsub(/[^\w.]/, '')
127
+ post[:orderdescription] = options[:description]
128
+ end
129
+
130
+ def add_payment_source(params, source, options={})
131
+ case determine_funding_source(source)
132
+ when :vault then add_customer_vault_id(params, source)
133
+ when :credit_card then add_creditcard(params, source, options)
134
+ when :check then add_check(params, source)
135
+ end
136
+ end
137
+
138
+ def add_customer_vault_id(params,vault_id)
139
+ params[:customer_vault_id] = vault_id
140
+ end
141
+
142
+ def add_creditcard(post, creditcard,options)
143
+ if options[:store]
144
+ post[:customer_vault] = "add_customer"
145
+ post[:customer_vault_id] = options[:store] unless options[:store] == true
146
+ end
147
+ post[:ccnumber] = creditcard.number
148
+ post[:cvv] = creditcard.verification_value if creditcard.verification_value?
149
+ post[:ccexp] = expdate(creditcard)
150
+ post[:firstname] = creditcard.first_name
151
+ post[:lastname] = creditcard.last_name
152
+ end
153
+
154
+ def add_check(post, check)
155
+ post[:payment] = 'check' # Set transaction to ACH
156
+ post[:checkname] = check.name # The name on the customer's Checking Account
157
+ post[:checkaba] = check.routing_number # The customer's bank routing number
158
+ post[:checkaccount] = check.account_number # The customer's account number
159
+ post[:account_holder_type] = check.account_holder_type # The customer's type of ACH account
160
+ post[:account_type] = check.account_type # The customer's type of ACH account
161
+ end
162
+
163
+ def parse(body)
164
+ results = {}
165
+ body.split(/&/).each do |pair|
166
+ key,val = pair.split(%r{=})
167
+ results[key] = val
168
+ end
169
+
170
+ results
171
+ end
172
+
173
+ def commit(action, money, parameters)
174
+ parameters[:amount] = amount(money) if money
175
+
176
+ response = parse( ssl_post(self.live_url, post_data(action,parameters)) )
177
+
178
+ Response.new(response["response"] == "1", message_from(response), response,
179
+ :authorization => response["transactionid"],
180
+ :test => test?,
181
+ :cvv_result => response["cvvresponse"],
182
+ :avs_result => { :code => response["avsresponse"] }
183
+ )
184
+
185
+ end
186
+
187
+ def message_from(response)
188
+ case response["responsetext"]
189
+ when "SUCCESS","Approved"
190
+ "This transaction has been approved"
191
+ when "DECLINE"
192
+ "This transaction has been declined"
193
+ else
194
+ response["responsetext"]
195
+ end
196
+ end
197
+
198
+ def post_data(action, parameters = {})
199
+ post = {}
200
+ post[:username] = @options[:login]
201
+ post[:password] = @options[:password]
202
+ post[:type] = action if action
203
+
204
+ request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join("&")
205
+ request
206
+ end
207
+
208
+ def determine_funding_source(source)
209
+ case
210
+ when source.is_a?(String) then :vault
211
+ when CreditCard.card_companies.keys.include?(card_brand(source)) then :credit_card
212
+ when card_brand(source) == 'check' then :check
213
+ else raise ArgumentError, "Unsupported funding source provided"
214
+ end
215
+ end
216
+ end
217
+ end
218
+ end
219
+
@@ -0,0 +1,163 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class InstapayGateway < Gateway
4
+ self.live_url = 'https://trans.instapaygateway.com/cgi-bin/process.cgi'
5
+
6
+ # The countries the gateway supports merchants from as 2 digit ISO country codes
7
+ self.supported_countries = ['US']
8
+ self.money_format = :dollars
9
+ self.default_currency = 'USD'
10
+ # The card types supported by the payment gateway
11
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover]
12
+
13
+ # The homepage URL of the gateway
14
+ self.homepage_url = 'http://www.instapayllc.com'
15
+
16
+ # The name of the gateway
17
+ self.display_name = 'InstaPay'
18
+
19
+ SUCCESS = "Accepted"
20
+ SUCCESS_MESSAGE = "The transaction has been approved"
21
+
22
+ def initialize(options = {})
23
+ requires!(options, :login)
24
+ super
25
+ end
26
+
27
+ def authorize(money, creditcard, options = {})
28
+ post = {}
29
+ post[:authonly] = 1
30
+ add_amount(post, money)
31
+ add_invoice(post, options)
32
+ add_creditcard(post, creditcard)
33
+ add_address(post, options)
34
+ add_customer_data(post, options)
35
+
36
+ commit('ns_quicksale_cc', post)
37
+ end
38
+
39
+ def purchase(money, creditcard, options = {})
40
+ post = {}
41
+ add_amount(post, money)
42
+ add_invoice(post, options)
43
+ add_creditcard(post, creditcard)
44
+ add_address(post, options)
45
+ add_customer_data(post, options)
46
+
47
+ commit('ns_quicksale_cc', post)
48
+ end
49
+
50
+ def capture(money, authorization, options = {})
51
+ post = {}
52
+ add_amount(post, money)
53
+ add_reference(post, authorization)
54
+ commit('ns_quicksale_cc', post)
55
+ end
56
+
57
+ private
58
+
59
+ def add_amount(post, money)
60
+ post[:amount] = amount(money)
61
+ end
62
+
63
+ def add_reference(post, reference)
64
+ post[:postonly] = reference
65
+ end
66
+
67
+ def add_customer_data(post, options)
68
+ post[:ci_email] = options[:email]
69
+ post["ci_IP Address"] = options[:ip]
70
+ end
71
+
72
+ def add_address(post, options)
73
+ if address = options[:billing_address] || options[:address]
74
+ post[:ci_billaddr1] = address[:address1]
75
+ post[:ci_billaddr2] = address[:address2]
76
+ post[:ci_billcity] = address[:city]
77
+ post[:ci_billstate] = address[:state]
78
+ post[:ci_billzip] = address[:zip]
79
+ post[:ci_billcountry] = address[:country]
80
+ post[:ci_phone] = address[:phone]
81
+ end
82
+
83
+ if address = options[:shipping_address]
84
+ post[:ci_shipaddr1] = address[:address1]
85
+ post[:ci_shipaddr2] = address[:address2]
86
+ post[:ci_shipcity] = address[:city]
87
+ post[:ci_shipstate] = address[:state]
88
+ post[:ci_shipzip] = address[:zip]
89
+ post[:ci_shipcountry] = address[:country]
90
+ end
91
+ end
92
+
93
+ def add_invoice(post, options)
94
+ post[:merchantordernumber] = options[:order_id]
95
+ post[:ci_memo] = options[:description]
96
+ post[:pocustomerrefid] = options[:invoice]
97
+ end
98
+
99
+ def add_creditcard(post, creditcard)
100
+ post[:ccnum] = creditcard.number
101
+ post[:expmon] = format(creditcard.month, :two_digits)
102
+ post[:cvv2] = creditcard.verification_value if creditcard.verification_value?
103
+ post[:expyear] = creditcard.year
104
+ post[:ccname] = creditcard.name
105
+ end
106
+
107
+ def parse(body)
108
+ results = {}
109
+ fields = body.split("\r\n")
110
+
111
+ response = fields[1].split('=')
112
+ response_data = response[1].split(':')
113
+
114
+ if response[0] == SUCCESS
115
+ results[:success] = true
116
+ results[:message] = SUCCESS_MESSAGE
117
+ results[:transaction_type] = response_data[0]
118
+ results[:authorization_code] = response_data[1]
119
+ results[:reference_number] = response_data[2]
120
+ results[:batch_number] = response_data[3]
121
+ results[:transaction_id] = response_data[4]
122
+ results[:avs_result] = response_data[5]
123
+ results[:authorize_net] = response_data[6]
124
+ results[:cvv_result] = response_data[7]
125
+ else
126
+ results[:success] = false
127
+ results[:result] = response_data[0]
128
+ results[:response_code] = response_data[1]
129
+ results[:message] = response_data[2]
130
+ end
131
+
132
+ fields[1..-1].each do |pair|
133
+ key, value = pair.split('=')
134
+ results[key] = value
135
+ end
136
+ results
137
+ end
138
+
139
+ def commit(action, parameters)
140
+ data = ssl_post self.live_url, post_data(action, parameters)
141
+ response = parse(data)
142
+
143
+ Response.new(response[:success] , response[:message], response,
144
+ :authorization => response[:transaction_id],
145
+ :avs_result => { :code => response[:avs_result] },
146
+ :cvv_result => response[:cvv_result]
147
+ )
148
+ end
149
+
150
+ def post_data(action, parameters = {})
151
+ post = {}
152
+ post[:acctid] = @options[:login]
153
+ if(@options[:password])
154
+ post[:merchantpin] = @options[:password]
155
+ end
156
+ post[:action] = action
157
+ request = post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
158
+ request
159
+ end
160
+ end
161
+ end
162
+ end
163
+