n8_activemerchant 1.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. data/CHANGELOG +574 -0
  2. data/CONTRIBUTORS +175 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.rdoc +151 -0
  5. data/gem-public_cert.pem +20 -0
  6. data/lib/active_merchant.rb +49 -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 +57 -0
  10. data/lib/active_merchant/billing/check.rb +68 -0
  11. data/lib/active_merchant/billing/credit_card.rb +161 -0
  12. data/lib/active_merchant/billing/credit_card_formatting.rb +21 -0
  13. data/lib/active_merchant/billing/credit_card_methods.rb +125 -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 +169 -0
  17. data/lib/active_merchant/billing/gateways.rb +18 -0
  18. data/lib/active_merchant/billing/gateways/authorize_net.rb +654 -0
  19. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +736 -0
  20. data/lib/active_merchant/billing/gateways/beanstream.rb +102 -0
  21. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +244 -0
  22. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
  23. data/lib/active_merchant/billing/gateways/bogus.rb +102 -0
  24. data/lib/active_merchant/billing/gateways/braintree.rb +17 -0
  25. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -0
  26. data/lib/active_merchant/billing/gateways/braintree_blue.rb +210 -0
  27. data/lib/active_merchant/billing/gateways/braintree_orange.rb +17 -0
  28. data/lib/active_merchant/billing/gateways/card_stream.rb +230 -0
  29. data/lib/active_merchant/billing/gateways/cyber_source.rb +406 -0
  30. data/lib/active_merchant/billing/gateways/data_cash.rb +593 -0
  31. data/lib/active_merchant/billing/gateways/efsnet.rb +229 -0
  32. data/lib/active_merchant/billing/gateways/elavon.rb +134 -0
  33. data/lib/active_merchant/billing/gateways/epay.rb +263 -0
  34. data/lib/active_merchant/billing/gateways/eway.rb +277 -0
  35. data/lib/active_merchant/billing/gateways/exact.rb +222 -0
  36. data/lib/active_merchant/billing/gateways/first_pay.rb +172 -0
  37. data/lib/active_merchant/billing/gateways/garanti.rb +222 -0
  38. data/lib/active_merchant/billing/gateways/inspire.rb +221 -0
  39. data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
  40. data/lib/active_merchant/billing/gateways/iridium.rb +253 -0
  41. data/lib/active_merchant/billing/gateways/jetpay.rb +270 -0
  42. data/lib/active_merchant/billing/gateways/linkpoint.rb +449 -0
  43. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +154 -0
  44. data/lib/active_merchant/billing/gateways/merchant_ware.rb +283 -0
  45. data/lib/active_merchant/billing/gateways/modern_payments.rb +36 -0
  46. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +220 -0
  47. data/lib/active_merchant/billing/gateways/moneris.rb +205 -0
  48. data/lib/active_merchant/billing/gateways/net_registry.rb +189 -0
  49. data/lib/active_merchant/billing/gateways/netaxept.rb +234 -0
  50. data/lib/active_merchant/billing/gateways/netbilling.rb +168 -0
  51. data/lib/active_merchant/billing/gateways/ogone.rb +279 -0
  52. data/lib/active_merchant/billing/gateways/pay_junction.rb +392 -0
  53. data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
  54. data/lib/active_merchant/billing/gateways/paybox_direct.rb +203 -0
  55. data/lib/active_merchant/billing/gateways/payflow.rb +236 -0
  56. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +207 -0
  57. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
  58. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  59. data/lib/active_merchant/billing/gateways/payflow_express.rb +138 -0
  60. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +15 -0
  61. data/lib/active_merchant/billing/gateways/payflow_uk.rb +21 -0
  62. data/lib/active_merchant/billing/gateways/payment_express.rb +230 -0
  63. data/lib/active_merchant/billing/gateways/paypal.rb +121 -0
  64. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +326 -0
  65. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +38 -0
  66. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  67. data/lib/active_merchant/billing/gateways/paypal_express.rb +145 -0
  68. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +20 -0
  69. data/lib/active_merchant/billing/gateways/paysimple/paysimple.rb +333 -0
  70. data/lib/active_merchant/billing/gateways/paysimple/usaepay.wsdl +1596 -0
  71. data/lib/active_merchant/billing/gateways/plugnpay.rb +292 -0
  72. data/lib/active_merchant/billing/gateways/psigate.rb +214 -0
  73. data/lib/active_merchant/billing/gateways/psl_card.rb +304 -0
  74. data/lib/active_merchant/billing/gateways/quickpay.rb +213 -0
  75. data/lib/active_merchant/billing/gateways/realex.rb +200 -0
  76. data/lib/active_merchant/billing/gateways/sage.rb +146 -0
  77. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
  78. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +116 -0
  79. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
  80. data/lib/active_merchant/billing/gateways/sage_pay.rb +315 -0
  81. data/lib/active_merchant/billing/gateways/sallie_mae.rb +144 -0
  82. data/lib/active_merchant/billing/gateways/secure_net.rb +330 -0
  83. data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
  84. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +157 -0
  85. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
  86. data/lib/active_merchant/billing/gateways/skip_jack.rb +453 -0
  87. data/lib/active_merchant/billing/gateways/smart_ps.rb +265 -0
  88. data/lib/active_merchant/billing/gateways/trans_first.rb +127 -0
  89. data/lib/active_merchant/billing/gateways/transax.rb +25 -0
  90. data/lib/active_merchant/billing/gateways/trust_commerce.rb +418 -0
  91. data/lib/active_merchant/billing/gateways/usa_epay.rb +194 -0
  92. data/lib/active_merchant/billing/gateways/usa_epay_soap.rb +154 -0
  93. data/lib/active_merchant/billing/gateways/verifi.rb +228 -0
  94. data/lib/active_merchant/billing/gateways/viaklix.rb +189 -0
  95. data/lib/active_merchant/billing/gateways/wirecard.rb +318 -0
  96. data/lib/active_merchant/billing/integrations.rb +17 -0
  97. data/lib/active_merchant/billing/integrations/action_view_helper.rb +68 -0
  98. data/lib/active_merchant/billing/integrations/bogus.rb +23 -0
  99. data/lib/active_merchant/billing/integrations/bogus/helper.rb +17 -0
  100. data/lib/active_merchant/billing/integrations/bogus/notification.rb +11 -0
  101. data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
  102. data/lib/active_merchant/billing/integrations/chronopay.rb +23 -0
  103. data/lib/active_merchant/billing/integrations/chronopay/helper.rb +120 -0
  104. data/lib/active_merchant/billing/integrations/chronopay/notification.rb +158 -0
  105. data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
  106. data/lib/active_merchant/billing/integrations/direc_pay.rb +41 -0
  107. data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +188 -0
  108. data/lib/active_merchant/billing/integrations/direc_pay/notification.rb +76 -0
  109. data/lib/active_merchant/billing/integrations/direc_pay/return.rb +32 -0
  110. data/lib/active_merchant/billing/integrations/direc_pay/status.rb +37 -0
  111. data/lib/active_merchant/billing/integrations/gestpay.rb +25 -0
  112. data/lib/active_merchant/billing/integrations/gestpay/common.rb +42 -0
  113. data/lib/active_merchant/billing/integrations/gestpay/helper.rb +70 -0
  114. data/lib/active_merchant/billing/integrations/gestpay/notification.rb +85 -0
  115. data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
  116. data/lib/active_merchant/billing/integrations/helper.rb +96 -0
  117. data/lib/active_merchant/billing/integrations/hi_trust.rb +27 -0
  118. data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
  119. data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +59 -0
  120. data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
  121. data/lib/active_merchant/billing/integrations/nochex.rb +88 -0
  122. data/lib/active_merchant/billing/integrations/nochex/helper.rb +68 -0
  123. data/lib/active_merchant/billing/integrations/nochex/notification.rb +94 -0
  124. data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
  125. data/lib/active_merchant/billing/integrations/notification.rb +62 -0
  126. data/lib/active_merchant/billing/integrations/paypal.rb +39 -0
  127. data/lib/active_merchant/billing/integrations/paypal/helper.rb +119 -0
  128. data/lib/active_merchant/billing/integrations/paypal/notification.rb +154 -0
  129. data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
  130. data/lib/active_merchant/billing/integrations/quickpay.rb +17 -0
  131. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +72 -0
  132. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +74 -0
  133. data/lib/active_merchant/billing/integrations/return.rb +37 -0
  134. data/lib/active_merchant/billing/integrations/sage_pay_form.rb +37 -0
  135. data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +33 -0
  136. data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +109 -0
  137. data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +204 -0
  138. data/lib/active_merchant/billing/integrations/sage_pay_form/return.rb +27 -0
  139. data/lib/active_merchant/billing/integrations/two_checkout.rb +23 -0
  140. data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +59 -0
  141. data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +114 -0
  142. data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
  143. data/lib/active_merchant/billing/response.rb +32 -0
  144. data/lib/active_merchant/common.rb +14 -0
  145. data/lib/active_merchant/common/connection.rb +162 -0
  146. data/lib/active_merchant/common/country.rb +328 -0
  147. data/lib/active_merchant/common/error.rb +26 -0
  148. data/lib/active_merchant/common/post_data.rb +24 -0
  149. data/lib/active_merchant/common/posts_data.rb +61 -0
  150. data/lib/active_merchant/common/requires_parameters.rb +16 -0
  151. data/lib/active_merchant/common/utils.rb +18 -0
  152. data/lib/active_merchant/common/validateable.rb +76 -0
  153. data/lib/active_merchant/version.rb +3 -0
  154. data/lib/activemerchant.rb +1 -0
  155. data/lib/certs/cacert.pem +7815 -0
  156. data/lib/support/gateway_support.rb +58 -0
  157. data/lib/support/outbound_hosts.rb +25 -0
  158. metadata +270 -0
@@ -0,0 +1,204 @@
1
+ require 'net/http'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ module Integrations #:nodoc:
6
+ module SagePayForm
7
+ class Notification < ActiveMerchant::Billing::Integrations::Notification
8
+ class CryptError < StandardError; end
9
+
10
+ include Encryption
11
+
12
+ def initialize(post_data, options)
13
+ super
14
+ load_crypt_params(params['crypt'], options[:credential2])
15
+ end
16
+
17
+ # Was the transaction complete?
18
+ def complete?
19
+ status_code == 'OK'
20
+ end
21
+
22
+ # Text version of #complete?, since we don't support Pending.
23
+ def status
24
+ complete? ? 'Completed' : 'Failed'
25
+ end
26
+
27
+ # Status of transaction. List of possible values:
28
+ # <tt>OK</tt>:: Transaction completed successfully.
29
+ # <tt>NOTAUTHED</tt>:: Incorrect card details / insufficient funds.
30
+ # <tt>MALFORMED</tt>:: Invalid input data.
31
+ # <tt>INVALID</tt>:: Valid input data, but some fields are incorrect.
32
+ # <tt>ABORT</tt>:: User hit cancel button or went idle for 15+ minutes.
33
+ # <tt>REJECTED</tt>:: Rejected by account fraud screening rules.
34
+ # <tt>AUTHENTICATED</tt>:: Authenticated card details secured at SagePay.
35
+ # <tt>REGISTERED</tt>:: Non-authenticated card details secured at SagePay.
36
+ # <tt>ERROR</tt>:: Problem internal to SagePay.
37
+ def status_code
38
+ params['Status']
39
+ end
40
+
41
+ # Check this if #completed? is false.
42
+ def message
43
+ params['StatusDetail']
44
+ end
45
+
46
+ # Vendor-supplied code (:order mapping).
47
+ def item_id
48
+ params['VendorTxCode']
49
+ end
50
+
51
+ # Internal SagePay code, typically "{LONG-UUID}".
52
+ def transaction_id
53
+ params['VPSTxId']
54
+ end
55
+
56
+ # Authorization number (only if #completed?).
57
+ def auth_id
58
+ params['TxAuthNo']
59
+ end
60
+
61
+ # Total amount (no fees).
62
+ def gross
63
+ params['Amount']
64
+ end
65
+
66
+ # AVS and CV2 check results. Possible values:
67
+ # <tt>ALL MATCH</tt>::
68
+ # <tt>SECURITY CODE MATCH ONLY</tt>::
69
+ # <tt>ADDRESS MATCH ONLY</tt>::
70
+ # <tt>NO DATA MATCHES</tt>::
71
+ # <tt>DATA NOT CHECKED</tt>::
72
+ def avs_cv2_result
73
+ params['AVSCV2']
74
+ end
75
+
76
+ # Numeric address check. Possible values:
77
+ # <tt>NOTPROVIDED</tt>::
78
+ # <tt>NOTCHECKED</tt>::
79
+ # <tt>MATCHED</tt>::
80
+ # <tt>NOTMATCHED</tt>::
81
+ def address_result
82
+ params['AddressResult']
83
+ end
84
+
85
+ # Post code check. Possible values:
86
+ # <tt>NOTPROVIDED</tt>::
87
+ # <tt>NOTCHECKED</tt>::
88
+ # <tt>MATCHED</tt>::
89
+ # <tt>NOTMATCHED</tt>::
90
+ def post_code_result
91
+ params['PostCodeResult']
92
+ end
93
+
94
+ # CV2 code check. Possible values:
95
+ # <tt>NOTPROVIDED</tt>::
96
+ # <tt>NOTCHECKED</tt>::
97
+ # <tt>MATCHED</tt>::
98
+ # <tt>NOTMATCHED</tt>::
99
+ def cv2_result
100
+ params['CV2Result']
101
+ end
102
+
103
+ # Was the Gift Aid box checked?
104
+ def gift_aid?
105
+ params['GiftAid'] == '1'
106
+ end
107
+
108
+ # Result of 3D Secure checks. Possible values:
109
+ # <tt>OK</tt>:: Authenticated correctly.
110
+ # <tt>NOTCHECKED</tt>:: Authentication not performed.
111
+ # <tt>NOTAVAILABLE</tt>:: Card not auth-capable, or auth is otherwise impossible.
112
+ # <tt>NOTAUTHED</tt>:: User failed authentication.
113
+ # <tt>INCOMPLETE</tt>:: Authentication unable to complete.
114
+ # <tt>ERROR</tt>:: Unable to attempt authentication due to data / service errors.
115
+ def buyer_auth_result
116
+ params['3DSecureStatus']
117
+ end
118
+
119
+ # Encoded 3D Secure result code.
120
+ def buyer_auth_result_code
121
+ params['CAVV']
122
+ end
123
+
124
+ # Address confirmation status. PayPal only. Possible values:
125
+ # <tt>NONE</tt>::
126
+ # <tt>CONFIRMED</tt>::
127
+ # <tt>UNCONFIRMED</tt>::
128
+ def address_status
129
+ params['AddressStatus']
130
+ end
131
+
132
+ # Payer verification. Undocumented.
133
+ def payer_verified?
134
+ params['PayerStatus'] == 'VERIFIED'
135
+ end
136
+
137
+ # Credit card type. Possible values:
138
+ # <tt>VISA</tt>:: Visa
139
+ # <tt>MC</tt>:: MasterCard
140
+ # <tt>DELTA</tt>:: Delta
141
+ # <tt>SOLO</tt>:: Solo
142
+ # <tt>MAESTRO</tt>:: Maestro (UK and International)
143
+ # <tt>UKE</tt>:: Visa Electron
144
+ # <tt>AMEX</tt>:: American Express
145
+ # <tt>DC</tt>:: Diners Club
146
+ # <tt>JCB</tt>:: JCB
147
+ # <tt>LASER</tt>:: Laser
148
+ # <tt>PAYPAL</tt>:: PayPal
149
+ def credit_card_type
150
+ params['CardType']
151
+ end
152
+
153
+ # Last four digits of credit card.
154
+ def credit_card_last_4_digits
155
+ params['Last4Digits']
156
+ end
157
+
158
+ # Used by composition methods, but not supplied by SagePay.
159
+ def currency
160
+ nil
161
+ end
162
+
163
+ def test?
164
+ false
165
+ end
166
+
167
+ def acknowledge
168
+ true
169
+ end
170
+
171
+ private
172
+
173
+ def load_crypt_params(crypt, key)
174
+ raise MissingCryptData if crypt.blank?
175
+ raise MissingCryptKey if key.blank?
176
+
177
+ crypt_data = sage_decrypt(crypt.gsub(' ', '+'), key)
178
+ raise InvalidCryptData unless crypt_data =~ /(^|&)Status=/
179
+
180
+ params.clear
181
+ parse(crypt_data)
182
+ end
183
+
184
+ class MissingCryptKey < CryptError
185
+ def message
186
+ 'No merchant decryption key supplied'
187
+ end
188
+ end
189
+ class MissingCryptData < CryptError
190
+ def message
191
+ 'No data received from SagePay'
192
+ end
193
+ end
194
+ class InvalidCryptData < CryptError
195
+ def message
196
+ 'Invalid data received from SagePay'
197
+ end
198
+ end
199
+
200
+ end
201
+ end
202
+ end
203
+ end
204
+ end
@@ -0,0 +1,27 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module SagePayForm
5
+ class Return < ActiveMerchant::Billing::Integrations::Return
6
+
7
+ def initialize(query_string, options)
8
+ begin
9
+ @notification = Notification.new(query_string, options)
10
+ rescue Notification::CryptError => e
11
+ @message = e.message
12
+ end
13
+ end
14
+
15
+ def success?
16
+ @notification && @notification.complete?
17
+ end
18
+
19
+ def message
20
+ @message || @notification.message
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,23 @@
1
+
2
+ module ActiveMerchant #:nodoc:
3
+ module Billing #:nodoc:
4
+ module Integrations #:nodoc:
5
+ module TwoCheckout
6
+ autoload 'Helper', File.dirname(__FILE__) + '/two_checkout/helper'
7
+ autoload 'Return', File.dirname(__FILE__) + '/two_checkout/return'
8
+ autoload 'Notification', File.dirname(__FILE__) + '/two_checkout/notification'
9
+
10
+ mattr_accessor :service_url
11
+ self.service_url = 'https://www.2checkout.com/2co/buyer/purchase'
12
+
13
+ def self.notification(post)
14
+ Notification.new(post)
15
+ end
16
+
17
+ def self.return(query_string, options = {})
18
+ Return.new(query_string)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,59 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module TwoCheckout
5
+ class Helper < ActiveMerchant::Billing::Integrations::Helper
6
+ def initialize(order, account, options = {})
7
+ super
8
+ add_field('fixed', 'Y')
9
+
10
+ if ActiveMerchant::Billing::Base.integration_mode == :test || options[:test]
11
+ add_field('demo', 'Y')
12
+ end
13
+ end
14
+
15
+ # The 2checkout vendor account number
16
+ mapping :account, 'sid'
17
+
18
+ # he total amount to be billed, in decimal form, without a currency symbol. (8 characters, decimal, 2 characters: Example: 99999999.99)
19
+ mapping :amount, 'total'
20
+
21
+ # a unique order id from your program. (128 characters max)
22
+ mapping :order, 'cart_order_id'
23
+
24
+
25
+ mapping :customer, :email => 'email',
26
+ :phone => 'phone'
27
+
28
+ mapping :billing_address, :city => 'city',
29
+ :address1 => 'street_address',
30
+ :address2 => 'street_address2',
31
+ :state => 'state',
32
+ :zip => 'zip',
33
+ :country => 'country'
34
+
35
+ mapping :shipping_address, :city => 'ship_city',
36
+ :address1 => 'ship_street_address',
37
+ :state => 'ship_state',
38
+ :zip => 'ship_zip',
39
+ :country => 'ship_country'
40
+
41
+ mapping :invoice, 'merchant_order_id'
42
+
43
+ # Does nothing, since we've disabled the Continue Shopping button by using the fixed = Y field
44
+ mapping :return_url, 'return_url'
45
+
46
+ #mapping :description, ''
47
+ #mapping :tax, ''
48
+ #mapping :shipping, ''
49
+
50
+ def customer(params = {})
51
+ add_field(mappings[:customer][:email], params[:email])
52
+ add_field(mappings[:customer][:phone], params[:phone])
53
+ add_field('card_holder_name', "#{params[:first_name]} #{params[:last_name]}")
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,114 @@
1
+ require 'net/http'
2
+ require 'base64'
3
+ require 'digest/md5'
4
+
5
+ module ActiveMerchant #:nodoc:
6
+ module Billing #:nodoc:
7
+ module Integrations #:nodoc:
8
+ module TwoCheckout
9
+ class Notification < ActiveMerchant::Billing::Integrations::Notification
10
+ # order_number 2Checkout.com order number
11
+ # card_holder_name Card holder's name
12
+ # street_address Card holder's address
13
+ # city Card holder's city
14
+ # state Card holder's state
15
+ # zip Card holder's zip
16
+ # country Card holder's country
17
+ # email Card holder's email
18
+ # phone Card holder's phone
19
+ # credit_card_processed Y if successful, K if waiting for approval
20
+ # total Total purchase amount
21
+ # ship_name Shipping information
22
+ # ship_street_address Shipping information
23
+ # ship_city Shipping information
24
+ # ship_state Shipping information
25
+ # ship_zip Shipping information
26
+ # ship_country Shipping information
27
+ # product_id 2Checkout product ID for purchased items will append a number if more than one item.
28
+ # ex. product_id,product_id1,product_id2
29
+ # quantity quantity of corresponding product will append a number if more than one item.
30
+ # ex. quantity,quantity1,quantity2
31
+ # merchant_product_id your product ID for purchased items will append a number if more than one item.
32
+ # ex. merchant_product_id,merchant_product_id1,merchant_product_id2
33
+ # product_description your description for purchased items will append a number if more than one item.
34
+ # ex. product_description,product_description1,product_description2
35
+
36
+ def currency
37
+ 'USD'
38
+ end
39
+
40
+ def complete?
41
+ status == 'Completed'
42
+ end
43
+
44
+ def item_id
45
+ params['cart_order_id']
46
+ end
47
+
48
+ def transaction_id
49
+ params['order_number']
50
+ end
51
+
52
+ def received_at
53
+ params['']
54
+ end
55
+
56
+ def payer_email
57
+ params['email']
58
+ end
59
+
60
+ def receiver_email
61
+ params['']
62
+ end
63
+
64
+ # The MD5 Hash
65
+ def security_key
66
+ params['key']
67
+ end
68
+
69
+ # the money amount we received in X.2 decimal.
70
+ def gross
71
+ params['total']
72
+ end
73
+
74
+ # Was this a test transaction? # Use the hash
75
+ def test?
76
+ params['demo'] == 'Y'
77
+ end
78
+
79
+ def status
80
+ case params['credit_card_processed']
81
+ when 'Y'
82
+ 'Completed'
83
+ when 'K'
84
+ 'Pending'
85
+ else
86
+ 'Failed'
87
+ end
88
+ end
89
+
90
+ def verify(secret)
91
+ return false if security_key.blank?
92
+
93
+ Digest::MD5.hexdigest("#{secret}#{params['sid']}#{transaction_id}#{gross}").upcase == security_key.upcase
94
+ end
95
+
96
+ def acknowledge
97
+ true
98
+ end
99
+
100
+ private
101
+
102
+ def parse(post)
103
+ @raw = post.to_s
104
+ for line in @raw.split('&')
105
+ key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten
106
+ params[key] = CGI.unescape(value || '')
107
+ end
108
+ end
109
+
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,17 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module TwoCheckout
5
+ class Return < ActiveMerchant::Billing::Integrations::Return
6
+ def success?
7
+ params['credit_card_processed'] == 'Y'
8
+ end
9
+
10
+ def message
11
+
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end