activemerchant-nsp 1.27.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (252) hide show
  1. data/CHANGELOG +952 -0
  2. data/CONTRIBUTORS +347 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.md +204 -0
  5. data/gem-public_cert.pem +20 -0
  6. data/lib/active_merchant.rb +63 -0
  7. data/lib/active_merchant/billing.rb +9 -0
  8. data/lib/active_merchant/billing/avs_result.rb +98 -0
  9. data/lib/active_merchant/billing/base.rb +56 -0
  10. data/lib/active_merchant/billing/check.rb +68 -0
  11. data/lib/active_merchant/billing/credit_card.rb +274 -0
  12. data/lib/active_merchant/billing/credit_card_formatting.rb +21 -0
  13. data/lib/active_merchant/billing/credit_card_methods.rb +143 -0
  14. data/lib/active_merchant/billing/cvv_result.rb +38 -0
  15. data/lib/active_merchant/billing/expiry_date.rb +34 -0
  16. data/lib/active_merchant/billing/gateway.rb +176 -0
  17. data/lib/active_merchant/billing/gateways.rb +18 -0
  18. data/lib/active_merchant/billing/gateways/authorize_net.rb +695 -0
  19. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +943 -0
  20. data/lib/active_merchant/billing/gateways/balanced.rb +462 -0
  21. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +308 -0
  22. data/lib/active_merchant/billing/gateways/beanstream.rb +167 -0
  23. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +389 -0
  24. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
  25. data/lib/active_merchant/billing/gateways/blue_pay.rb +492 -0
  26. data/lib/active_merchant/billing/gateways/bogus.rb +142 -0
  27. data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
  28. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -0
  29. data/lib/active_merchant/billing/gateways/braintree_blue.rb +389 -0
  30. data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
  31. data/lib/active_merchant/billing/gateways/card_save.rb +23 -0
  32. data/lib/active_merchant/billing/gateways/card_stream.rb +230 -0
  33. data/lib/active_merchant/billing/gateways/certo_direct.rb +278 -0
  34. data/lib/active_merchant/billing/gateways/cyber_source.rb +576 -0
  35. data/lib/active_merchant/billing/gateways/data_cash.rb +597 -0
  36. data/lib/active_merchant/billing/gateways/efsnet.rb +235 -0
  37. data/lib/active_merchant/billing/gateways/elavon.rb +137 -0
  38. data/lib/active_merchant/billing/gateways/epay.rb +276 -0
  39. data/lib/active_merchant/billing/gateways/eway.rb +287 -0
  40. data/lib/active_merchant/billing/gateways/eway_managed.rb +265 -0
  41. data/lib/active_merchant/billing/gateways/exact.rb +227 -0
  42. data/lib/active_merchant/billing/gateways/fat_zebra.rb +152 -0
  43. data/lib/active_merchant/billing/gateways/federated_canada.rb +168 -0
  44. data/lib/active_merchant/billing/gateways/first_pay.rb +177 -0
  45. data/lib/active_merchant/billing/gateways/garanti.rb +262 -0
  46. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +252 -0
  47. data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +13 -0
  48. data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +29 -0
  49. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +55 -0
  50. data/lib/active_merchant/billing/gateways/inspire.rb +221 -0
  51. data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
  52. data/lib/active_merchant/billing/gateways/iridium.rb +257 -0
  53. data/lib/active_merchant/billing/gateways/itransact.rb +450 -0
  54. data/lib/active_merchant/billing/gateways/jetpay.rb +276 -0
  55. data/lib/active_merchant/billing/gateways/linkpoint.rb +451 -0
  56. data/lib/active_merchant/billing/gateways/litle.rb +290 -0
  57. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +157 -0
  58. data/lib/active_merchant/billing/gateways/merchant_ware.rb +289 -0
  59. data/lib/active_merchant/billing/gateways/metrics_global.rb +323 -0
  60. data/lib/active_merchant/billing/gateways/migs.rb +263 -0
  61. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
  62. data/lib/active_merchant/billing/gateways/modern_payments.rb +38 -0
  63. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +220 -0
  64. data/lib/active_merchant/billing/gateways/moneris.rb +250 -0
  65. data/lib/active_merchant/billing/gateways/moneris_us.rb +211 -0
  66. data/lib/active_merchant/billing/gateways/nab_transact.rb +257 -0
  67. data/lib/active_merchant/billing/gateways/net_registry.rb +189 -0
  68. data/lib/active_merchant/billing/gateways/netaxept.rb +239 -0
  69. data/lib/active_merchant/billing/gateways/netbilling.rb +196 -0
  70. data/lib/active_merchant/billing/gateways/nmi.rb +13 -0
  71. data/lib/active_merchant/billing/gateways/ogone.rb +427 -0
  72. data/lib/active_merchant/billing/gateways/optimal_payment.rb +277 -0
  73. data/lib/active_merchant/billing/gateways/orbital.rb +351 -0
  74. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +46 -0
  75. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +266 -0
  76. data/lib/active_merchant/billing/gateways/pay_junction.rb +397 -0
  77. data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
  78. data/lib/active_merchant/billing/gateways/paybox_direct.rb +201 -0
  79. data/lib/active_merchant/billing/gateways/payflow.rb +268 -0
  80. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +212 -0
  81. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
  82. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  83. data/lib/active_merchant/billing/gateways/payflow_express.rb +224 -0
  84. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +15 -0
  85. data/lib/active_merchant/billing/gateways/payflow_uk.rb +21 -0
  86. data/lib/active_merchant/billing/gateways/payment_express.rb +282 -0
  87. data/lib/active_merchant/billing/gateways/paypal.rb +106 -0
  88. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +653 -0
  89. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +49 -0
  90. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +245 -0
  91. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  92. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +43 -0
  93. data/lib/active_merchant/billing/gateways/paypal_express.rb +178 -0
  94. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
  95. data/lib/active_merchant/billing/gateways/paystation.rb +201 -0
  96. data/lib/active_merchant/billing/gateways/payway.rb +214 -0
  97. data/lib/active_merchant/billing/gateways/plugnpay.rb +295 -0
  98. data/lib/active_merchant/billing/gateways/psigate.rb +219 -0
  99. data/lib/active_merchant/billing/gateways/psl_card.rb +304 -0
  100. data/lib/active_merchant/billing/gateways/qbms.rb +297 -0
  101. data/lib/active_merchant/billing/gateways/quantum.rb +282 -0
  102. data/lib/active_merchant/billing/gateways/quickpay.rb +298 -0
  103. data/lib/active_merchant/billing/gateways/realex.rb +313 -0
  104. data/lib/active_merchant/billing/gateways/sage.rb +148 -0
  105. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
  106. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +115 -0
  107. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
  108. data/lib/active_merchant/billing/gateways/sage_pay.rb +322 -0
  109. data/lib/active_merchant/billing/gateways/sallie_mae.rb +144 -0
  110. data/lib/active_merchant/billing/gateways/samurai.rb +121 -0
  111. data/lib/active_merchant/billing/gateways/secure_net.rb +330 -0
  112. data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
  113. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +284 -0
  114. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
  115. data/lib/active_merchant/billing/gateways/skip_jack.rb +458 -0
  116. data/lib/active_merchant/billing/gateways/smart_ps.rb +273 -0
  117. data/lib/active_merchant/billing/gateways/stripe.rb +236 -0
  118. data/lib/active_merchant/billing/gateways/trans_first.rb +127 -0
  119. data/lib/active_merchant/billing/gateways/transax.rb +23 -0
  120. data/lib/active_merchant/billing/gateways/trust_commerce.rb +423 -0
  121. data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
  122. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1497 -0
  123. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +206 -0
  124. data/lib/active_merchant/billing/gateways/verifi.rb +233 -0
  125. data/lib/active_merchant/billing/gateways/viaklix.rb +194 -0
  126. data/lib/active_merchant/billing/gateways/vindicia.rb +359 -0
  127. data/lib/active_merchant/billing/gateways/wirecard.rb +313 -0
  128. data/lib/active_merchant/billing/gateways/worldpay.rb +271 -0
  129. data/lib/active_merchant/billing/integrations.rb +17 -0
  130. data/lib/active_merchant/billing/integrations/action_view_helper.rb +73 -0
  131. data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +38 -0
  132. data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +228 -0
  133. data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +340 -0
  134. data/lib/active_merchant/billing/integrations/bogus.rb +23 -0
  135. data/lib/active_merchant/billing/integrations/bogus/helper.rb +17 -0
  136. data/lib/active_merchant/billing/integrations/bogus/notification.rb +11 -0
  137. data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
  138. data/lib/active_merchant/billing/integrations/chronopay.rb +23 -0
  139. data/lib/active_merchant/billing/integrations/chronopay/helper.rb +120 -0
  140. data/lib/active_merchant/billing/integrations/chronopay/notification.rb +158 -0
  141. data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
  142. data/lib/active_merchant/billing/integrations/direc_pay.rb +41 -0
  143. data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +200 -0
  144. data/lib/active_merchant/billing/integrations/direc_pay/notification.rb +76 -0
  145. data/lib/active_merchant/billing/integrations/direc_pay/return.rb +32 -0
  146. data/lib/active_merchant/billing/integrations/direc_pay/status.rb +37 -0
  147. data/lib/active_merchant/billing/integrations/directebanking.rb +47 -0
  148. data/lib/active_merchant/billing/integrations/directebanking/helper.rb +90 -0
  149. data/lib/active_merchant/billing/integrations/directebanking/notification.rb +120 -0
  150. data/lib/active_merchant/billing/integrations/directebanking/return.rb +11 -0
  151. data/lib/active_merchant/billing/integrations/dotpay.rb +22 -0
  152. data/lib/active_merchant/billing/integrations/dotpay/helper.rb +77 -0
  153. data/lib/active_merchant/billing/integrations/dotpay/notification.rb +86 -0
  154. data/lib/active_merchant/billing/integrations/dotpay/return.rb +11 -0
  155. data/lib/active_merchant/billing/integrations/dwolla.rb +30 -0
  156. data/lib/active_merchant/billing/integrations/dwolla/helper.rb +31 -0
  157. data/lib/active_merchant/billing/integrations/dwolla/notification.rb +55 -0
  158. data/lib/active_merchant/billing/integrations/dwolla/return.rb +38 -0
  159. data/lib/active_merchant/billing/integrations/e_payment_plans.rb +48 -0
  160. data/lib/active_merchant/billing/integrations/e_payment_plans/helper.rb +34 -0
  161. data/lib/active_merchant/billing/integrations/e_payment_plans/notification.rb +84 -0
  162. data/lib/active_merchant/billing/integrations/easy_pay.rb +30 -0
  163. data/lib/active_merchant/billing/integrations/easy_pay/common.rb +40 -0
  164. data/lib/active_merchant/billing/integrations/easy_pay/helper.rb +40 -0
  165. data/lib/active_merchant/billing/integrations/easy_pay/notification.rb +51 -0
  166. data/lib/active_merchant/billing/integrations/epay.rb +21 -0
  167. data/lib/active_merchant/billing/integrations/epay/helper.rb +55 -0
  168. data/lib/active_merchant/billing/integrations/epay/notification.rb +110 -0
  169. data/lib/active_merchant/billing/integrations/first_data.rb +38 -0
  170. data/lib/active_merchant/billing/integrations/first_data/helper.rb +63 -0
  171. data/lib/active_merchant/billing/integrations/first_data/notification.rb +56 -0
  172. data/lib/active_merchant/billing/integrations/gestpay.rb +25 -0
  173. data/lib/active_merchant/billing/integrations/gestpay/common.rb +42 -0
  174. data/lib/active_merchant/billing/integrations/gestpay/helper.rb +70 -0
  175. data/lib/active_merchant/billing/integrations/gestpay/notification.rb +85 -0
  176. data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
  177. data/lib/active_merchant/billing/integrations/helper.rb +117 -0
  178. data/lib/active_merchant/billing/integrations/hi_trust.rb +27 -0
  179. data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
  180. data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +59 -0
  181. data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
  182. data/lib/active_merchant/billing/integrations/maksuturva.rb +86 -0
  183. data/lib/active_merchant/billing/integrations/maksuturva/helper.rb +119 -0
  184. data/lib/active_merchant/billing/integrations/maksuturva/notification.rb +48 -0
  185. data/lib/active_merchant/billing/integrations/moneybookers.rb +26 -0
  186. data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +59 -0
  187. data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +129 -0
  188. data/lib/active_merchant/billing/integrations/nelnet.rb +40 -0
  189. data/lib/active_merchant/billing/integrations/nelnet/helper.rb +34 -0
  190. data/lib/active_merchant/billing/integrations/nelnet/notification.rb +100 -0
  191. data/lib/active_merchant/billing/integrations/nochex.rb +88 -0
  192. data/lib/active_merchant/billing/integrations/nochex/helper.rb +68 -0
  193. data/lib/active_merchant/billing/integrations/nochex/notification.rb +94 -0
  194. data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
  195. data/lib/active_merchant/billing/integrations/notification.rb +62 -0
  196. data/lib/active_merchant/billing/integrations/paxum.rb +44 -0
  197. data/lib/active_merchant/billing/integrations/paxum/common.rb +24 -0
  198. data/lib/active_merchant/billing/integrations/paxum/helper.rb +42 -0
  199. data/lib/active_merchant/billing/integrations/paxum/notification.rb +33 -0
  200. data/lib/active_merchant/billing/integrations/payflow_link.rb +21 -0
  201. data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +100 -0
  202. data/lib/active_merchant/billing/integrations/payflow_link/notification.rb +78 -0
  203. data/lib/active_merchant/billing/integrations/paypal.rb +39 -0
  204. data/lib/active_merchant/billing/integrations/paypal/helper.rb +119 -0
  205. data/lib/active_merchant/billing/integrations/paypal/notification.rb +155 -0
  206. data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
  207. data/lib/active_merchant/billing/integrations/paypal_payments_advanced.rb +20 -0
  208. data/lib/active_merchant/billing/integrations/paypal_payments_advanced/helper.rb +15 -0
  209. data/lib/active_merchant/billing/integrations/pxpay.rb +31 -0
  210. data/lib/active_merchant/billing/integrations/pxpay/helper.rb +110 -0
  211. data/lib/active_merchant/billing/integrations/pxpay/notification.rb +157 -0
  212. data/lib/active_merchant/billing/integrations/pxpay/return.rb +25 -0
  213. data/lib/active_merchant/billing/integrations/quickpay.rb +21 -0
  214. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +71 -0
  215. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +74 -0
  216. data/lib/active_merchant/billing/integrations/return.rb +42 -0
  217. data/lib/active_merchant/billing/integrations/robokassa.rb +49 -0
  218. data/lib/active_merchant/billing/integrations/robokassa/common.rb +19 -0
  219. data/lib/active_merchant/billing/integrations/robokassa/helper.rb +50 -0
  220. data/lib/active_merchant/billing/integrations/robokassa/notification.rb +55 -0
  221. data/lib/active_merchant/billing/integrations/robokassa/return.rb +17 -0
  222. data/lib/active_merchant/billing/integrations/sage_pay_form.rb +37 -0
  223. data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +33 -0
  224. data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +129 -0
  225. data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +210 -0
  226. data/lib/active_merchant/billing/integrations/sage_pay_form/return.rb +31 -0
  227. data/lib/active_merchant/billing/integrations/two_checkout.rb +44 -0
  228. data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +91 -0
  229. data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +139 -0
  230. data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
  231. data/lib/active_merchant/billing/integrations/valitor.rb +33 -0
  232. data/lib/active_merchant/billing/integrations/valitor/helper.rb +86 -0
  233. data/lib/active_merchant/billing/integrations/valitor/notification.rb +13 -0
  234. data/lib/active_merchant/billing/integrations/valitor/response_fields.rb +97 -0
  235. data/lib/active_merchant/billing/integrations/valitor/return.rb +13 -0
  236. data/lib/active_merchant/billing/integrations/verkkomaksut.rb +20 -0
  237. data/lib/active_merchant/billing/integrations/verkkomaksut/helper.rb +87 -0
  238. data/lib/active_merchant/billing/integrations/verkkomaksut/notification.rb +59 -0
  239. data/lib/active_merchant/billing/integrations/web_pay.rb +45 -0
  240. data/lib/active_merchant/billing/integrations/web_pay/common.rb +50 -0
  241. data/lib/active_merchant/billing/integrations/web_pay/helper.rb +68 -0
  242. data/lib/active_merchant/billing/integrations/web_pay/notification.rb +51 -0
  243. data/lib/active_merchant/billing/integrations/world_pay.rb +27 -0
  244. data/lib/active_merchant/billing/integrations/world_pay/helper.rb +100 -0
  245. data/lib/active_merchant/billing/integrations/world_pay/notification.rb +160 -0
  246. data/lib/active_merchant/billing/response.rb +64 -0
  247. data/lib/active_merchant/version.rb +3 -0
  248. data/lib/activemerchant.rb +1 -0
  249. data/lib/support/gateway_support.rb +65 -0
  250. data/lib/support/outbound_hosts.rb +25 -0
  251. data/lib/support/ssl_verify.rb +93 -0
  252. metadata +482 -0
@@ -0,0 +1,276 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class JetpayGateway < Gateway
4
+ self.test_url = 'https://test1.jetpay.com/jetpay'
5
+ self.live_url = 'https://gateway17.jetpay.com/jetpay'
6
+
7
+ # The countries the gateway supports merchants from as 2 digit ISO country codes
8
+ self.supported_countries = ['US']
9
+
10
+ # The card types supported by the payment gateway
11
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover]
12
+
13
+ # The homepage URL of the gateway
14
+ self.homepage_url = 'http://www.jetpay.com/'
15
+
16
+ # The name of the gateway
17
+ self.display_name = 'JetPay'
18
+
19
+ # all transactions are in cents
20
+ self.money_format = :cents
21
+
22
+ ACTION_CODE_MESSAGES = {
23
+ "001" => "Refer to card issuer.",
24
+ "002" => "Refer to card issuer, special condition.",
25
+ "003" => "Pick up card.",
26
+ "200" => "Deny - Pick up card.",
27
+ "005" => "Do not honor.",
28
+ "100" => "Deny.",
29
+ "006" => "Error.",
30
+ "181" => "Format error.",
31
+ "007" => "Pickup card, special condition.",
32
+ "104" => "Deny - New card issued.",
33
+ "110" => "Invalid amount.",
34
+ "014" => "Invalid account number (no such number).",
35
+ "111" => "Invalid account.",
36
+ "015" => "No such issuer.",
37
+ "103" => "Deny - Invalid manual Entry 4DBC.",
38
+ "182" => "Please wait.",
39
+ "109" => "Invalid merchant.",
40
+ "041" => "Pick up card (lost card).",
41
+ "043" => "Pick up card (stolen card).",
42
+ "051" => "Insufficient funds.",
43
+ "052" => "No checking account.",
44
+ "105" => "Deny - Account Cancelled.",
45
+ "054" => "Expired Card.",
46
+ "101" => "Expired Card.",
47
+ "183" => "Invalid currency code.",
48
+ "057" => "Transaction not permitted to cardholder.",
49
+ "115" => "Service not permitted.",
50
+ "062" => "Restricted card.",
51
+ "189" => "Deny - Cancelled or Closed Merchant/SE.",
52
+ "188" => "Deny - Expiration date required.",
53
+ "125" => "Invalid effective date.",
54
+ "122" => "Invalid card (CID) security code.",
55
+ "400" => "Reversal accepted.",
56
+ "992" => "DECLINE/TIMEOUT.",
57
+ "107" => "Please Call Issuer.",
58
+ "025" => "Transaction Not Found.",
59
+ "981" => "AVS Error.",
60
+ "913" => "Invalid Card Type.",
61
+ "996" => "Terminal ID Not Found.",
62
+ nil => "No response returned (missing credentials?)."
63
+ }
64
+
65
+ def initialize(options = {})
66
+ requires!(options, :login)
67
+ @options = options
68
+ super
69
+ end
70
+
71
+ def purchase(money, credit_card, options = {})
72
+ commit(money, build_sale_request(money, credit_card, options))
73
+ end
74
+
75
+ def authorize(money, credit_card, options = {})
76
+ commit(money, build_authonly_request(money, credit_card, options))
77
+ end
78
+
79
+ def capture(money, reference, options = {})
80
+ commit(money, build_capture_request('CAPT', reference.split(";").first))
81
+ end
82
+
83
+ def void(reference, options = {})
84
+ transaction_id, approval, amount = reference.split(";")
85
+ commit(amount.to_i, build_void_request(amount.to_i, transaction_id, approval))
86
+ end
87
+
88
+ def credit(money, transaction_id_or_card, options = {})
89
+ if transaction_id_or_card.is_a?(String)
90
+ deprecated CREDIT_DEPRECATION_MESSAGE
91
+ refund(money, transaction_id_or_card, options)
92
+ else
93
+ commit(money, build_credit_request('CREDIT', money, nil, transaction_id_or_card))
94
+ end
95
+ end
96
+
97
+ def refund(money, reference, options = {})
98
+ transaction_id = reference.split(";").first
99
+ credit_card = options[:credit_card]
100
+ commit(money, build_credit_request('CREDIT', money, transaction_id, credit_card))
101
+ end
102
+
103
+
104
+ private
105
+
106
+ def build_xml_request(transaction_type, transaction_id = nil, &block)
107
+ xml = Builder::XmlMarkup.new
108
+ xml.tag! 'JetPay' do
109
+ # The basic values needed for any request
110
+ xml.tag! 'TerminalID', @options[:login]
111
+ xml.tag! 'TransactionType', transaction_type
112
+ xml.tag! 'TransactionID', transaction_id.nil? ? generate_unique_id.slice(0, 18) : transaction_id
113
+
114
+ if block_given?
115
+ yield xml
116
+ else
117
+ xml.target!
118
+ end
119
+ end
120
+ end
121
+
122
+ def build_sale_request(money, credit_card, options)
123
+ build_xml_request('SALE') do |xml|
124
+ add_credit_card(xml, credit_card)
125
+ add_addresses(xml, options)
126
+ add_customer_data(xml, options)
127
+ add_invoice_data(xml, options)
128
+ xml.tag! 'TotalAmount', amount(money)
129
+
130
+ xml.target!
131
+ end
132
+ end
133
+
134
+ def build_authonly_request(money, credit_card, options)
135
+ build_xml_request('AUTHONLY') do |xml|
136
+ add_credit_card(xml, credit_card)
137
+ add_addresses(xml, options)
138
+ add_customer_data(xml, options)
139
+ add_invoice_data(xml, options)
140
+ xml.tag! 'TotalAmount', amount(money)
141
+
142
+ xml.target!
143
+ end
144
+ end
145
+
146
+ def build_capture_request(transaction_type, transaction_id)
147
+ build_xml_request(transaction_type, transaction_id)
148
+ end
149
+
150
+ def build_void_request(money, transaction_id, approval)
151
+ build_xml_request('VOID', transaction_id) do |xml|
152
+ xml.tag! 'Approval', approval
153
+ xml.tag! 'TotalAmount', amount(money)
154
+
155
+ xml.target!
156
+ end
157
+ end
158
+
159
+ # `transaction_id` may be nil for unlinked credit transactions.
160
+ def build_credit_request(transaction_type, money, transaction_id, card)
161
+ build_xml_request(transaction_type, transaction_id) do |xml|
162
+ add_credit_card(xml, card) if card
163
+ xml.tag! 'TotalAmount', amount(money)
164
+
165
+ xml.target!
166
+ end
167
+ end
168
+
169
+ def commit(money, request)
170
+ response = parse(ssl_post(test? ? self.test_url : self.live_url, request))
171
+
172
+ success = success?(response)
173
+ Response.new(success,
174
+ success ? 'APPROVED' : message_from(response),
175
+ response,
176
+ :test => test?,
177
+ :authorization => authorization_from(response, money),
178
+ :avs_result => { :code => response[:avs] },
179
+ :cvv_result => response[:cvv2]
180
+ )
181
+ end
182
+
183
+ def parse(body)
184
+ return {} if body.blank?
185
+
186
+ xml = REXML::Document.new(body)
187
+
188
+ response = {}
189
+ xml.root.elements.to_a.each do |node|
190
+ parse_element(response, node)
191
+ end
192
+ response
193
+ end
194
+
195
+ def parse_element(response, node)
196
+ if node.has_elements?
197
+ node.elements.each{|element| parse_element(response, element) }
198
+ else
199
+ response[node.name.underscore.to_sym] = node.text
200
+ end
201
+ end
202
+
203
+ def format_exp(value)
204
+ format(value, :two_digits)
205
+ end
206
+
207
+ def success?(response)
208
+ response[:action_code] == "000"
209
+ end
210
+
211
+ def message_from(response)
212
+ ACTION_CODE_MESSAGES[response[:action_code]]
213
+ end
214
+
215
+ def authorization_from(response, money)
216
+ original_amount = amount(money) if money
217
+ [ response[:transaction_id], response[:approval], original_amount ].join(";")
218
+ end
219
+
220
+ def add_credit_card(xml, credit_card)
221
+ xml.tag! 'CardNum', credit_card.number
222
+ xml.tag! 'CardExpMonth', format_exp(credit_card.month)
223
+ xml.tag! 'CardExpYear', format_exp(credit_card.year)
224
+
225
+ if credit_card.first_name || credit_card.last_name
226
+ xml.tag! 'CardName', [credit_card.first_name,credit_card.last_name].compact.join(' ')
227
+ end
228
+
229
+ unless credit_card.verification_value.nil? || (credit_card.verification_value.length == 0)
230
+ xml.tag! 'CVV2', credit_card.verification_value
231
+ end
232
+ end
233
+
234
+ def add_addresses(xml, options)
235
+ if billing_address = options[:billing_address] || options[:address]
236
+ xml.tag! 'BillingAddress', [billing_address[:address1], billing_address[:address2]].compact.join(" ")
237
+ xml.tag! 'BillingCity', billing_address[:city]
238
+ xml.tag! 'BillingStateProv', billing_address[:state]
239
+ xml.tag! 'BillingPostalCode', billing_address[:zip]
240
+ xml.tag! 'BillingCountry', lookup_country_code(billing_address[:country])
241
+ xml.tag! 'BillingPhone', billing_address[:phone]
242
+ end
243
+
244
+ if shipping_address = options[:shipping_address]
245
+ xml.tag! 'ShippingInfo' do
246
+ xml.tag! 'ShippingName', shipping_address[:name]
247
+
248
+ xml.tag! 'ShippingAddr' do
249
+ xml.tag! 'Address', [shipping_address[:address1], shipping_address[:address2]].compact.join(" ")
250
+ xml.tag! 'City', shipping_address[:city]
251
+ xml.tag! 'StateProv', shipping_address[:state]
252
+ xml.tag! 'PostalCode', shipping_address[:zip]
253
+ xml.tag! 'Country', lookup_country_code(shipping_address[:country])
254
+ end
255
+ end
256
+ end
257
+ end
258
+
259
+ def add_customer_data(xml, options)
260
+ xml.tag! 'Email', options[:email] if options[:email]
261
+ xml.tag! 'UserIPAddress', options[:ip] if options[:ip]
262
+ end
263
+
264
+ def add_invoice_data(xml, options)
265
+ xml.tag! 'OrderNumber', options[:order_id] if options[:order_id]
266
+ xml.tag! 'TaxAmount', amount(options[:tax]) if options[:tax]
267
+ end
268
+
269
+ def lookup_country_code(code)
270
+ country = Country.find(code) rescue nil
271
+ country && country.code(:alpha3)
272
+ end
273
+ end
274
+ end
275
+ end
276
+
@@ -0,0 +1,451 @@
1
+ require 'rexml/document'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+
6
+ # Initialization Options
7
+ # :login Your store number
8
+ # :pem The text of your linkpoint PEM file. Note
9
+ # this is not the path to file, but its
10
+ # contents. If you are only using one PEM
11
+ # file on your site you can declare it
12
+ # globally and then you won't need to
13
+ # include this option
14
+ #
15
+ #
16
+ # A valid store number is required. Unfortunately, with LinkPoint
17
+ # YOU CAN'T JUST USE ANY OLD STORE NUMBER. Also, you can't just
18
+ # generate your own PEM file. You'll need to use a special PEM file
19
+ # provided by LinkPoint.
20
+ #
21
+ # Go to http://www.linkpoint.com/support/sup_teststore.asp to set up
22
+ # a test account and obtain your PEM file.
23
+ #
24
+ # Declaring PEM file Globally
25
+ # ActiveMerchant::Billing::LinkpointGateway.pem_file = File.read( File.dirname(__FILE__) + '/../mycert.pem' )
26
+ #
27
+ #
28
+ # Valid Order Options
29
+ # :result =>
30
+ # LIVE Production mode
31
+ # GOOD Approved response in test mode
32
+ # DECLINE Declined response in test mode
33
+ # DUPLICATE Duplicate response in test mode
34
+ #
35
+ # :ponumber Order number
36
+ #
37
+ # :transactionorigin => Source of the transaction
38
+ # ECI Email or Internet
39
+ # MAIL Mail order
40
+ # MOTO Mail order/Telephone
41
+ # TELEPHONE Telephone
42
+ # RETAIL Face-to-face
43
+ #
44
+ # :ordertype =>
45
+ # SALE Real live sale
46
+ # PREAUTH Authorize only
47
+ # POSTAUTH Forced Ticket or Ticket Only transaction
48
+ # VOID
49
+ # CREDIT
50
+ # CALCSHIPPING For shipping charges calculations
51
+ # CALCTAX For sales tax calculations
52
+ #
53
+ # Recurring Options
54
+ # :action =>
55
+ # SUBMIT
56
+ # MODIFY
57
+ # CANCEL
58
+ #
59
+ # :installments Identifies how many recurring payments to charge the customer
60
+ # :startdate Date to begin charging the recurring payments. Format: YYYYMMDD or "immediate"
61
+ # :periodicity =>
62
+ # MONTHLY
63
+ # BIMONTHLY
64
+ # WEEKLY
65
+ # BIWEEKLY
66
+ # YEARLY
67
+ # DAILY
68
+ # :threshold Tells how many times to retry the transaction (if it fails) before contacting the merchant.
69
+ # :comments Uh... comments
70
+ #
71
+ #
72
+ # For reference:
73
+ #
74
+ # https://www.linkpointcentral.com/lpc/docs/Help/APIHelp/lpintguide.htm
75
+ #
76
+ # Entities = {
77
+ # :payment => [:subtotal, :tax, :vattax, :shipping, :chargetotal],
78
+ # :billing => [:name, :address1, :address2, :city, :state, :zip, :country, :email, :phone, :fax, :addrnum],
79
+ # :shipping => [:name, :address1, :address2, :city, :state, :zip, :country, :weight, :items, :carrier, :total],
80
+ # :creditcard => [:cardnumber, :cardexpmonth, :cardexpyear, :cvmvalue, :track],
81
+ # :telecheck => [:routing, :account, :checknumber, :bankname, :bankstate, :dl, :dlstate, :void, :accounttype, :ssn],
82
+ # :transactiondetails => [:transactionorigin, :oid, :ponumber, :taxexempt, :terminaltype, :ip, :reference_number, :recurring, :tdate],
83
+ # :periodic => [:action, :installments, :threshold, :startdate, :periodicity, :comments],
84
+ # :notes => [:comments, :referred]
85
+ # :items => [:item => [:price, :quantity, :description, :id, :options => [:option => [:name, :value]]]]
86
+ # }
87
+ #
88
+ #
89
+ # LinkPoint's Items entity is an optional entity that can be attached to orders.
90
+ # It is entered as :line_items to be consistent with the CyberSource implementation
91
+ #
92
+ # The line_item hash goes in the options hash and should look like
93
+ #
94
+ # :line_items => [
95
+ # {
96
+ # :id => '123456',
97
+ # :description => 'Logo T-Shirt',
98
+ # :price => '12.00',
99
+ # :quantity => '1',
100
+ # :options => [
101
+ # {
102
+ # :name => 'Color',
103
+ # :value => 'Red'
104
+ # },
105
+ # {
106
+ # :name => 'Size',
107
+ # :value => 'XL'
108
+ # }
109
+ # ]
110
+ # },
111
+ # {
112
+ # :id => '111',
113
+ # :description => 'keychain',
114
+ # :price => '3.00',
115
+ # :quantity => '1'
116
+ # }
117
+ # ]
118
+ # This functionality is only supported by this particular gateway may
119
+ # be changed at any time
120
+ #
121
+ class LinkpointGateway < Gateway
122
+ # Your global PEM file. This will be assigned to you by linkpoint
123
+ #
124
+ # Example:
125
+ #
126
+ # ActiveMerchant::Billing::LinkpointGateway.pem_file = File.read( File.dirname(__FILE__) + '/../mycert.pem' )
127
+ #
128
+ cattr_accessor :pem_file
129
+
130
+ self.test_url = 'https://staging.linkpt.net:1129/'
131
+ self.live_url = 'https://secure.linkpt.net:1129/'
132
+
133
+ self.supported_countries = ['US']
134
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club]
135
+ self.homepage_url = 'http://www.linkpoint.com/'
136
+ self.display_name = 'LinkPoint'
137
+
138
+ def initialize(options = {})
139
+ requires!(options, :login)
140
+
141
+ @options = {
142
+ :result => 'LIVE',
143
+ :pem => LinkpointGateway.pem_file
144
+ }.update(options)
145
+
146
+ raise ArgumentError, "You need to pass in your pem file using the :pem parameter or set it globally using ActiveMerchant::Billing::LinkpointGateway.pem_file = File.read( File.dirname(__FILE__) + '/../mycert.pem' ) or similar" if @options[:pem].blank?
147
+ end
148
+
149
+ # Send a purchase request with periodic options
150
+ # Recurring Options
151
+ # :action =>
152
+ # SUBMIT
153
+ # MODIFY
154
+ # CANCEL
155
+ #
156
+ # :installments Identifies how many recurring payments to charge the customer
157
+ # :startdate Date to begin charging the recurring payments. Format: YYYYMMDD or "immediate"
158
+ # :periodicity =>
159
+ # :monthly
160
+ # :bimonthly
161
+ # :weekly
162
+ # :biweekly
163
+ # :yearly
164
+ # :daily
165
+ # :threshold Tells how many times to retry the transaction (if it fails) before contacting the merchant.
166
+ # :comments Uh... comments
167
+ #
168
+ def recurring(money, creditcard, options={})
169
+ requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily], :installments, :order_id )
170
+
171
+ options.update(
172
+ :ordertype => "SALE",
173
+ :action => options[:action] || "SUBMIT",
174
+ :installments => options[:installments] || 12,
175
+ :startdate => options[:startdate] || "immediate",
176
+ :periodicity => options[:periodicity].to_s || "monthly",
177
+ :comments => options[:comments] || nil,
178
+ :threshold => options[:threshold] || 3
179
+ )
180
+ commit(money, creditcard, options)
181
+ end
182
+
183
+ # Buy the thing
184
+ def purchase(money, creditcard, options={})
185
+ requires!(options, :order_id)
186
+ options.update(
187
+ :ordertype => "SALE"
188
+ )
189
+ commit(money, creditcard, options)
190
+ end
191
+
192
+ #
193
+ # Authorize the transaction
194
+ #
195
+ # Reserves the funds on the customer's credit card, but does not charge the card.
196
+ #
197
+ def authorize(money, creditcard, options = {})
198
+ requires!(options, :order_id)
199
+ options.update(
200
+ :ordertype => "PREAUTH"
201
+ )
202
+ commit(money, creditcard, options)
203
+ end
204
+
205
+ #
206
+ # Post an authorization.
207
+ #
208
+ # Captures the funds from an authorized transaction.
209
+ # Order_id must be a valid order id from a prior authorized transaction.
210
+ #
211
+ def capture(money, authorization, options = {})
212
+ options.update(
213
+ :order_id => authorization,
214
+ :ordertype => "POSTAUTH"
215
+ )
216
+ commit(money, nil, options)
217
+ end
218
+
219
+ # Void a previous transaction
220
+ def void(identification, options = {})
221
+ options.update(
222
+ :order_id => identification,
223
+ :ordertype => "VOID"
224
+ )
225
+ commit(nil, nil, options)
226
+ end
227
+
228
+ #
229
+ # Refund an order
230
+ #
231
+ # identification must be a valid order id previously submitted by SALE
232
+ #
233
+ def refund(money, identification, options = {})
234
+ options.update(
235
+ :ordertype => "CREDIT",
236
+ :order_id => identification
237
+ )
238
+ commit(money, nil, options)
239
+ end
240
+
241
+ def credit(money, identification, options = {})
242
+ deprecated CREDIT_DEPRECATION_MESSAGE
243
+ refund(money, identification, options)
244
+ end
245
+
246
+ def test?
247
+ @options[:test] || super
248
+ end
249
+
250
+ private
251
+ # Commit the transaction by posting the XML file to the LinkPoint server
252
+ def commit(money, creditcard, options = {})
253
+ response = parse(ssl_post(test? ? self.test_url : self.live_url, post_data(money, creditcard, options)))
254
+
255
+ Response.new(successful?(response), response[:message], response,
256
+ :test => test?,
257
+ :authorization => response[:ordernum],
258
+ :avs_result => { :code => response[:avs].to_s[2,1] },
259
+ :cvv_result => response[:avs].to_s[3,1]
260
+ )
261
+ end
262
+
263
+ def successful?(response)
264
+ response[:approved] == "APPROVED"
265
+ end
266
+
267
+ # Build the XML file
268
+ def post_data(money, creditcard, options)
269
+ params = parameters(money, creditcard, options)
270
+
271
+ xml = REXML::Document.new
272
+ order = xml.add_element("order")
273
+
274
+ # Merchant Info
275
+ merchantinfo = order.add_element("merchantinfo")
276
+ merchantinfo.add_element("configfile").text = @options[:login]
277
+
278
+ # Loop over the params hash to construct the XML string
279
+ for key, value in params
280
+ elem = order.add_element(key.to_s)
281
+ if key == :items
282
+ build_items(elem, value)
283
+ else
284
+ for k, v in params[key]
285
+ elem.add_element(k.to_s).text = params[key][k].to_s if params[key][k]
286
+ end
287
+ end
288
+ # Linkpoint doesn't understand empty elements:
289
+ order.delete(elem) if elem.size == 0
290
+ end
291
+ return xml.to_s
292
+ end
293
+
294
+ # adds LinkPoint's Items entity to the XML. Called from post_data
295
+ def build_items(element, items)
296
+ for item in items
297
+ item_element = element.add_element("item")
298
+ for key, value in item
299
+ if key == :options
300
+ options_element = item_element.add_element("options")
301
+ for option in value
302
+ opt_element = options_element.add_element("option")
303
+ opt_element.add_element("name").text = option[:name] unless option[:name].blank?
304
+ opt_element.add_element("value").text = option[:value] unless option[:value].blank?
305
+ end
306
+ else
307
+ item_element.add_element(key.to_s).text = item[key].to_s unless item[key].blank?
308
+ end
309
+ end
310
+ end
311
+ end
312
+
313
+ # Set up the parameters hash just once so we don't have to do it
314
+ # for every action.
315
+ def parameters(money, creditcard, options = {})
316
+
317
+ params = {
318
+ :payment => {
319
+ :subtotal => amount(options[:subtotal]),
320
+ :tax => amount(options[:tax]),
321
+ :vattax => amount(options[:vattax]),
322
+ :shipping => amount(options[:shipping]),
323
+ :chargetotal => amount(money)
324
+ },
325
+ :transactiondetails => {
326
+ :transactionorigin => options[:transactionorigin] || "ECI",
327
+ :oid => options[:order_id],
328
+ :ponumber => options[:ponumber],
329
+ :taxexempt => options[:taxexempt],
330
+ :terminaltype => options[:terminaltype],
331
+ :ip => options[:ip],
332
+ :reference_number => options[:reference_number],
333
+ :recurring => options[:recurring] || "NO", #DO NOT USE if you are using the periodic billing option.
334
+ :tdate => options[:tdate]
335
+ },
336
+ :orderoptions => {
337
+ :ordertype => options[:ordertype],
338
+ :result => @options[:result]
339
+ },
340
+ :periodic => {
341
+ :action => options[:action],
342
+ :installments => options[:installments],
343
+ :threshold => options[:threshold],
344
+ :startdate => options[:startdate],
345
+ :periodicity => options[:periodicity],
346
+ :comments => options[:comments]
347
+ },
348
+ :telecheck => {
349
+ :routing => options[:telecheck_routing],
350
+ :account => options[:telecheck_account],
351
+ :checknumber => options[:telecheck_checknumber],
352
+ :bankname => options[:telecheck_bankname],
353
+ :dl => options[:telecheck_dl],
354
+ :dlstate => options[:telecheck_dlstate],
355
+ :void => options[:telecheck_void],
356
+ :accounttype => options[:telecheck_accounttype],
357
+ :ssn => options[:telecheck_ssn],
358
+ }
359
+ }
360
+
361
+ if creditcard
362
+ params[:creditcard] = {
363
+ :cardnumber => creditcard.number,
364
+ :cardexpmonth => creditcard.month,
365
+ :cardexpyear => format_creditcard_expiry_year(creditcard.year),
366
+ :track => nil
367
+ }
368
+
369
+ if creditcard.verification_value?
370
+ params[:creditcard][:cvmvalue] = creditcard.verification_value
371
+ params[:creditcard][:cvmindicator] = 'provided'
372
+ else
373
+ params[:creditcard][:cvmindicator] = 'not_provided'
374
+ end
375
+ end
376
+
377
+ if billing_address = options[:billing_address] || options[:address]
378
+
379
+ params[:billing] = {}
380
+ params[:billing][:name] = billing_address[:name] || (creditcard ? creditcard.name : nil)
381
+ params[:billing][:address1] = billing_address[:address1] unless billing_address[:address1].blank?
382
+ params[:billing][:address2] = billing_address[:address2] unless billing_address[:address2].blank?
383
+ params[:billing][:city] = billing_address[:city] unless billing_address[:city].blank?
384
+ params[:billing][:state] = billing_address[:state] unless billing_address[:state].blank?
385
+ params[:billing][:zip] = billing_address[:zip] unless billing_address[:zip].blank?
386
+ params[:billing][:country] = billing_address[:country] unless billing_address[:country].blank?
387
+ params[:billing][:company] = billing_address[:company] unless billing_address[:company].blank?
388
+ params[:billing][:phone] = billing_address[:phone] unless billing_address[:phone].blank?
389
+ params[:billing][:email] = options[:email] unless options[:email].blank?
390
+ end
391
+
392
+ if shipping_address = options[:shipping_address]
393
+
394
+ params[:shipping] = {}
395
+ params[:shipping][:name] = shipping_address[:name] || creditcard ? creditcard.name : nil
396
+ params[:shipping][:address1] = shipping_address[:address1] unless shipping_address[:address1].blank?
397
+ params[:shipping][:address2] = shipping_address[:address2] unless shipping_address[:address2].blank?
398
+ params[:shipping][:city] = shipping_address[:city] unless shipping_address[:city].blank?
399
+ params[:shipping][:state] = shipping_address[:state] unless shipping_address[:state].blank?
400
+ params[:shipping][:zip] = shipping_address[:zip] unless shipping_address[:zip].blank?
401
+ params[:shipping][:country] = shipping_address[:country] unless shipping_address[:country].blank?
402
+ end
403
+
404
+ params[:items] = options[:line_items] if options[:line_items]
405
+
406
+ return params
407
+ end
408
+
409
+ def parse(xml)
410
+
411
+ # For reference, a typical response...
412
+ # <r_csp></r_csp>
413
+ # <r_time></r_time>
414
+ # <r_ref></r_ref>
415
+ # <r_error></r_error>
416
+ # <r_ordernum></r_ordernum>
417
+ # <r_message>This is a test transaction and will not show up in the Reports</r_message>
418
+ # <r_code></r_code>
419
+ # <r_tdate>Thu Feb 2 15:40:21 2006</r_tdate>
420
+ # <r_score></r_score>
421
+ # <r_authresponse></r_authresponse>
422
+ # <r_approved>APPROVED</r_approved>
423
+ # <r_avs></r_avs>
424
+
425
+ response = {:message => "Global Error Receipt", :complete => false}
426
+
427
+ xml = REXML::Document.new("<response>#{xml}</response>")
428
+ xml.root.elements.each do |node|
429
+ response[node.name.downcase.sub(/^r_/, '').to_sym] = normalize(node.text)
430
+ end unless xml.root.nil?
431
+
432
+ response
433
+ end
434
+
435
+ # Make a ruby type out of the response string
436
+ def normalize(field)
437
+ case field
438
+ when "true" then true
439
+ when "false" then false
440
+ when "" then nil
441
+ when "null" then nil
442
+ else field
443
+ end
444
+ end
445
+
446
+ def format_creditcard_expiry_year(year)
447
+ sprintf("%.4i", year)[-2..-1]
448
+ end
449
+ end
450
+ end
451
+ end