activemerchant 1.32.1 → 1.33.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +41 -0
  3. data/CONTRIBUTORS +8 -0
  4. data/README.md +6 -4
  5. data/lib/active_merchant/billing/check.rb +4 -3
  6. data/lib/active_merchant/billing/credit_card.rb +7 -3
  7. data/lib/active_merchant/billing/gateways/authorize_net.rb +27 -7
  8. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +8 -1
  9. data/lib/active_merchant/billing/gateways/blue_pay.rb +201 -185
  10. data/lib/active_merchant/billing/gateways/bogus.rb +1 -1
  11. data/lib/active_merchant/billing/gateways/card_stream_modern.rb +155 -0
  12. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +94 -12
  13. data/lib/active_merchant/billing/gateways/litle.rb +41 -11
  14. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +27 -6
  15. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +2 -2
  16. data/lib/active_merchant/billing/gateways/net_registry.rb +8 -3
  17. data/lib/active_merchant/billing/gateways/netaxept.rb +65 -117
  18. data/lib/active_merchant/billing/gateways/orbital.rb +181 -48
  19. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +12 -10
  20. data/lib/active_merchant/billing/gateways/paymill.rb +5 -5
  21. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +11 -6
  22. data/lib/active_merchant/billing/gateways/paypal_express.rb +25 -7
  23. data/lib/active_merchant/billing/gateways/pin.rb +5 -5
  24. data/lib/active_merchant/billing/gateways/sage.rb +10 -5
  25. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +16 -11
  26. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +1 -1
  27. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +21 -16
  28. data/lib/active_merchant/billing/gateways/sage_pay.rb +1 -0
  29. data/lib/active_merchant/billing/gateways/transnational.rb +239 -0
  30. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +8 -3
  31. data/lib/active_merchant/billing/integrations/direc_pay.rb +1 -1
  32. data/lib/active_merchant/billing/integrations/direc_pay/status.rb +1 -1
  33. data/lib/active_merchant/billing/integrations/dwolla.rb +5 -12
  34. data/lib/active_merchant/billing/integrations/dwolla/common.rb +21 -0
  35. data/lib/active_merchant/billing/integrations/dwolla/helper.rb +15 -6
  36. data/lib/active_merchant/billing/integrations/dwolla/notification.rb +11 -6
  37. data/lib/active_merchant/billing/integrations/dwolla/return.rb +12 -4
  38. data/lib/active_merchant/billing/integrations/notification.rb +13 -8
  39. data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +13 -1
  40. data/lib/active_merchant/billing/integrations/payu_in.rb +43 -0
  41. data/lib/active_merchant/billing/integrations/payu_in/helper.rb +74 -0
  42. data/lib/active_merchant/billing/integrations/payu_in/notification.rb +167 -0
  43. data/lib/active_merchant/billing/integrations/payu_in/return.rb +53 -0
  44. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +68 -5
  45. data/lib/active_merchant/billing/integrations/rbkmoney.rb +17 -0
  46. data/lib/active_merchant/billing/integrations/rbkmoney/helper.rb +23 -0
  47. data/lib/active_merchant/billing/integrations/rbkmoney/notification.rb +91 -0
  48. data/lib/active_merchant/version.rb +1 -1
  49. metadata +14 -4
  50. metadata.gz.sig +0 -0
@@ -283,14 +283,19 @@ module ActiveMerchant #:nodoc:
283
283
  void_transaction(options.merge!(:reference_number => identification))
284
284
  end
285
285
 
286
- # Credit a previous transaction.
286
+ # Refund a previous transaction.
287
287
  #
288
288
  # Note: See run_transaction for additional options.
289
289
  #
290
- def credit(money, identification, options={})
290
+ def refund(money, identification, options={})
291
291
  refund_transaction(options.merge!(:amount => money, :reference_number => identification))
292
292
  end
293
293
 
294
+ def credit(money, identification, options={})
295
+ deprecated CREDIT_DEPRECATION_MESSAGE
296
+ refund(money, identification, options)
297
+ end
298
+
294
299
  # Customer ======================================================
295
300
 
296
301
  # Add a customer.
@@ -1334,7 +1339,7 @@ module ActiveMerchant #:nodoc:
1334
1339
 
1335
1340
  def build_check_data(soap, options)
1336
1341
  soap.CheckData 'xsi:type' => "ns1:CheckData" do |soap|
1337
- build_tag soap, :string, 'Account', options[:payment_method].number
1342
+ build_tag soap, :string, 'Account', options[:payment_method].account_number
1338
1343
  build_tag soap, :string, 'Routing', options[:payment_method].routing_number
1339
1344
  build_tag soap, :string, 'AccountType', options[:payment_method].account_type.capitalize
1340
1345
  CHECK_DATA_OPTIONS.each do |k,v|
@@ -10,7 +10,7 @@ module ActiveMerchant #:nodoc:
10
10
  mattr_accessor :production_url, :test_url
11
11
 
12
12
  self.production_url = "https://www.timesofmoney.com/direcpay/secure/dpMerchantTransaction.jsp"
13
- self.test_url = "https://test.timesofmoney.com/direcpay/secure/dpMerchantTransaction.jsp"
13
+ self.test_url = "https://test.direcpay.com/direcpay/secure/dpMerchantTransaction.jsp"
14
14
 
15
15
  def self.service_url
16
16
  mode = ActiveMerchant::Billing::Base.integration_mode
@@ -6,7 +6,7 @@ module ActiveMerchant #:nodoc:
6
6
  class Status
7
7
  include PostsData
8
8
 
9
- STATUS_TEST_URL = 'https://test.timesofmoney.com/direcpay/secure/dpPullMerchAtrnDtls.jsp'
9
+ STATUS_TEST_URL = 'https://test.direcpay.com/direcpay/secure/dpMerchantTransaction.jsp'
10
10
  STATUS_LIVE_URL = 'https://www.timesofmoney.com/direcpay/secure/dpPullMerchAtrnDtls.jsp'
11
11
 
12
12
  attr_reader :account, :options
@@ -1,28 +1,21 @@
1
- # All mappings in helper.rb are required fields to be sent to Dwolla.
2
- # :account = 'Dwolla Id of merchant'
3
- # :credential1 = 'key from Dwolla Application'
4
- # :credential2 = 'secret from Dwolla Application'
5
- # :redirect_url = 'can be different that what is specified on Dwolla Application creation'
6
- # :return_url = 'can be different that what is specified on Dwolla Application creation'
7
- # :order_id = must be unique for each transaction
8
-
9
1
  module ActiveMerchant #:nodoc:
10
2
  module Billing #:nodoc:
11
3
  module Integrations #:nodoc:
12
- module Dwolla
4
+ module Dwolla
13
5
  autoload :Return, 'active_merchant/billing/integrations/dwolla/return.rb'
14
6
  autoload :Helper, 'active_merchant/billing/integrations/dwolla/helper.rb'
15
7
  autoload :Notification, 'active_merchant/billing/integrations/dwolla/notification.rb'
16
-
8
+ autoload :Common, 'active_merchant/billing/integrations/dwolla/common.rb'
9
+
17
10
  mattr_accessor :service_url
18
11
  self.service_url = 'https://www.dwolla.com/payment/pay'
19
12
 
20
13
  def self.notification(post, options={})
21
- Notification.new(post)
14
+ Notification.new(post, options)
22
15
  end
23
16
 
24
17
  def self.return(query_string, options={})
25
- Return.new(query_string)
18
+ Return.new(query_string, options)
26
19
  end
27
20
  end
28
21
  end
@@ -0,0 +1,21 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Dwolla
5
+ module Common
6
+ def verify_signature(checkoutId, amount, notification_signature, secret)
7
+ if secret.nil?
8
+ raise ArgumentError, "You need to provide the Application secret as the option :credential3 to verify that the notification originated from Dwolla"
9
+ end
10
+
11
+ expected_signature = Digest::SHA1.hexdigest(secret + ('%s&%.2f' % [checkoutId, amount]))
12
+
13
+ if notification_signature != expected_signature
14
+ raise StandardError, "Dwolla signature verification failed."
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,29 +1,38 @@
1
+ require 'digest/sha1'
2
+
1
3
  module ActiveMerchant #:nodoc:
2
4
  module Billing #:nodoc:
3
5
  module Integrations #:nodoc:
4
6
  module Dwolla
5
7
  class Helper < ActiveMerchant::Billing::Integrations::Helper
6
-
7
8
  def initialize(order, account, options = {})
8
9
  super
9
10
  add_field('name', 'Store Purchase')
10
11
 
11
12
  if ActiveMerchant::Billing::Base.integration_mode == :test || options[:test]
12
13
  add_field('test', 'true')
13
- end
14
+ end
15
+
16
+ timestamp = Time.now.to_i.to_s
17
+ add_field('timestamp', timestamp)
18
+ add_field('allowFundingSources', 'true')
19
+
20
+ key = options[:credential2].to_s
21
+ secret = options[:credential3].to_s
22
+ orderid = order.to_s
23
+ signature = Digest::SHA1.hexdigest(secret + "#{key}&#{timestamp}&#{orderid}")
24
+ add_field('signature', signature)
14
25
  end
15
-
16
- # Replace with the real mapping
26
+
17
27
  mapping :account, 'destinationid'
18
28
  mapping :credential2, 'key'
19
- mapping :credential3, 'secret'
20
29
  mapping :notify_url, 'callback'
21
30
  mapping :return_url, 'redirect'
22
31
  mapping :description, 'description'
23
32
  mapping :amount, 'amount'
24
33
  mapping :tax, 'tax'
25
34
  mapping :shipping, 'shipping'
26
- mapping :order, 'orderid'
35
+ mapping :order, 'orderid'
27
36
  end
28
37
  end
29
38
  end
@@ -1,12 +1,15 @@
1
1
  require 'net/http'
2
+ require 'digest/sha1'
2
3
 
3
4
  module ActiveMerchant #:nodoc:
4
5
  module Billing #:nodoc:
5
6
  module Integrations #:nodoc:
6
7
  module Dwolla
7
8
  class Notification < ActiveMerchant::Billing::Integrations::Notification
9
+ include Common
10
+
8
11
  def complete?
9
- status == "Completed"
12
+ (status == "Completed")
10
13
  end
11
14
 
12
15
  def status
@@ -30,22 +33,24 @@ module ActiveMerchant #:nodoc:
30
33
  end
31
34
 
32
35
  def error
33
- params['Message']
36
+ params['Error']
34
37
  end
35
38
 
36
- # Was this a test transaction?
37
39
  def test?
38
40
  params['TestMode']
39
41
  end
40
42
 
41
- def acknowledge
43
+ def acknowledge
42
44
  true
43
45
  end
44
- private
45
- # Take the posted data and move the relevant data into a hash
46
+
47
+ private
48
+
46
49
  def parse(post)
47
50
  @raw = post.to_s
48
51
  json_post = JSON.parse(post)
52
+ verify_signature(json_post['CheckoutId'], json_post['Amount'], json_post['Signature'], @options[:credential3])
53
+
49
54
  params.merge!(json_post)
50
55
  end
51
56
  end
@@ -3,9 +3,17 @@ module ActiveMerchant #:nodoc:
3
3
  module Integrations #:nodoc:
4
4
  module Dwolla
5
5
  class Return < ActiveMerchant::Billing::Integrations::Return
6
+ include Common
7
+
8
+ def initialize(data, options)
9
+ params = parse(data)
10
+ verify_signature(params['checkoutId'], params['amount'], params['signature'], options[:credential3])
11
+
12
+ super
13
+ end
6
14
 
7
15
  def success?
8
- self.error.nil? && self.callback_success?
16
+ (self.error.nil? && self.callback_success?)
9
17
  end
10
18
 
11
19
  def error
@@ -17,7 +25,7 @@ module ActiveMerchant #:nodoc:
17
25
  end
18
26
 
19
27
  def checkout_id
20
- params['checkoutid']
28
+ params['checkoutId']
21
29
  end
22
30
 
23
31
  def transaction
@@ -29,9 +37,9 @@ module ActiveMerchant #:nodoc:
29
37
  end
30
38
 
31
39
  def callback_success?
32
- params['postback'] != "failure"
40
+ (params['postback'] != "failure")
33
41
  end
34
- end
42
+ end
35
43
  end
36
44
  end
37
45
  end
@@ -4,10 +4,15 @@ module ActiveMerchant #:nodoc:
4
4
  class Notification
5
5
  attr_accessor :params
6
6
  attr_accessor :raw
7
-
8
- # set this to an array in the subclass, to specify which IPs are allowed to send requests
7
+
8
+ # set this to an array in the subclass, to specify which IPs are allowed
9
+ # to send requests
9
10
  class_attribute :production_ips
10
11
 
12
+ # * *Args* :
13
+ # - +doc+ -> raw post string
14
+ # - +options+ -> custom options which individual implementations can
15
+ # utilize
11
16
  def initialize(post, options = {})
12
17
  @options = options
13
18
  empty!
@@ -27,19 +32,19 @@ module ActiveMerchant #:nodoc:
27
32
  (gross.to_f * 100.0).round
28
33
  end
29
34
 
30
- # This combines the gross and currency and returns a proper Money object.
35
+ # This combines the gross and currency and returns a proper Money object.
31
36
  # this requires the money library located at http://dist.leetsoft.com/api/money
32
37
  def amount
33
38
  return Money.new(gross_cents, currency) rescue ArgumentError
34
39
  return Money.new(gross_cents) # maybe you have an own money object which doesn't take a currency?
35
40
  end
36
41
 
37
- # reset the notification.
42
+ # reset the notification.
38
43
  def empty!
39
44
  @params = Hash.new
40
- @raw = ""
45
+ @raw = ""
41
46
  end
42
-
47
+
43
48
  # Check if the request comes from an official IP
44
49
  def valid_sender?(ip)
45
50
  return true if ActiveMerchant::Billing::Base.integration_mode == :test || production_ips.blank?
@@ -49,13 +54,13 @@ module ActiveMerchant #:nodoc:
49
54
  def test?
50
55
  false
51
56
  end
52
-
57
+
53
58
  private
54
59
 
55
60
  # Take the posted data and move the relevant data into a hash
56
61
  def parse(post)
57
62
  @raw = post.to_s
58
- for line in @raw.split('&')
63
+ for line in @raw.split('&')
59
64
  key, value = *line.scan( %r{^([A-Za-z0-9_.]+)\=(.*)$} ).flatten
60
65
  params[key] = CGI.unescape(value)
61
66
  end
@@ -35,7 +35,7 @@ module ActiveMerchant #:nodoc:
35
35
  mapping :customer, { :first_name => 'first_name', :last_name => 'last_name' }
36
36
 
37
37
  def description(value)
38
- add_field('description', "#{value}".delete("#"))
38
+ add_field('description', normalize("#{value}").delete("#"))
39
39
  end
40
40
 
41
41
  def customer(params = {})
@@ -97,6 +97,18 @@ module ActiveMerchant #:nodoc:
97
97
 
98
98
  [response['SECURETOKEN'], response['SECURETOKENID']] if response['RESPMSG'] && response['RESPMSG'].downcase == "approved"
99
99
  end
100
+
101
+ def normalize(text)
102
+ return unless text
103
+
104
+ if ActiveSupport::Inflector.method(:transliterate).arity == -2
105
+ ActiveSupport::Inflector.transliterate(text,'')
106
+ elsif RUBY_VERSION >= '1.9'
107
+ text.gsub(/[^\x00-\x7F]+/, '')
108
+ else
109
+ ActiveSupport::Inflector.transliterate(text).to_s
110
+ end
111
+ end
100
112
  end
101
113
  end
102
114
  end
@@ -0,0 +1,43 @@
1
+ require 'digest/sha2'
2
+ require 'bigdecimal'
3
+
4
+ module ActiveMerchant #:nodoc:
5
+ module Billing #:nodoc:
6
+ module Integrations #:nodoc:
7
+ module PayuIn
8
+ autoload :Return, 'active_merchant/billing/integrations/payu_in/return.rb'
9
+ autoload :Helper, 'active_merchant/billing/integrations/payu_in/helper.rb'
10
+ autoload :Notification, 'active_merchant/billing/integrations/payu_in/notification.rb'
11
+
12
+ mattr_accessor :test_url
13
+ mattr_accessor :production_url
14
+
15
+ self.test_url = 'https://test.payu.in/_payment.php'
16
+ self.production_url = 'https://secure.payu.in/_payment.php'
17
+
18
+ def self.service_url
19
+ ActiveMerchant::Billing::Base.integration_mode == :production ? self.production_url : self.test_url
20
+ end
21
+
22
+ def self.notification(post, options = {})
23
+ Notification.new(post, options)
24
+ end
25
+
26
+ def self.return(post, options = {})
27
+ Return.new(post, options)
28
+ end
29
+
30
+ def self.checksum(merchant_id, secret_key, *payload_items )
31
+ options = payload_items.pop if Hash === payload_items.last
32
+ options ||= {}
33
+ payload = if options[:reverse] then
34
+ payload_items.dup.push( merchant_id || "" ).unshift( secret_key || "" ).collect{ |x| x.to_s }.join("|")
35
+ else
36
+ payload_items.dup.unshift( merchant_id || "" ).push( secret_key || "" ).collect{ |x| x.to_s }.join("|")
37
+ end
38
+ Digest::SHA512.hexdigest( payload )
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,74 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module PayuIn
5
+ class Helper < ActiveMerchant::Billing::Integrations::Helper
6
+
7
+ mapping :amount, 'amount'
8
+ mapping :account, 'key'
9
+ mapping :order, 'txnid'
10
+ mapping :credential2, 'productinfo'
11
+
12
+ mapping :customer, :first_name => 'firstname',
13
+ :last_name => 'lastname',
14
+ :email => 'email',
15
+ :phone => 'phone'
16
+
17
+ mapping :billing_address, :city => 'city',
18
+ :address1 => 'address1',
19
+ :address2 => 'address2',
20
+ :state => 'state',
21
+ :zip => 'zip',
22
+ :country => 'country'
23
+
24
+ # Which tab you want to be open default on PayU
25
+ # CC (CreditCard) or NB (NetBanking)
26
+ mapping :mode, 'pg'
27
+
28
+ mapping :notify_url, 'notify_url'
29
+ mapping :return_url, ['surl', 'furl']
30
+ mapping :cancel_return_url, 'curl'
31
+ mapping :checksum, 'hash'
32
+
33
+ mapping :user_defined, { :var1 => 'udf1',
34
+ :var2 => 'udf2',
35
+ :var3 => 'udf3',
36
+ :var4 => 'udf4',
37
+ :var5 => 'udf5',
38
+ :var6 => 'udf6',
39
+ :var7 => 'udf7',
40
+ :var8 => 'udf8',
41
+ :var9 => 'udf9',
42
+ :var10 => 'udf10'
43
+ }
44
+
45
+ def initialize(order, account, options = {})
46
+ super
47
+ self.pg = 'CC'
48
+ end
49
+
50
+ def form_fields
51
+ @fields.merge(mappings[:checksum] => generate_checksum)
52
+ end
53
+
54
+ def generate_checksum( options = {} )
55
+ checksum_fields = [ :order, :amount, :credential2, { :customer => [ :first_name, :email ] },
56
+ { :user_defined => [ :var1, :var2, :var3, :var4, :var5, :var6, :var7, :var8, :var9, :var10 ] } ]
57
+ checksum_payload_items = checksum_fields.inject( [] ) do | items, field |
58
+ if Hash === field then
59
+ key = field.keys.first
60
+ field[key].inject( items ){ |s,x| items.push( @fields[ mappings[key][x] ] ) }
61
+ else
62
+ items.push( @fields[ mappings[field] ] )
63
+ end
64
+ end
65
+ checksum_payload_items.push( options )
66
+ PayuIn.checksum(@fields["key"], @fields["productinfo"], *checksum_payload_items )
67
+ end
68
+
69
+ end
70
+
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,167 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module PayuIn
5
+ class Notification < ActiveMerchant::Billing::Integrations::Notification
6
+
7
+ def initialize(post, options = {})
8
+ super(post, options)
9
+ @merchant_id = options[:credential1]
10
+ @secret_key = options[:credential2]
11
+ end
12
+
13
+ def complete?
14
+ status == "success"
15
+ end
16
+
17
+ # Status of the transaction. List of possible values:
18
+ # <tt>invalid</tt>:: transaction id is not present
19
+ # <tt>tampered</tt>:: transaction data has been tampered
20
+ # <tt>success</tt>:: transaction successful
21
+ # <tt>pending</tt>:: transaction is pending for some approval
22
+ # <tt>failure</tt>:: transaction failure
23
+ def status
24
+ @status ||= if checksum_ok?
25
+ if transaction_id.blank?
26
+ 'invalid'
27
+ else
28
+ transaction_status.downcase
29
+ end
30
+ else
31
+ 'tampered'
32
+ end
33
+ end
34
+
35
+ def invoice_ok?( order_id )
36
+ order_id.to_s == invoice.to_s
37
+ end
38
+
39
+ # Order amount should be equal to gross - discount
40
+ def amount_ok?( order_amount, order_discount = BigDecimal.new( '0.0' ) )
41
+ BigDecimal.new( gross ) == order_amount && BigDecimal.new( discount ) == order_discount
42
+ end
43
+
44
+ # Status of transaction return from the PayU. List of possible values:
45
+ # <tt>SUCCESS</tt>::
46
+ # <tt>PENDING</tt>::
47
+ # <tt>FAILURE</tt>::
48
+ def transaction_status
49
+ params['status']
50
+ end
51
+
52
+ # ID of this transaction (PayU.in number)
53
+ def transaction_id
54
+ params['mihpayid']
55
+ end
56
+
57
+ # Mode of Payment
58
+ #
59
+ # 'CC' for credit-card
60
+ # 'NB' for net-banking
61
+ # 'CD' for cheque or DD
62
+ # 'CO' for Cash Pickup
63
+ def type
64
+ params['mode']
65
+ end
66
+
67
+ # What currency have we been dealing with
68
+ def currency
69
+ 'INR'
70
+ end
71
+
72
+ def item_id
73
+ params['txnid']
74
+ end
75
+
76
+ # This is the invoice which you passed to PayU.in
77
+ def invoice
78
+ params['txnid']
79
+ end
80
+
81
+ # Merchant Id provided by the PayU.in
82
+ def account
83
+ params['key']
84
+ end
85
+
86
+ # original amount send by merchant
87
+ def gross
88
+ params['amount']
89
+ end
90
+
91
+ # This is discount given to user - based on promotion set by merchants.
92
+ def discount
93
+ params['discount']
94
+ end
95
+
96
+ # Description offer for what PayU given the offer to user - based on promotion set by merchants.
97
+ def offer_description
98
+ params['offer']
99
+ end
100
+
101
+ # Information about the product as send by merchant
102
+ def product_info
103
+ params['productinfo']
104
+ end
105
+
106
+ # Email of the customer
107
+ def customer_email
108
+ params['email']
109
+ end
110
+
111
+ # Phone of the customer
112
+ def customer_phone
113
+ params['phone']
114
+ end
115
+
116
+ # Firstname of the customer
117
+ def customer_first_name
118
+ params['firstname']
119
+ end
120
+
121
+ # Lastname of the customer
122
+ def customer_last_name
123
+ params['lastname']
124
+ end
125
+
126
+ # Full address of the customer
127
+ def customer_address
128
+ { :address1 => params['address1'], :address2 => params['address2'],
129
+ :city => params['city'], :state => params['state'],
130
+ :country => params['country'], :zipcode => params['zipcode'] }
131
+ end
132
+
133
+ def user_defined
134
+ return @user_defined if @user_defined
135
+ @user_defined = []
136
+ 10.times{ |i| @user_defined.push( params[ "udf#{i+1}" ] ) }
137
+ @user_defined
138
+ end
139
+
140
+ def checksum
141
+ params['hash']
142
+ end
143
+
144
+ def message
145
+ @message || params['error']
146
+ end
147
+
148
+ def acknowledge
149
+ checksum_ok?
150
+ end
151
+
152
+ def checksum_ok?
153
+ fields = user_defined.dup.push( customer_email, customer_first_name, product_info, gross, invoice, :reverse => true )
154
+ fields.unshift( transaction_status )
155
+ unless PayuIn.checksum(@merchant_id, @secret_key, *fields ) == checksum
156
+ @message = 'Return checksum not matching the data provided'
157
+ return false
158
+ end
159
+ true
160
+ end
161
+
162
+ end
163
+ end
164
+ end
165
+ end
166
+ end
167
+