activemerchant 1.42.2 → 1.42.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/CHANGELOG +32 -0
  5. data/CONTRIBUTORS +12 -0
  6. data/README.md +3 -0
  7. data/lib/active_merchant/billing/base.rb +9 -2
  8. data/lib/active_merchant/billing/credit_card_methods.rb +1 -1
  9. data/lib/active_merchant/billing/gateway.rb +1 -1
  10. data/lib/active_merchant/billing/gateways/authorize_net.rb +3 -2
  11. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +8 -8
  12. data/lib/active_merchant/billing/gateways/balanced.rb +7 -2
  13. data/lib/active_merchant/billing/gateways/beanstream.rb +1 -1
  14. data/lib/active_merchant/billing/gateways/bogus.rb +32 -22
  15. data/lib/active_merchant/billing/gateways/braintree_blue.rb +124 -39
  16. data/lib/active_merchant/billing/gateways/cyber_source.rb +2 -2
  17. data/lib/active_merchant/billing/gateways/litle.rb +1 -1
  18. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +2 -2
  19. data/lib/active_merchant/billing/gateways/moneris.rb +1 -1
  20. data/lib/active_merchant/billing/gateways/moneris_us.rb +1 -1
  21. data/lib/active_merchant/billing/gateways/nab_transact.rb +3 -1
  22. data/lib/active_merchant/billing/gateways/netpay.rb +1 -1
  23. data/lib/active_merchant/billing/gateways/pay_junction.rb +7 -7
  24. data/lib/active_merchant/billing/gateways/payex.rb +402 -0
  25. data/lib/active_merchant/billing/gateways/payflow.rb +41 -11
  26. data/lib/active_merchant/billing/gateways/payment_express.rb +1 -1
  27. data/lib/active_merchant/billing/gateways/paymill.rb +55 -3
  28. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +1 -1
  29. data/lib/active_merchant/billing/gateways/payscout.rb +171 -0
  30. data/lib/active_merchant/billing/gateways/pin.rb +1 -1
  31. data/lib/active_merchant/billing/gateways/realex.rb +1 -1
  32. data/lib/active_merchant/billing/gateways/redsys.rb +1 -1
  33. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
  34. data/lib/active_merchant/billing/gateways/stripe.rb +23 -25
  35. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +26 -15
  36. data/lib/active_merchant/billing/gateways/webpay.rb +27 -11
  37. data/lib/active_merchant/billing/gateways/wirecard.rb +1 -1
  38. data/lib/active_merchant/billing/integrations/bit_pay/helper.rb +1 -1
  39. data/lib/active_merchant/billing/integrations/ipay88.rb +4 -0
  40. data/lib/active_merchant/billing/integrations/ipay88/helper.rb +1 -1
  41. data/lib/active_merchant/billing/integrations/ipay88/notification.rb +103 -0
  42. data/lib/active_merchant/billing/integrations/ipay88/return.rb +8 -74
  43. data/lib/active_merchant/billing/integrations/pay_fast/notification.rb +1 -1
  44. data/lib/active_merchant/billing/integrations/paypal/helper.rb +1 -1
  45. data/lib/active_merchant/billing/integrations/payu_in.rb +2 -9
  46. data/lib/active_merchant/billing/integrations/payu_in/helper.rb +15 -13
  47. data/lib/active_merchant/billing/integrations/payu_in/notification.rb +9 -20
  48. data/lib/active_merchant/billing/integrations/payu_in_paisa/helper.rb +1 -1
  49. data/lib/active_merchant/billing/integrations/payu_in_paisa/notification.rb +0 -10
  50. data/lib/active_merchant/billing/integrations/payu_in_paisa/return.rb +1 -1
  51. data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +1 -1
  52. data/lib/active_merchant/billing/integrations/valitor/helper.rb +3 -3
  53. data/lib/active_merchant/billing/integrations/valitor/response_fields.rb +2 -2
  54. data/lib/active_merchant/billing/integrations/verkkomaksut/notification.rb +1 -1
  55. data/lib/active_merchant/billing/integrations/wirecard_checkout_page.rb +1 -1
  56. data/lib/active_merchant/billing/integrations/world_pay/helper.rb +2 -2
  57. data/lib/active_merchant/version.rb +1 -1
  58. metadata +7 -3
  59. metadata.gz.sig +0 -0
@@ -40,7 +40,7 @@ module ActiveMerchant #:nodoc:
40
40
  post = create_post_for_auth_or_purchase(money, creditcard, options)
41
41
  post[:capture] = "false"
42
42
 
43
- commit(:post, 'charges', post, generate_options(options))
43
+ commit(:post, 'charges', post, options)
44
44
  end
45
45
 
46
46
  # To create a charge on a card or a token, call
@@ -53,31 +53,30 @@ module ActiveMerchant #:nodoc:
53
53
  def purchase(money, creditcard, options = {})
54
54
  post = create_post_for_auth_or_purchase(money, creditcard, options)
55
55
 
56
- commit(:post, 'charges', post, generate_options(options))
56
+ commit(:post, 'charges', post, options)
57
57
  end
58
58
 
59
59
  def capture(money, authorization, options = {})
60
60
  post = {:amount => amount(money)}
61
61
  add_application_fee(post, options)
62
62
 
63
- commit(:post, "charges/#{CGI.escape(authorization)}/capture", post)
63
+ commit(:post, "charges/#{CGI.escape(authorization)}/capture", post, options)
64
64
  end
65
65
 
66
66
  def void(identification, options = {})
67
- commit(:post, "charges/#{CGI.escape(identification)}/refund", {})
67
+ commit(:post, "charges/#{CGI.escape(identification)}/refund", {}, options)
68
68
  end
69
69
 
70
70
  def refund(money, identification, options = {})
71
71
  post = {:amount => amount(money)}
72
- commit_options = generate_options(options)
73
72
 
74
73
  MultiResponse.run(:first) do |r|
75
- r.process { commit(:post, "charges/#{CGI.escape(identification)}/refund", post, commit_options) }
74
+ r.process { commit(:post, "charges/#{CGI.escape(identification)}/refund", post, options) }
76
75
 
77
76
  return r unless options[:refund_fee_amount]
78
77
 
79
- r.process { fetch_application_fees(identification, commit_options) }
80
- r.process { refund_application_fee(options[:refund_fee_amount], application_fee_from_response(r), commit_options) }
78
+ r.process { fetch_application_fees(identification, options) }
79
+ r.process { refund_application_fee(options[:refund_fee_amount], application_fee_from_response(r), options) }
81
80
  end
82
81
  end
83
82
 
@@ -104,17 +103,16 @@ module ActiveMerchant #:nodoc:
104
103
  post[:description] = options[:description]
105
104
  post[:email] = options[:email]
106
105
 
107
- commit_options = generate_options(options)
108
106
  if options[:customer]
109
107
  MultiResponse.run(:first) do |r|
110
- r.process { commit(:post, "customers/#{CGI.escape(options[:customer])}/cards", post, commit_options) }
108
+ r.process { commit(:post, "customers/#{CGI.escape(options[:customer])}/cards", post, options) }
111
109
 
112
110
  return r unless options[:set_default] and r.success? and !r.params["id"].blank?
113
111
 
114
112
  r.process { update_customer(options[:customer], :default_card => r.params["id"]) }
115
113
  end
116
114
  else
117
- commit(:post, 'customers', post, commit_options)
115
+ commit(:post, 'customers', post, options)
118
116
  end
119
117
  end
120
118
 
@@ -124,14 +122,14 @@ module ActiveMerchant #:nodoc:
124
122
  end
125
123
 
126
124
  def update_customer(customer_id, options = {})
127
- commit(:post, "customers/#{CGI.escape(customer_id)}", options, generate_options(options))
125
+ commit(:post, "customers/#{CGI.escape(customer_id)}", options, options)
128
126
  end
129
127
 
130
128
  def unstore(customer_id, card_id = nil, options = {})
131
129
  if card_id.nil?
132
- commit(:delete, "customers/#{CGI.escape(customer_id)}", nil, generate_options(options))
130
+ commit(:delete, "customers/#{CGI.escape(customer_id)}", nil, options)
133
131
  else
134
- commit(:delete, "customers/#{CGI.escape(customer_id)}/cards/#{CGI.escape(card_id)}", nil, generate_options(options))
132
+ commit(:delete, "customers/#{CGI.escape(customer_id)}/cards/#{CGI.escape(card_id)}", nil, options)
135
133
  end
136
134
  end
137
135
 
@@ -143,7 +141,8 @@ module ActiveMerchant #:nodoc:
143
141
  add_creditcard(post, creditcard, options)
144
142
  add_customer(post, creditcard, options)
145
143
  add_customer_data(post,options)
146
- post[:description] = options[:description] || options[:email]
144
+ post[:description] = options[:description]
145
+ post[:metadata] = { email: options[:email] } if options[:email]
147
146
  add_flags(post, options)
148
147
  add_application_fee(post, options)
149
148
  post
@@ -158,6 +157,10 @@ module ActiveMerchant #:nodoc:
158
157
  post[:application_fee] = options[:application_fee] if options[:application_fee]
159
158
  end
160
159
 
160
+ def add_expand_parameters(post, options)
161
+ post[:expand] = Array.wrap(options[:expand])
162
+ end
163
+
161
164
  def add_customer_data(post, options)
162
165
  metadata_options = [:description, :ip, :user_agent, :referrer]
163
166
  post.update(options.slice(*metadata_options))
@@ -232,21 +235,14 @@ module ActiveMerchant #:nodoc:
232
235
  h["#{key}[#{k}]"] = v unless v.blank?
233
236
  end
234
237
  post_data(h)
238
+ elsif value.is_a?(Array)
239
+ value.map { |v| "#{key}[]=#{CGI.escape(v.to_s)}" }.join("&")
235
240
  else
236
241
  "#{key}=#{CGI.escape(value.to_s)}"
237
242
  end
238
243
  end.compact.join("&")
239
244
  end
240
245
 
241
- def generate_options(raw_options)
242
- options = generate_meta(raw_options)
243
- options.merge!(raw_options.slice(:version))
244
- end
245
-
246
- def generate_meta(options)
247
- {:meta => {:ip => options[:ip]}}
248
- end
249
-
250
246
  def headers(options = {})
251
247
  @@ua ||= JSON.dump({
252
248
  :bindings_version => ActiveMerchant::VERSION,
@@ -262,13 +258,15 @@ module ActiveMerchant #:nodoc:
262
258
  "Authorization" => "Basic " + Base64.encode64(key.to_s + ":").strip,
263
259
  "User-Agent" => "Stripe/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
264
260
  "X-Stripe-Client-User-Agent" => @@ua,
265
- "X-Stripe-Client-User-Metadata" => options[:meta].to_json
261
+ "X-Stripe-Client-User-Metadata" => {:ip => options[:ip]}.to_json
266
262
  }
267
263
  headers.merge!("Stripe-Version" => options[:version]) if options[:version]
268
264
  headers
269
265
  end
270
266
 
271
267
  def commit(method, url, parameters=nil, options = {})
268
+ add_expand_parameters(parameters, options) if parameters
269
+
272
270
  raw_response = response = nil
273
271
  success = false
274
272
  begin
@@ -179,7 +179,6 @@ module ActiveMerchant #:nodoc:
179
179
  } #:nodoc:
180
180
 
181
181
  CHECK_DATA_OPTIONS = {
182
- :check_number => [:integer, 'CheckNumber'],
183
182
  :drivers_license => [:string, 'DriversLicense'],
184
183
  :drivers_license_state => [:string, 'DriversLicenseState'],
185
184
  :record_type => [:string, 'RecordType'],
@@ -339,9 +338,10 @@ module ActiveMerchant #:nodoc:
339
338
  commit(__method__, request)
340
339
  end
341
340
 
342
- # Update a customer by replacing all of the customer details..
341
+ # Update a customer by replacing all of the customer details.
343
342
  #
344
- # Use quickUpdateCustomer to just update a few attributes.
343
+ # ==== Required
344
+ # * <tt>:customer_number</tt> -- customer to update
345
345
  #
346
346
  # ==== Options
347
347
  # * Same as add_customer
@@ -355,7 +355,7 @@ module ActiveMerchant #:nodoc:
355
355
 
356
356
  # Enable a customer for recurring billing.
357
357
  #
358
- # Note: Customer does not need to have all recurring paramerters to succeed.
358
+ # Note: Customer does not need to have all recurring parameters to succeed.
359
359
  #
360
360
  # ==== Required
361
361
  # * <tt>:customer_number</tt>
@@ -454,7 +454,7 @@ module ActiveMerchant #:nodoc:
454
454
  commit(__method__, request)
455
455
  end
456
456
 
457
- # Delete one the payment methods beloning to a customer
457
+ # Delete one the payment methods belonging to a customer
458
458
  #
459
459
  # ==== Required
460
460
  # * <tt>:customer_number</tt>
@@ -543,11 +543,11 @@ module ActiveMerchant #:nodoc:
543
543
  # will be returned in the response.
544
544
  #
545
545
  # ==== Options
546
- # * <tt>:method</tt> -- credit_card or check
546
+ # * <tt>:payment_method</tt> -- credit_card or check
547
547
  # * <tt>:command</tt> -- sale, credit, void, creditvoid, authonly, capture, postauth, check, checkcredit; defaults to sale; only required for run_transaction when other than sale
548
548
  # * <tt>:reference_number</tt> -- for the original transaction; obtained by sale or authonly
549
549
  # * <tt>:authorization_code</tt> -- required for postauth; obtained offline
550
- # * <tt>:ignore_duplicate</tt> -- set +true+ if you want to override the duplicate tranaction handling
550
+ # * <tt>:ignore_duplicate</tt> -- set +true+ if you want to override the duplicate transaction handling
551
551
  # * <tt>:account_holder</tt> -- name of account holder
552
552
  # * <tt>:customer_id</tt> -- merchant assigned id
553
553
  # * <tt>:customer_receipt</tt> -- set +true+ to email receipt to billing email address
@@ -680,7 +680,7 @@ module ActiveMerchant #:nodoc:
680
680
  commit(__method__, request)
681
681
  end
682
682
 
683
- # Override transaction flagged for mananager approval.
683
+ # Override transaction flagged for manager approval.
684
684
  #
685
685
  # Note: Checks only!
686
686
  #
@@ -1166,7 +1166,7 @@ module ActiveMerchant #:nodoc:
1166
1166
  soap.tag! "ns1:captureTransaction" do |soap|
1167
1167
  build_token soap, options
1168
1168
  build_tag soap, :integer, 'RefNum', options[:reference_number]
1169
- build_tag soap, :double, 'RefNum', amount(options[:amount])
1169
+ build_tag soap, :double, 'Amount', amount(options[:amount])
1170
1170
  end
1171
1171
  end
1172
1172
 
@@ -1244,16 +1244,18 @@ module ActiveMerchant #:nodoc:
1244
1244
  when payment_method[:method].kind_of?(ActiveMerchant::Billing::CreditCard)
1245
1245
  build_tag soap, :string, 'CardNumber', payment_method[:method].number
1246
1246
  build_tag soap, :string, 'CardExpiration',
1247
- "#{"%02d" % payment_method[:method].month}#{payment_method[:method].year}"
1247
+ "#{"%02d" % payment_method[:method].month}#{payment_method[:method].year.to_s[-2..-1]}"
1248
1248
  if options[:billing_address]
1249
1249
  build_tag soap, :string, 'AvsStreet', options[:billing_address][:address1]
1250
1250
  build_tag soap, :string, 'AvsZip', options[:billing_address][:zip]
1251
1251
  end
1252
1252
  build_tag soap, :string, 'CardCode', payment_method[:method].verification_value
1253
1253
  when payment_method[:method].kind_of?(ActiveMerchant::Billing::Check)
1254
- build_tag soap, :string, 'Account', payment_method[:method].number
1254
+ build_tag soap, :string, 'Account', payment_method[:method].account_number
1255
1255
  build_tag soap, :string, 'Routing', payment_method[:method].routing_number
1256
- build_tag soap, :string, 'AccountType', payment_method[:method].account_type.capitalize
1256
+ unless payment_method[:method].account_type.nil?
1257
+ build_tag soap, :string, 'AccountType', payment_method[:method].account_type.capitalize
1258
+ end
1257
1259
  build_tag soap, :string, 'DriversLicense', options[:drivers_license]
1258
1260
  build_tag soap, :string, 'DriversLicenseState', options[:drivers_license_state]
1259
1261
  build_tag soap, :string, 'RecordType', options[:record_type]
@@ -1323,8 +1325,7 @@ module ActiveMerchant #:nodoc:
1323
1325
  def build_credit_card_data(soap, options)
1324
1326
  soap.CreditCardData 'xsi:type' => "ns1:CreditCardData" do |soap|
1325
1327
  build_tag soap, :string, 'CardNumber', options[:payment_method].number
1326
- build_tag soap, :string, 'CardExpiration',
1327
- "#{"%02d" % options[:payment_method].month}#{options[:payment_method].year}"
1328
+ build_tag soap, :string, 'CardExpiration', build_card_expiration(options)
1328
1329
  if options[:billing_address]
1329
1330
  build_tag soap, :string, 'AvsStreet', options[:billing_address][:address1]
1330
1331
  build_tag soap, :string, 'AvsZip', options[:billing_address][:zip]
@@ -1337,8 +1338,17 @@ module ActiveMerchant #:nodoc:
1337
1338
  end
1338
1339
  end
1339
1340
 
1341
+ def build_card_expiration(options)
1342
+ month = options[:payment_method].month
1343
+ year = options[:payment_method].year
1344
+ unless month.nil? || year.nil?
1345
+ "#{"%02d" % month}#{year.to_s[-2..-1]}"
1346
+ end
1347
+ end
1348
+
1340
1349
  def build_check_data(soap, options)
1341
1350
  soap.CheckData 'xsi:type' => "ns1:CheckData" do |soap|
1351
+ build_tag soap, :integer, 'CheckNumber', options[:payment_method].number
1342
1352
  build_tag soap, :string, 'Account', options[:payment_method].account_number
1343
1353
  build_tag soap, :string, 'Routing', options[:payment_method].routing_number
1344
1354
  build_tag soap, :string, 'AccountType', options[:payment_method].account_type.capitalize
@@ -1461,7 +1471,8 @@ module ActiveMerchant #:nodoc:
1461
1471
  when :get_customer_payment_methods
1462
1472
  p['item']
1463
1473
  when :get_transaction_custom
1464
- p['item'].inject({}) { |map, field| map[field['field']] = field['value']; map }
1474
+ items = p['item'].kind_of?(Array) ? p['item'] : [p['item']]
1475
+ items.inject({}) { |hash, item| hash[item['field']] = item['value']; hash }
1465
1476
  else
1466
1477
  p
1467
1478
  end
@@ -13,25 +13,22 @@ module ActiveMerchant #:nodoc:
13
13
  self.homepage_url = 'https://webpay.jp/'
14
14
  self.display_name = 'WebPay'
15
15
 
16
- def authorize(money, credit_card, options = {})
17
- raise NotImplementedError.new
18
- end
19
-
20
- def capture(money, credit_card, options = {})
21
- raise NotImplementedError.new
16
+ def capture(money, authorization, options = {})
17
+ post = {:amount => localized_amount(money)}
18
+ add_application_fee(post, options)
19
+ commit(:post, "charges/#{CGI.escape(authorization)}/capture", post)
22
20
  end
23
21
 
24
22
  def refund(money, identification, options = {})
25
23
  post = {:amount => localized_amount(money)}
26
- commit_options = generate_meta(options)
27
24
 
28
25
  MultiResponse.run do |r|
29
- r.process { commit(:post, "charges/#{CGI.escape(identification)}/refund", post, commit_options) }
26
+ r.process { commit(:post, "charges/#{CGI.escape(identification)}/refund", post, options) }
30
27
 
31
28
  return r unless options[:refund_fee_amount]
32
29
 
33
- r.process { fetch_application_fees(identification, commit_options) }
34
- r.process { refund_application_fee(options[:refund_fee_amount], application_fee_from_response(r), commit_options) }
30
+ r.process { fetch_application_fees(identification, options) }
31
+ r.process { refund_application_fee(options[:refund_fee_amount], application_fee_from_response(r), options) }
35
32
  end
36
33
  end
37
34
 
@@ -52,6 +49,25 @@ module ActiveMerchant #:nodoc:
52
49
  post[:customer] = options[:customer] if options[:customer] && !creditcard.respond_to?(:number)
53
50
  end
54
51
 
52
+ def store(creditcard, options = {})
53
+ post = {}
54
+ add_creditcard(post, creditcard, options)
55
+ post[:description] = options[:description]
56
+ post[:email] = options[:email]
57
+
58
+ if options[:customer]
59
+ MultiResponse.run(:first) do |r|
60
+ r.process { commit(:post, "customers/#{CGI.escape(options[:customer])}/", post, options) }
61
+
62
+ return r unless options[:set_default] and r.success? and !r.params["id"].blank?
63
+
64
+ r.process { update_customer(options[:customer], :default_card => r.params["id"]) }
65
+ end
66
+ else
67
+ commit(:post, 'customers', post, options)
68
+ end
69
+ end
70
+
55
71
  def json_error(raw_response)
56
72
  msg = 'Invalid response received from the WebPay API. Please contact support@webpay.jp if you continue to receive this message.'
57
73
  msg += " (The raw response returned by the API was #{raw_response.inspect})"
@@ -75,7 +91,7 @@ module ActiveMerchant #:nodoc:
75
91
  "Authorization" => "Basic " + Base64.encode64(@api_key.to_s + ":").strip,
76
92
  "User-Agent" => "Webpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
77
93
  "X-Webpay-Client-User-Agent" => @@ua,
78
- "X-Webpay-Client-User-Metadata" => options[:meta].to_json
94
+ "X-Webpay-Client-User-Metadata" => {:ip => options[:ip]}.to_json
79
95
  }
80
96
  end
81
97
  end
@@ -232,7 +232,7 @@ module ActiveMerchant #:nodoc:
232
232
  response
233
233
  end
234
234
 
235
- # Parse the <ProcessingStatus> Element which containts all important information
235
+ # Parse the <ProcessingStatus> Element which contains all important information
236
236
  def parse_response(response, root)
237
237
  status = nil
238
238
  # get the root element for this Transaction
@@ -55,7 +55,7 @@ module ActiveMerchant #:nodoc:
55
55
 
56
56
  response = http.request(request)
57
57
  JSON.parse(response.body)
58
- rescue JSON::ParseError
58
+ rescue JSON::ParserError
59
59
  end
60
60
  end
61
61
  end
@@ -10,6 +10,10 @@ module ActiveMerchant #:nodoc:
10
10
  "https://www.mobile88.com/epayment/entry.asp"
11
11
  end
12
12
 
13
+ def self.requery_url
14
+ "https://www.mobile88.com/epayment/enquiry.asp"
15
+ end
16
+
13
17
  def self.return(query_string, options={})
14
18
  Return.new(query_string, options)
15
19
  end
@@ -107,7 +107,7 @@ module ActiveMerchant #:nodoc:
107
107
  components = [merchant_key]
108
108
  components << fields[mappings[:account]]
109
109
  components << fields[mappings[:order]]
110
- components << amount_in_dollars.to_s.gsub(/0+$/, '').gsub(/[.,]/, '')
110
+ components << amount_in_dollars.gsub(/[.,]/, '')
111
111
  components << fields[mappings[:currency]]
112
112
  components.join
113
113
  end
@@ -0,0 +1,103 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Ipay88
5
+ class Notification < ActiveMerchant::Billing::Integrations::Notification
6
+ include ActiveMerchant::PostsData
7
+
8
+ def status
9
+ params["Status"] == '1' ? 'Completed' : 'Failed'
10
+ end
11
+
12
+ def complete?
13
+ status == 'Completed'
14
+ end
15
+
16
+ def item_id
17
+ params["RefNo"]
18
+ end
19
+
20
+ def gross
21
+ params["Amount"]
22
+ end
23
+
24
+ def currency
25
+ params["Currency"]
26
+ end
27
+
28
+ def account
29
+ params["MerchantCode"]
30
+ end
31
+
32
+ def payment
33
+ params["PaymentId"].to_i
34
+ end
35
+
36
+ def remark
37
+ params["Remark"]
38
+ end
39
+
40
+ def transaction_id
41
+ params["TransId"]
42
+ end
43
+
44
+ def auth_code
45
+ params["AuthCode"]
46
+ end
47
+
48
+ def error
49
+ params["ErrDesc"]
50
+ end
51
+
52
+ def signature
53
+ params["Signature"]
54
+ end
55
+
56
+ def secure?
57
+ generated_signature == signature
58
+ end
59
+
60
+ def success?
61
+ status == 'Completed'
62
+ end
63
+
64
+ def acknowledge
65
+ secure? && success? && requery == "00"
66
+ end
67
+
68
+ protected
69
+
70
+ def generated_signature
71
+ Helper.sign(sig_components)
72
+ end
73
+
74
+ def sig_components
75
+ components = [@options[:credential2]]
76
+ [:account, :payment, :item_id, :amount_in_cents, :currency].each do |i|
77
+ components << send(i)
78
+ end
79
+ components << params["Status"]
80
+ components.join
81
+ end
82
+
83
+ def requery
84
+ data = { "MerchantCode" => account, "RefNo" => item_id, "Amount" => gross }
85
+ params = parameterize(data)
86
+ ssl_post Ipay88.requery_url, params, { "Content-Length" => params.size.to_s, "User-Agent" => "Active Merchant -- http://activemerchant.org" }
87
+ end
88
+
89
+ private
90
+
91
+ def parameterize(params)
92
+ params.reject { |k, v| v.blank? }.keys.sort.collect { |key| "#{key}=#{CGI.escape(params[key].to_s)}" }.join("&")
93
+ end
94
+
95
+ def amount_in_cents
96
+ @amount_in_cents ||= (gross || "").gsub(/[.,]/, "")
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
103
+