abtain_billing 1.0 → 1.02

Sign up to get free protection for your applications and to get access to all the features.
Files changed (237) hide show
  1. data/CHANGELOG +2 -472
  2. data/CONTRIBUTORS +0 -126
  3. data/MIT-LICENSE +2 -2
  4. data/Rakefile +3 -3
  5. data/init.rb +3 -3
  6. data/lib/{active_merchant.rb → abtain_billing.rb} +18 -18
  7. data/lib/{active_merchant → abtain_billing}/billing/avs_result.rb +1 -1
  8. data/lib/{active_merchant → abtain_billing}/billing/base.rb +7 -7
  9. data/lib/{active_merchant → abtain_billing}/billing/check.rb +1 -1
  10. data/lib/{active_merchant → abtain_billing}/billing/credit_card.rb +2 -2
  11. data/lib/{active_merchant → abtain_billing}/billing/credit_card_formatting.rb +1 -1
  12. data/lib/{active_merchant → abtain_billing}/billing/credit_card_methods.rb +2 -2
  13. data/lib/{active_merchant → abtain_billing}/billing/cvv_result.rb +1 -1
  14. data/lib/{active_merchant → abtain_billing}/billing/expiry_date.rb +1 -1
  15. data/lib/{active_merchant → abtain_billing}/billing/gateway.rb +5 -5
  16. data/lib/{active_merchant → abtain_billing}/billing/gateways.rb +1 -1
  17. data/lib/{active_merchant → abtain_billing}/billing/gateways/authorize_net.rb +3 -1
  18. data/lib/{active_merchant → abtain_billing}/billing/gateways/authorize_net_cim.rb +2 -1
  19. data/lib/{active_merchant → abtain_billing}/billing/gateways/bogus.rb +1 -1
  20. data/lib/{active_merchant → abtain_billing}/billing/gateways/cyber_source.rb +1 -1
  21. data/lib/abtain_billing/billing/integrations.rb +22 -0
  22. data/lib/{active_merchant → abtain_billing}/billing/integrations/action_view_helper.rb +2 -2
  23. data/lib/{active_merchant → abtain_billing}/billing/integrations/bogus.rb +4 -4
  24. data/lib/{active_merchant → abtain_billing}/billing/integrations/bogus/helper.rb +2 -2
  25. data/lib/{active_merchant → abtain_billing}/billing/integrations/bogus/notification.rb +2 -2
  26. data/lib/{active_merchant → abtain_billing}/billing/integrations/bogus/return.rb +2 -2
  27. data/lib/{active_merchant → abtain_billing}/billing/integrations/chronopay.rb +4 -4
  28. data/lib/{active_merchant → abtain_billing}/billing/integrations/chronopay/helper.rb +2 -2
  29. data/lib/{active_merchant → abtain_billing}/billing/integrations/chronopay/notification.rb +2 -2
  30. data/lib/{active_merchant → abtain_billing}/billing/integrations/chronopay/return.rb +2 -2
  31. data/lib/{active_merchant → abtain_billing}/billing/integrations/gestpay.rb +1 -1
  32. data/lib/{active_merchant → abtain_billing}/billing/integrations/gestpay/common.rb +1 -1
  33. data/lib/{active_merchant → abtain_billing}/billing/integrations/gestpay/helper.rb +2 -2
  34. data/lib/{active_merchant → abtain_billing}/billing/integrations/gestpay/notification.rb +2 -2
  35. data/lib/{active_merchant → abtain_billing}/billing/integrations/gestpay/return.rb +2 -2
  36. data/lib/{active_merchant → abtain_billing}/billing/integrations/helper.rb +2 -2
  37. data/lib/{active_merchant → abtain_billing}/billing/integrations/hi_trust.rb +2 -2
  38. data/lib/{active_merchant → abtain_billing}/billing/integrations/hi_trust/helper.rb +2 -2
  39. data/lib/{active_merchant → abtain_billing}/billing/integrations/hi_trust/notification.rb +3 -3
  40. data/lib/{active_merchant → abtain_billing}/billing/integrations/hi_trust/return.rb +2 -2
  41. data/lib/{active_merchant → abtain_billing}/billing/integrations/nochex.rb +5 -5
  42. data/lib/{active_merchant → abtain_billing}/billing/integrations/nochex/helper.rb +2 -2
  43. data/lib/{active_merchant → abtain_billing}/billing/integrations/nochex/notification.rb +3 -3
  44. data/lib/{active_merchant → abtain_billing}/billing/integrations/nochex/return.rb +2 -2
  45. data/lib/{active_merchant → abtain_billing}/billing/integrations/notification.rb +2 -2
  46. data/lib/{active_merchant → abtain_billing}/billing/integrations/paypal.rb +5 -5
  47. data/lib/{active_merchant → abtain_billing}/billing/integrations/paypal/helper.rb +2 -2
  48. data/lib/{active_merchant → abtain_billing}/billing/integrations/paypal/notification.rb +3 -3
  49. data/lib/{active_merchant → abtain_billing}/billing/integrations/paypal/return.rb +2 -2
  50. data/lib/{active_merchant → abtain_billing}/billing/integrations/quickpay.rb +1 -1
  51. data/lib/{active_merchant → abtain_billing}/billing/integrations/quickpay/helper.rb +2 -2
  52. data/lib/{active_merchant → abtain_billing}/billing/integrations/quickpay/notification.rb +2 -2
  53. data/lib/{active_merchant → abtain_billing}/billing/integrations/return.rb +1 -1
  54. data/lib/{active_merchant → abtain_billing}/billing/integrations/two_checkout.rb +1 -1
  55. data/lib/{active_merchant → abtain_billing}/billing/integrations/two_checkout/helper.rb +3 -3
  56. data/lib/{active_merchant → abtain_billing}/billing/integrations/two_checkout/notification.rb +2 -2
  57. data/lib/{active_merchant → abtain_billing}/billing/integrations/two_checkout/return.rb +2 -2
  58. data/lib/{active_merchant → abtain_billing}/billing/response.rb +2 -2
  59. data/lib/{active_merchant → abtain_billing}/lib/connection.rb +3 -3
  60. data/lib/{active_merchant → abtain_billing}/lib/country.rb +1 -1
  61. data/lib/abtain_billing/lib/error.rb +4 -0
  62. data/lib/{active_merchant → abtain_billing}/lib/post_data.rb +0 -0
  63. data/lib/{active_merchant → abtain_billing}/lib/posts_data.rb +1 -1
  64. data/lib/{active_merchant → abtain_billing}/lib/requires_parameters.rb +1 -1
  65. data/lib/{active_merchant → abtain_billing}/lib/utils.rb +1 -1
  66. data/lib/{active_merchant → abtain_billing}/lib/validateable.rb +1 -1
  67. data/lib/support/gateway_support.rb +3 -3
  68. data/test/fixtures.yml +2 -2
  69. data/test/remote/integrations/remote_gestpay_integration_test.rb +1 -1
  70. data/test/remote/integrations/remote_paypal_integration_test.rb +3 -3
  71. data/test/test_helper.rb +10 -10
  72. data/test/unit/base_test.rb +2 -2
  73. data/test/unit/connection_test.rb +11 -11
  74. data/test/unit/country_code_test.rb +1 -1
  75. data/test/unit/country_test.rb +1 -1
  76. data/test/unit/credit_card_formatting_test.rb +1 -1
  77. data/test/unit/credit_card_methods_test.rb +2 -2
  78. data/test/unit/gateways/authorize_net_test.rb +2 -2
  79. data/test/unit/gateways/bogus_test.rb +1 -1
  80. data/test/unit/gateways/data_cash_test.rb +1 -1
  81. data/test/unit/gateways/jetpay_test.rb +1 -1
  82. data/test/unit/gateways/merchant_ware_test.rb +1 -1
  83. data/test/unit/gateways/payflow_express_test.rb +1 -1
  84. data/test/unit/gateways/payflow_test.rb +5 -5
  85. data/test/unit/gateways/paypal_express_test.rb +2 -2
  86. data/test/unit/gateways/paypal_test.rb +2 -2
  87. data/test/unit/gateways/realex_test.rb +1 -1
  88. data/test/unit/gateways/verifi_test.rb +1 -1
  89. data/test/unit/integrations/action_view_helper_test.rb +1 -1
  90. data/test/unit/integrations/bogus_module_test.rb +1 -1
  91. data/test/unit/integrations/chronopay_module_test.rb +1 -1
  92. data/test/unit/integrations/gestpay_module_test.rb +1 -1
  93. data/test/unit/integrations/helpers/bogus_helper_test.rb +1 -1
  94. data/test/unit/integrations/helpers/chronopay_helper_test.rb +1 -1
  95. data/test/unit/integrations/helpers/gestpay_helper_test.rb +1 -1
  96. data/test/unit/integrations/helpers/hi_trust_helper_test.rb +1 -1
  97. data/test/unit/integrations/helpers/nochex_helper_test.rb +1 -1
  98. data/test/unit/integrations/helpers/paypal_helper_test.rb +2 -2
  99. data/test/unit/integrations/helpers/quickpay_helper_test.rb +1 -1
  100. data/test/unit/integrations/helpers/two_checkout_helper_test.rb +4 -4
  101. data/test/unit/integrations/hi_trust_module_test.rb +1 -1
  102. data/test/unit/integrations/nochex_module_test.rb +1 -1
  103. data/test/unit/integrations/notifications/chronopay_notification_test.rb +1 -1
  104. data/test/unit/integrations/notifications/gestpay_notification_test.rb +1 -1
  105. data/test/unit/integrations/notifications/hi_trust_notification_test.rb +4 -4
  106. data/test/unit/integrations/notifications/nochex_notification_test.rb +1 -1
  107. data/test/unit/integrations/notifications/notification_test.rb +4 -4
  108. data/test/unit/integrations/notifications/paypal_notification_test.rb +1 -1
  109. data/test/unit/integrations/notifications/quickpay_notification_test.rb +1 -1
  110. data/test/unit/integrations/notifications/two_checkout_notification_test.rb +1 -1
  111. data/test/unit/integrations/paypal_module_test.rb +4 -4
  112. data/test/unit/integrations/quickpay_module_test.rb +1 -1
  113. data/test/unit/integrations/returns/chronopay_return_test.rb +1 -1
  114. data/test/unit/integrations/returns/gestpay_return_test.rb +1 -1
  115. data/test/unit/integrations/returns/hi_trust_return_test.rb +1 -1
  116. data/test/unit/integrations/returns/nochex_return_test.rb +1 -1
  117. data/test/unit/integrations/returns/paypal_return_test.rb +1 -1
  118. data/test/unit/integrations/returns/return_test.rb +1 -1
  119. data/test/unit/integrations/returns/two_checkout_return_test.rb +1 -1
  120. data/test/unit/integrations/two_checkout_module_test.rb +1 -1
  121. data/test/unit/posts_data_test.rb +5 -5
  122. data/test/unit/utils_test.rb +1 -1
  123. data/test/unit/validateable_test.rb +2 -2
  124. metadata +63 -174
  125. data/lib/active_merchant/billing/gateways/beanstream.rb +0 -102
  126. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +0 -233
  127. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +0 -54
  128. data/lib/active_merchant/billing/gateways/braintree.rb +0 -17
  129. data/lib/active_merchant/billing/gateways/card_stream.rb +0 -230
  130. data/lib/active_merchant/billing/gateways/data_cash.rb +0 -595
  131. data/lib/active_merchant/billing/gateways/efsnet.rb +0 -229
  132. data/lib/active_merchant/billing/gateways/elavon.rb +0 -106
  133. data/lib/active_merchant/billing/gateways/eway.rb +0 -277
  134. data/lib/active_merchant/billing/gateways/exact.rb +0 -222
  135. data/lib/active_merchant/billing/gateways/first_pay.rb +0 -172
  136. data/lib/active_merchant/billing/gateways/instapay.rb +0 -164
  137. data/lib/active_merchant/billing/gateways/jetpay.rb +0 -270
  138. data/lib/active_merchant/billing/gateways/linkpoint.rb +0 -449
  139. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +0 -154
  140. data/lib/active_merchant/billing/gateways/merchant_ware.rb +0 -283
  141. data/lib/active_merchant/billing/gateways/modern_payments.rb +0 -36
  142. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +0 -214
  143. data/lib/active_merchant/billing/gateways/moneris.rb +0 -205
  144. data/lib/active_merchant/billing/gateways/net_registry.rb +0 -189
  145. data/lib/active_merchant/billing/gateways/netbilling.rb +0 -168
  146. data/lib/active_merchant/billing/gateways/ogone.rb +0 -279
  147. data/lib/active_merchant/billing/gateways/pay_junction.rb +0 -392
  148. data/lib/active_merchant/billing/gateways/pay_secure.rb +0 -120
  149. data/lib/active_merchant/billing/gateways/payflow.rb +0 -236
  150. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +0 -207
  151. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +0 -39
  152. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +0 -13
  153. data/lib/active_merchant/billing/gateways/payflow_express.rb +0 -138
  154. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +0 -15
  155. data/lib/active_merchant/billing/gateways/payflow_uk.rb +0 -21
  156. data/lib/active_merchant/billing/gateways/payment_express.rb +0 -230
  157. data/lib/active_merchant/billing/gateways/paypal.rb +0 -121
  158. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +0 -326
  159. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +0 -38
  160. data/lib/active_merchant/billing/gateways/paypal_ca.rb +0 -13
  161. data/lib/active_merchant/billing/gateways/paypal_express.rb +0 -130
  162. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +0 -20
  163. data/lib/active_merchant/billing/gateways/plugnpay.rb +0 -292
  164. data/lib/active_merchant/billing/gateways/psigate.rb +0 -214
  165. data/lib/active_merchant/billing/gateways/psl_card.rb +0 -306
  166. data/lib/active_merchant/billing/gateways/quickpay.rb +0 -213
  167. data/lib/active_merchant/billing/gateways/realex.rb +0 -200
  168. data/lib/active_merchant/billing/gateways/sage.rb +0 -146
  169. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +0 -88
  170. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +0 -116
  171. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -97
  172. data/lib/active_merchant/billing/gateways/sage_pay.rb +0 -308
  173. data/lib/active_merchant/billing/gateways/sallie_mae.rb +0 -144
  174. data/lib/active_merchant/billing/gateways/secure_pay.rb +0 -31
  175. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +0 -157
  176. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +0 -113
  177. data/lib/active_merchant/billing/gateways/skip_jack.rb +0 -452
  178. data/lib/active_merchant/billing/gateways/smart_ps.rb +0 -254
  179. data/lib/active_merchant/billing/gateways/trans_first.rb +0 -127
  180. data/lib/active_merchant/billing/gateways/transax.rb +0 -26
  181. data/lib/active_merchant/billing/gateways/trust_commerce.rb +0 -418
  182. data/lib/active_merchant/billing/gateways/usa_epay.rb +0 -194
  183. data/lib/active_merchant/billing/gateways/verifi.rb +0 -228
  184. data/lib/active_merchant/billing/gateways/viaklix.rb +0 -189
  185. data/lib/active_merchant/billing/gateways/wirecard.rb +0 -318
  186. data/lib/active_merchant/billing/integrations.rb +0 -22
  187. data/lib/active_merchant/lib/error.rb +0 -4
  188. data/test/remote/gateways/remote_beanstream_interac_test.rb +0 -53
  189. data/test/remote/gateways/remote_beanstream_test.rb +0 -150
  190. data/test/remote/gateways/remote_braintree_test.rb +0 -154
  191. data/test/remote/gateways/remote_card_stream_test.rb +0 -148
  192. data/test/remote/gateways/remote_data_cash_test.rb +0 -357
  193. data/test/remote/gateways/remote_efsnet_test.rb +0 -81
  194. data/test/remote/gateways/remote_elavon_test.rb +0 -66
  195. data/test/remote/gateways/remote_eway_test.rb +0 -74
  196. data/test/remote/gateways/remote_exact_test.rb +0 -60
  197. data/test/remote/gateways/remote_first_pay_test.rb +0 -87
  198. data/test/remote/gateways/remote_instapay_test.rb +0 -61
  199. data/test/remote/gateways/remote_jetpay_test.rb +0 -103
  200. data/test/remote/gateways/remote_linkpoint_test.rb +0 -121
  201. data/test/remote/gateways/remote_merchant_e_solutions_test.rb +0 -173
  202. data/test/remote/gateways/remote_merchant_ware_test.rb +0 -113
  203. data/test/remote/gateways/remote_modern_payments_cim_test.rb +0 -58
  204. data/test/remote/gateways/remote_modern_payments_test.rb +0 -43
  205. data/test/remote/gateways/remote_moneris_test.rb +0 -82
  206. data/test/remote/gateways/remote_net_registry_test.rb +0 -85
  207. data/test/remote/gateways/remote_netbilling_test.rb +0 -70
  208. data/test/remote/gateways/remote_ogone_test.rb +0 -115
  209. data/test/remote/gateways/remote_pay_junction_test.rb +0 -143
  210. data/test/remote/gateways/remote_pay_secure_test.rb +0 -39
  211. data/test/remote/gateways/remote_payflow_express_test.rb +0 -50
  212. data/test/remote/gateways/remote_payflow_test.rb +0 -237
  213. data/test/remote/gateways/remote_payflow_uk_test.rb +0 -173
  214. data/test/remote/gateways/remote_payment_express_test.rb +0 -136
  215. data/test/remote/gateways/remote_paypal_express_test.rb +0 -49
  216. data/test/remote/gateways/remote_paypal_test.rb +0 -191
  217. data/test/remote/gateways/remote_plugnpay_test.rb +0 -72
  218. data/test/remote/gateways/remote_psigate_test.rb +0 -50
  219. data/test/remote/gateways/remote_psl_card_test.rb +0 -125
  220. data/test/remote/gateways/remote_quickpay_test.rb +0 -190
  221. data/test/remote/gateways/remote_realex_test.rb +0 -224
  222. data/test/remote/gateways/remote_sage_bankcard_test.rb +0 -109
  223. data/test/remote/gateways/remote_sage_pay_test.rb +0 -219
  224. data/test/remote/gateways/remote_sage_test.rb +0 -87
  225. data/test/remote/gateways/remote_sage_virtual_check_test.rb +0 -62
  226. data/test/remote/gateways/remote_sallie_mae_test.rb +0 -51
  227. data/test/remote/gateways/remote_secure_pay_au_test.rb +0 -40
  228. data/test/remote/gateways/remote_secure_pay_tech_test.rb +0 -37
  229. data/test/remote/gateways/remote_secure_pay_test.rb +0 -28
  230. data/test/remote/gateways/remote_skipjack_test.rb +0 -105
  231. data/test/remote/gateways/remote_trans_first_test.rb +0 -34
  232. data/test/remote/gateways/remote_transax_test.rb +0 -112
  233. data/test/remote/gateways/remote_trust_commerce_test.rb +0 -152
  234. data/test/remote/gateways/remote_usa_epay_test.rb +0 -46
  235. data/test/remote/gateways/remote_verifi_test.rb +0 -107
  236. data/test/remote/gateways/remote_viaklix_test.rb +0 -43
  237. data/test/remote/gateways/remote_wirecard_test.rb +0 -111
@@ -1,120 +0,0 @@
1
- module ActiveMerchant #:nodoc:
2
- module Billing #:nodoc:
3
- class PaySecureGateway < Gateway
4
- URL = 'https://clearance.commsecure.com.au/cgi-bin/PSDirect'
5
-
6
- self.money_format = :cents
7
-
8
- # Currently Authorization and Capture is not implemented because
9
- # capturing requires the original credit card information
10
- TRANSACTIONS = {
11
- :purchase => 'PURCHASE',
12
- :authorization => 'AUTHORISE',
13
- :capture => 'ADVICE',
14
- :credit => 'REFUND'
15
- }
16
-
17
- SUCCESS = 'Accepted'
18
- SUCCESS_MESSAGE = 'The transaction was approved'
19
-
20
- self.supported_countries = ['AU']
21
- self.homepage_url = 'http://www.commsecure.com.au/paysecure.shtml'
22
- self.display_name = 'PaySecure'
23
- self.supported_cardtypes = [:visa, :master, :american_express, :diners_club]
24
-
25
- def initialize(options = {})
26
- requires!(options, :login, :password)
27
- @options = options
28
- super
29
- end
30
-
31
- def purchase(money, credit_card, options = {})
32
- requires!(options, :order_id)
33
-
34
- post = {}
35
- add_amount(post, money)
36
- add_invoice(post, options)
37
- add_credit_card(post, credit_card)
38
-
39
- commit(:purchase, money, post)
40
- end
41
-
42
- private
43
- # Used for capturing, which is currently not supported.
44
- def add_reference(post, identification)
45
- auth, trans_id = identification.split(";")
46
- post[:authnum] = auth
47
- post[:transid] = trans_id
48
- end
49
-
50
- def add_amount(post, money)
51
- post[:amount] = amount(money)
52
- end
53
-
54
- def add_invoice(post, options)
55
- post[:merchant_transid] = options[:order_id].to_s.slice(0,21)
56
- post[:memnum] = options[:invoice]
57
- post[:custnum] = options[:customer]
58
- post[:clientdata] = options[:description]
59
- end
60
-
61
- def add_credit_card(post, credit_card)
62
- post[:cardnum] = credit_card.number
63
- post[:cardname] = credit_card.name
64
- post[:expiry] = expdate(credit_card)
65
- post[:cvv2] = credit_card.verification_value
66
- end
67
-
68
- def expdate(credit_card)
69
- year = sprintf("%.4i", credit_card.year)
70
- month = sprintf("%.2i", credit_card.month)
71
-
72
- "#{month}#{year[-2..-1]}"
73
- end
74
-
75
- def commit(action, money, parameters)
76
- response = parse( ssl_post(URL, post_data(action, parameters)) )
77
-
78
- Response.new(successful?(response), message_from(response), response,
79
- :test => test_response?(response),
80
- :authorization => authorization_from(response)
81
- )
82
-
83
- end
84
-
85
- def successful?(response)
86
- response[:status] == SUCCESS
87
- end
88
-
89
- def authorization_from(response)
90
- [ response[:authnum], response[:transid] ].compact.join(";")
91
- end
92
-
93
- def test_response?(response)
94
- !!(response[:transid] =~ /SimProxy/)
95
- end
96
-
97
- def message_from(response)
98
- successful?(response) ? SUCCESS_MESSAGE : response[:errorstring]
99
- end
100
-
101
- def parse(body)
102
- response = {}
103
- body.collect do |l|
104
- key, value = l.split(":", 2)
105
- response[key.to_s.downcase.to_sym] = value.strip
106
- end
107
- response
108
- end
109
-
110
- def post_data(action, parameters = {})
111
- parameters[:request_type] = TRANSACTIONS[action]
112
- parameters[:merchant_id] = @options[:login]
113
- parameters[:password] = @options[:password]
114
-
115
- parameters.reject{|k,v| v.blank?}.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join("&")
116
- end
117
- end
118
- end
119
- end
120
-
@@ -1,236 +0,0 @@
1
- require File.dirname(__FILE__) + '/payflow/payflow_common_api'
2
- require File.dirname(__FILE__) + '/payflow/payflow_response'
3
- require File.dirname(__FILE__) + '/payflow_express'
4
-
5
- module ActiveMerchant #:nodoc:
6
- module Billing #:nodoc:
7
- class PayflowGateway < Gateway
8
- include PayflowCommonAPI
9
-
10
- RECURRING_ACTIONS = Set.new([:add, :modify, :cancel, :inquiry, :reactivate, :payment])
11
-
12
- self.supported_cardtypes = [:visa, :master, :american_express, :jcb, :discover, :diners_club]
13
- self.homepage_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=_payflow-pro-overview-outside'
14
- self.display_name = 'PayPal Payflow Pro'
15
-
16
- def authorize(money, credit_card_or_reference, options = {})
17
- request = build_sale_or_authorization_request(:authorization, money, credit_card_or_reference, options)
18
-
19
- commit(request)
20
- end
21
-
22
- def purchase(money, credit_card_or_reference, options = {})
23
- request = build_sale_or_authorization_request(:purchase, money, credit_card_or_reference, options)
24
-
25
- commit(request)
26
- end
27
-
28
- def credit(money, identification_or_credit_card, options = {})
29
- if identification_or_credit_card.is_a?(String)
30
- # Perform referenced credit
31
- request = build_reference_request(:credit, money, identification_or_credit_card, options)
32
- else
33
- # Perform non-referenced credit
34
- request = build_credit_card_request(:credit, money, identification_or_credit_card, options)
35
- end
36
-
37
- commit(request)
38
- end
39
-
40
- # Adds or modifies a recurring Payflow profile. See the Payflow Pro Recurring Billing Guide for more details:
41
- # https://www.paypal.com/en_US/pdf/PayflowPro_RecurringBilling_Guide.pdf
42
- #
43
- # Several options are available to customize the recurring profile:
44
- #
45
- # * <tt>profile_id</tt> - is only required for editing a recurring profile
46
- # * <tt>starting_at</tt> - takes a Date, Time, or string in mmddyyyy format. The date must be in the future.
47
- # * <tt>name</tt> - The name of the customer to be billed. If not specified, the name from the credit card is used.
48
- # * <tt>periodicity</tt> - The frequency that the recurring payments will occur at. Can be one of
49
- # :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily, :semimonthly, :quadweekly, :quarterly, :semiyearly
50
- # * <tt>payments</tt> - The term, or number of payments that will be made
51
- # * <tt>comment</tt> - A comment associated with the profile
52
- def recurring(money, credit_card, options = {})
53
- options[:name] = credit_card.name if options[:name].blank? && credit_card
54
- request = build_recurring_request(options[:profile_id] ? :modify : :add, money, options) do |xml|
55
- add_credit_card(xml, credit_card) if credit_card
56
- end
57
- commit(request, :recurring)
58
- end
59
-
60
- def cancel_recurring(profile_id)
61
- request = build_recurring_request(:cancel, 0, :profile_id => profile_id)
62
- commit(request, :recurring)
63
- end
64
-
65
- def recurring_inquiry(profile_id, options = {})
66
- request = build_recurring_request(:inquiry, nil, options.update( :profile_id => profile_id ))
67
- commit(request, :recurring)
68
- end
69
-
70
- def express
71
- @express ||= PayflowExpressGateway.new(@options)
72
- end
73
-
74
- private
75
- def build_sale_or_authorization_request(action, money, credit_card_or_reference, options)
76
- if credit_card_or_reference.is_a?(String)
77
- build_reference_sale_or_authorization_request(action, money, credit_card_or_reference, options)
78
- else
79
- build_credit_card_request(action, money, credit_card_or_reference, options)
80
- end
81
- end
82
-
83
- def build_reference_sale_or_authorization_request(action, money, reference, options)
84
- xml = Builder::XmlMarkup.new
85
- xml.tag! TRANSACTIONS[action] do
86
- xml.tag! 'PayData' do
87
- xml.tag! 'Invoice' do
88
- xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
89
- end
90
- xml.tag! 'Tender' do
91
- xml.tag! 'Card' do
92
- xml.tag! 'ExtData', 'Name' => 'ORIGID', 'Value' => reference
93
- end
94
- end
95
- end
96
- end
97
- xml.target!
98
- end
99
-
100
- def build_credit_card_request(action, money, credit_card, options)
101
- xml = Builder::XmlMarkup.new
102
- xml.tag! TRANSACTIONS[action] do
103
- xml.tag! 'PayData' do
104
- xml.tag! 'Invoice' do
105
- xml.tag! 'CustIP', options[:ip] unless options[:ip].blank?
106
- xml.tag! 'InvNum', options[:order_id].to_s.gsub(/[^\w.]/, '') unless options[:order_id].blank?
107
- xml.tag! 'Description', options[:description] unless options[:description].blank?
108
-
109
- billing_address = options[:billing_address] || options[:address]
110
- add_address(xml, 'BillTo', billing_address, options) if billing_address
111
- add_address(xml, 'ShipTo', options[:shipping_address], options) if options[:shipping_address]
112
-
113
- xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
114
- end
115
-
116
- xml.tag! 'Tender' do
117
- add_credit_card(xml, credit_card)
118
- end
119
- end
120
- end
121
- xml.target!
122
- end
123
-
124
- def add_credit_card(xml, credit_card)
125
- xml.tag! 'Card' do
126
- xml.tag! 'CardType', credit_card_type(credit_card)
127
- xml.tag! 'CardNum', credit_card.number
128
- xml.tag! 'ExpDate', expdate(credit_card)
129
- xml.tag! 'NameOnCard', credit_card.first_name
130
- xml.tag! 'CVNum', credit_card.verification_value if credit_card.verification_value?
131
-
132
- if requires_start_date_or_issue_number?(credit_card)
133
- xml.tag!('ExtData', 'Name' => 'CardStart', 'Value' => startdate(credit_card)) unless credit_card.start_month.blank? || credit_card.start_year.blank?
134
- xml.tag!('ExtData', 'Name' => 'CardIssue', 'Value' => format(credit_card.issue_number, :two_digits)) unless credit_card.issue_number.blank?
135
- end
136
- xml.tag! 'ExtData', 'Name' => 'LASTNAME', 'Value' => credit_card.last_name
137
- end
138
- end
139
-
140
- def credit_card_type(credit_card)
141
- return '' if card_brand(credit_card).blank?
142
-
143
- CARD_MAPPING[card_brand(credit_card).to_sym]
144
- end
145
-
146
- def expdate(creditcard)
147
- year = sprintf("%.4i", creditcard.year)
148
- month = sprintf("%.2i", creditcard.month)
149
-
150
- "#{year}#{month}"
151
- end
152
-
153
- def startdate(creditcard)
154
- year = format(creditcard.start_year, :two_digits)
155
- month = format(creditcard.start_month, :two_digits)
156
-
157
- "#{month}#{year}"
158
- end
159
-
160
- def build_recurring_request(action, money, options)
161
- unless RECURRING_ACTIONS.include?(action)
162
- raise StandardError, "Invalid Recurring Profile Action: #{action}"
163
- end
164
-
165
- xml = Builder::XmlMarkup.new
166
- xml.tag! 'RecurringProfiles' do
167
- xml.tag! 'RecurringProfile' do
168
- xml.tag! action.to_s.capitalize do
169
- unless [:cancel, :inquiry].include?(action)
170
- xml.tag! 'RPData' do
171
- xml.tag! 'Name', options[:name] unless options[:name].nil?
172
- xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
173
- xml.tag! 'PayPeriod', get_pay_period(options)
174
- xml.tag! 'Term', options[:payments] unless options[:payments].nil?
175
- xml.tag! 'Comment', options[:comment] unless options[:comment].nil?
176
-
177
-
178
- if initial_tx = options[:initial_transaction]
179
- requires!(initial_tx, [:type, :authorization, :purchase])
180
- requires!(initial_tx, :amount) if initial_tx[:type] == :purchase
181
-
182
- xml.tag! 'OptionalTrans', TRANSACTIONS[initial_tx[:type]]
183
- xml.tag! 'OptionalTransAmt', amount(initial_tx[:amount]) unless initial_tx[:amount].blank?
184
- end
185
-
186
- xml.tag! 'Start', format_rp_date(options[:starting_at] || Date.today + 1 )
187
- xml.tag! 'EMail', options[:email] unless options[:email].nil?
188
-
189
- billing_address = options[:billing_address] || options[:address]
190
- add_address(xml, 'BillTo', billing_address, options) if billing_address
191
- add_address(xml, 'ShipTo', options[:shipping_address], options) if options[:shipping_address]
192
- end
193
- xml.tag! 'Tender' do
194
- yield xml
195
- end
196
- end
197
- if action != :add
198
- xml.tag! "ProfileID", options[:profile_id]
199
- end
200
- if action == :inquiry
201
- xml.tag! "PaymentHistory", ( options[:history] ? 'Y' : 'N' )
202
- end
203
- end
204
- end
205
- end
206
- end
207
-
208
- def get_pay_period(options)
209
- requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily, :semimonthly, :quadweekly, :quarterly, :semiyearly])
210
- case options[:periodicity]
211
- when :weekly then 'Weekly'
212
- when :biweekly then 'Bi-weekly'
213
- when :semimonthly then 'Semi-monthly'
214
- when :quadweekly then 'Every four weeks'
215
- when :monthly then 'Monthly'
216
- when :quarterly then 'Quarterly'
217
- when :semiyearly then 'Semi-yearly'
218
- when :yearly then 'Yearly'
219
- end
220
- end
221
-
222
- def format_rp_date(time)
223
- case time
224
- when Time, Date then time.strftime("%m%d%Y")
225
- else
226
- time.to_s
227
- end
228
- end
229
-
230
- def build_response(success, message, response, options = {})
231
- PayflowResponse.new(success, message, response, options)
232
- end
233
- end
234
- end
235
- end
236
-
@@ -1,207 +0,0 @@
1
- module ActiveMerchant #:nodoc:
2
- module Billing #:nodoc:
3
- module PayflowCommonAPI
4
- def self.included(base)
5
- base.default_currency = 'USD'
6
-
7
- base.class_inheritable_accessor :partner
8
-
9
- # Set the default partner to PayPal
10
- base.partner = 'PayPal'
11
-
12
- base.supported_countries = ['US', 'CA', 'SG', 'AU']
13
-
14
- base.class_inheritable_accessor :timeout
15
- base.timeout = 60
16
-
17
- # Enable safe retry of failed connections
18
- # Payflow is safe to retry because retried transactions use the same
19
- # X-VPS-Request-ID header. If a transaction is detected as a duplicate
20
- # only the original transaction data will be used by Payflow, and the
21
- # subsequent Responses will have a :duplicate parameter set in the params
22
- # hash.
23
- base.retry_safe = true
24
- end
25
-
26
- XMLNS = 'http://www.paypal.com/XMLPay'
27
- TEST_URL = 'https://pilot-payflowpro.paypal.com'
28
- LIVE_URL = 'https://payflowpro.paypal.com'
29
-
30
- CARD_MAPPING = {
31
- :visa => 'Visa',
32
- :master => 'MasterCard',
33
- :discover => 'Discover',
34
- :american_express => 'Amex',
35
- :jcb => 'JCB',
36
- :diners_club => 'DinersClub',
37
- :switch => 'Switch',
38
- :solo => 'Solo'
39
- }
40
-
41
- TRANSACTIONS = {
42
- :purchase => "Sale",
43
- :authorization => "Authorization",
44
- :capture => "Capture",
45
- :void => "Void",
46
- :credit => "Credit"
47
- }
48
-
49
- CVV_CODE = {
50
- 'Match' => 'M',
51
- 'No Match' => 'N',
52
- 'Service Not Available' => 'U',
53
- 'Service not Requested' => 'P'
54
- }
55
-
56
- def initialize(options = {})
57
- requires!(options, :login, :password)
58
-
59
- @options = options
60
- @options[:partner] = partner if @options[:partner].blank?
61
- super
62
- end
63
-
64
- def test?
65
- @options[:test] || super
66
- end
67
-
68
- def capture(money, authorization, options = {})
69
- request = build_reference_request(:capture, money, authorization, options)
70
- commit(request)
71
- end
72
-
73
- def void(authorization, options = {})
74
- request = build_reference_request(:void, nil, authorization, options)
75
- commit(request)
76
- end
77
-
78
- private
79
- def build_request(body, request_type = nil)
80
- xml = Builder::XmlMarkup.new
81
- xml.instruct!
82
- xml.tag! 'XMLPayRequest', 'Timeout' => 30, 'version' => "2.1", "xmlns" => XMLNS do
83
- xml.tag! 'RequestData' do
84
- xml.tag! 'Vendor', @options[:login]
85
- xml.tag! 'Partner', @options[:partner]
86
- if request_type == :recurring
87
- xml << body
88
- else
89
- xml.tag! 'Transactions' do
90
- xml.tag! 'Transaction' do
91
- xml.tag! 'Verbosity', 'MEDIUM'
92
- xml << body
93
- end
94
- end
95
- end
96
- end
97
- xml.tag! 'RequestAuth' do
98
- xml.tag! 'UserPass' do
99
- xml.tag! 'User', !@options[:user].blank? ? @options[:user] : @options[:login]
100
- xml.tag! 'Password', @options[:password]
101
- end
102
- end
103
- end
104
- xml.target!
105
- end
106
-
107
- def build_reference_request(action, money, authorization, options)
108
- xml = Builder::XmlMarkup.new
109
- xml.tag! TRANSACTIONS[action] do
110
- xml.tag! 'PNRef', authorization
111
-
112
- unless money.nil?
113
- xml.tag! 'Invoice' do
114
- xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
115
- end
116
- end
117
- end
118
-
119
- xml.target!
120
- end
121
-
122
- def add_address(xml, tag, address, options)
123
- return if address.nil?
124
- xml.tag! tag do
125
- xml.tag! 'Name', address[:name] unless address[:name].blank?
126
- xml.tag! 'EMail', options[:email] unless options[:email].blank?
127
- xml.tag! 'Phone', address[:phone] unless address[:phone].blank?
128
- xml.tag! 'CustCode', options[:customer] if !options[:customer].blank? && tag == 'BillTo'
129
-
130
- xml.tag! 'Address' do
131
- xml.tag! 'Street', address[:address1] unless address[:address1].blank?
132
- xml.tag! 'City', address[:city] unless address[:city].blank?
133
- xml.tag! 'State', address[:state].blank? ? "N/A" : address[:state]
134
- xml.tag! 'Country', address[:country] unless address[:country].blank?
135
- xml.tag! 'Zip', address[:zip] unless address[:zip].blank?
136
- end
137
- end
138
- end
139
-
140
- def parse(data)
141
- response = {}
142
- xml = REXML::Document.new(data)
143
- root = REXML::XPath.first(xml, "//ResponseData")
144
-
145
- # REXML::XPath in Ruby 1.8.6 is now unable to match nodes based on their attributes
146
- tx_result = REXML::XPath.first(root, "//TransactionResult")
147
-
148
- if tx_result && tx_result.attributes['Duplicate'] == "true"
149
- response[:duplicate] = true
150
- end
151
-
152
- root.elements.to_a.each do |node|
153
- parse_element(response, node)
154
- end
155
-
156
- response
157
- end
158
-
159
- def parse_element(response, node)
160
- node_name = node.name.underscore.to_sym
161
- case
162
- when node_name == :rp_payment_result
163
- # Since we'll have multiple history items, we can't just flatten everything
164
- # down as we do everywhere else. RPPaymentResult elements are not contained
165
- # in an RPPaymentResults element so we'll come here multiple times
166
- response[node_name] ||= []
167
- response[node_name] << ( payment_result_response = {} )
168
- node.elements.each{ |e| parse_element(payment_result_response, e) }
169
- when node.has_elements?
170
- node.elements.each{|e| parse_element(response, e) }
171
- when node_name.to_s =~ /amt$/
172
- # *Amt elements don't put the value in the #text - instead they use a Currency attribute
173
- response[node_name] = node.attributes['Currency']
174
- when node_name == :ext_data
175
- response[node.attributes['Name'].underscore.to_sym] = node.attributes['Value']
176
- else
177
- response[node_name] = node.text
178
- end
179
- end
180
-
181
- def build_headers(content_length)
182
- {
183
- "Content-Type" => "text/xml",
184
- "Content-Length" => content_length.to_s,
185
- "X-VPS-Client-Timeout" => timeout.to_s,
186
- "X-VPS-VIT-Integration-Product" => "ActiveMerchant",
187
- "X-VPS-VIT-Runtime-Version" => RUBY_VERSION,
188
- "X-VPS-Request-ID" => Utils.generate_unique_id
189
- }
190
- end
191
-
192
- def commit(request_body, request_type = nil)
193
- request = build_request(request_body, request_type)
194
- headers = build_headers(request.size)
195
-
196
- response = parse(ssl_post(test? ? TEST_URL : LIVE_URL, request, headers))
197
-
198
- build_response(response[:result] == "0", response[:message], response,
199
- :test => test?,
200
- :authorization => response[:pn_ref] || response[:rp_ref],
201
- :cvv_result => CVV_CODE[response[:cv_result]],
202
- :avs_result => { :code => response[:avs_result] }
203
- )
204
- end
205
- end
206
- end
207
- end