activemerchant 1.26.0 → 1.27.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. data/CHANGELOG +17 -0
  2. data/CONTRIBUTORS +20 -0
  3. data/README.md +5 -0
  4. data/lib/active_merchant/billing/base.rb +2 -2
  5. data/lib/active_merchant/billing/gateway.rb +6 -0
  6. data/lib/active_merchant/billing/gateways/authorize_net.rb +1 -1
  7. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +0 -3
  8. data/lib/active_merchant/billing/gateways/balanced.rb +462 -0
  9. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +3 -3
  10. data/lib/active_merchant/billing/gateways/beanstream.rb +1 -1
  11. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +3 -2
  12. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +1 -1
  13. data/lib/active_merchant/billing/gateways/braintree.rb +2 -0
  14. data/lib/active_merchant/billing/gateways/braintree_blue.rb +11 -1
  15. data/lib/active_merchant/billing/gateways/braintree_orange.rb +2 -4
  16. data/lib/active_merchant/billing/gateways/card_stream.rb +2 -2
  17. data/lib/active_merchant/billing/gateways/certo_direct.rb +2 -3
  18. data/lib/active_merchant/billing/gateways/cyber_source.rb +3 -3
  19. data/lib/active_merchant/billing/gateways/data_cash.rb +3 -3
  20. data/lib/active_merchant/billing/gateways/efsnet.rb +3 -3
  21. data/lib/active_merchant/billing/gateways/epay.rb +3 -3
  22. data/lib/active_merchant/billing/gateways/eway.rb +8 -7
  23. data/lib/active_merchant/billing/gateways/eway_managed.rb +3 -3
  24. data/lib/active_merchant/billing/gateways/exact.rb +2 -2
  25. data/lib/active_merchant/billing/gateways/fat_zebra.rb +4 -4
  26. data/lib/active_merchant/billing/gateways/federated_canada.rb +2 -2
  27. data/lib/active_merchant/billing/gateways/first_pay.rb +3 -3
  28. data/lib/active_merchant/billing/gateways/garanti.rb +2 -2
  29. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +3 -1
  30. data/lib/active_merchant/billing/gateways/inspire.rb +2 -2
  31. data/lib/active_merchant/billing/gateways/instapay.rb +2 -2
  32. data/lib/active_merchant/billing/gateways/iridium.rb +4 -5
  33. data/lib/active_merchant/billing/gateways/itransact.rb +2 -2
  34. data/lib/active_merchant/billing/gateways/jetpay.rb +3 -3
  35. data/lib/active_merchant/billing/gateways/linkpoint.rb +3 -6
  36. data/lib/active_merchant/billing/gateways/litle.rb +50 -34
  37. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +3 -3
  38. data/lib/active_merchant/billing/gateways/merchant_ware.rb +2 -2
  39. data/lib/active_merchant/billing/gateways/migs.rb +8 -4
  40. data/lib/active_merchant/billing/gateways/modern_payments.rb +2 -0
  41. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +4 -4
  42. data/lib/active_merchant/billing/gateways/moneris.rb +3 -3
  43. data/lib/active_merchant/billing/gateways/moneris_us.rb +3 -3
  44. data/lib/active_merchant/billing/gateways/nab_transact.rb +8 -6
  45. data/lib/active_merchant/billing/gateways/net_registry.rb +2 -2
  46. data/lib/active_merchant/billing/gateways/netaxept.rb +4 -4
  47. data/lib/active_merchant/billing/gateways/netbilling.rb +2 -2
  48. data/lib/active_merchant/billing/gateways/ogone.rb +10 -5
  49. data/lib/active_merchant/billing/gateways/optimal_payment.rb +3 -3
  50. data/lib/active_merchant/billing/gateways/orbital.rb +4 -4
  51. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +2 -2
  52. data/lib/active_merchant/billing/gateways/pay_secure.rb +2 -2
  53. data/lib/active_merchant/billing/gateways/paybox_direct.rb +7 -5
  54. data/lib/active_merchant/billing/gateways/payflow.rb +39 -37
  55. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +4 -3
  56. data/lib/active_merchant/billing/gateways/payment_express.rb +2 -2
  57. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +98 -85
  58. data/lib/active_merchant/billing/gateways/paystation.rb +2 -2
  59. data/lib/active_merchant/billing/gateways/payway.rb +3 -2
  60. data/lib/active_merchant/billing/gateways/plugnpay.rb +63 -66
  61. data/lib/active_merchant/billing/gateways/psigate.rb +3 -3
  62. data/lib/active_merchant/billing/gateways/psl_card.rb +3 -3
  63. data/lib/active_merchant/billing/gateways/quantum.rb +2 -2
  64. data/lib/active_merchant/billing/gateways/quickpay.rb +2 -2
  65. data/lib/active_merchant/billing/gateways/realex.rb +7 -7
  66. data/lib/active_merchant/billing/gateways/sage.rb +2 -0
  67. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +1 -1
  68. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +2 -3
  69. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +1 -1
  70. data/lib/active_merchant/billing/gateways/sage_pay.rb +8 -6
  71. data/lib/active_merchant/billing/gateways/sallie_mae.rb +2 -2
  72. data/lib/active_merchant/billing/gateways/secure_net.rb +4 -4
  73. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +9 -6
  74. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +2 -2
  75. data/lib/active_merchant/billing/gateways/skip_jack.rb +3 -3
  76. data/lib/active_merchant/billing/gateways/smart_ps.rb +3 -1
  77. data/lib/active_merchant/billing/gateways/stripe.rb +2 -2
  78. data/lib/active_merchant/billing/gateways/trans_first.rb +2 -2
  79. data/lib/active_merchant/billing/gateways/transax.rb +1 -3
  80. data/lib/active_merchant/billing/gateways/trust_commerce.rb +3 -3
  81. data/lib/active_merchant/billing/gateways/usa_epay.rb +2 -0
  82. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +3 -2
  83. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +6 -6
  84. data/lib/active_merchant/billing/gateways/verifi.rb +2 -2
  85. data/lib/active_merchant/billing/gateways/wirecard.rb +4 -4
  86. data/lib/active_merchant/billing/gateways/worldpay.rb +37 -18
  87. data/lib/active_merchant/billing/integrations/action_view_helper.rb +6 -5
  88. data/lib/active_merchant/billing/integrations/first_data.rb +38 -0
  89. data/lib/active_merchant/billing/integrations/first_data/helper.rb +63 -0
  90. data/lib/active_merchant/billing/integrations/first_data/notification.rb +56 -0
  91. data/lib/active_merchant/billing/integrations/helper.rb +4 -0
  92. data/lib/active_merchant/billing/integrations/maksuturva.rb +86 -0
  93. data/lib/active_merchant/billing/integrations/maksuturva/helper.rb +119 -0
  94. data/lib/active_merchant/billing/integrations/maksuturva/notification.rb +48 -0
  95. data/lib/active_merchant/billing/integrations/paxum.rb +44 -0
  96. data/lib/active_merchant/billing/integrations/paxum/common.rb +24 -0
  97. data/lib/active_merchant/billing/integrations/paxum/helper.rb +42 -0
  98. data/lib/active_merchant/billing/integrations/paxum/notification.rb +33 -0
  99. data/lib/active_merchant/billing/integrations/pxpay.rb +31 -0
  100. data/lib/active_merchant/billing/integrations/pxpay/helper.rb +110 -0
  101. data/lib/active_merchant/billing/integrations/pxpay/notification.rb +157 -0
  102. data/lib/active_merchant/billing/integrations/pxpay/return.rb +25 -0
  103. data/lib/active_merchant/billing/integrations/web_pay.rb +45 -0
  104. data/lib/active_merchant/billing/integrations/web_pay/common.rb +50 -0
  105. data/lib/active_merchant/billing/integrations/web_pay/helper.rb +68 -0
  106. data/lib/active_merchant/billing/integrations/web_pay/notification.rb +51 -0
  107. data/lib/active_merchant/version.rb +1 -1
  108. data/lib/support/gateway_support.rb +9 -2
  109. data/lib/support/ssl_verify.rb +93 -0
  110. metadata +45 -71
  111. data.tar.gz.sig +0 -3
  112. metadata.gz.sig +0 -0
@@ -39,16 +39,17 @@ module ActiveMerchant #:nodoc:
39
39
  # <% service.cancel_return_url 'http://mystore.com' %>
40
40
  # <% end %>
41
41
  #
42
- def payment_service_for(order, account, options = {}, &proc)
42
+ def payment_service_for(order, account, options = {}, &proc)
43
43
  raise ArgumentError, "Missing block" unless block_given?
44
44
 
45
45
  integration_module = ActiveMerchant::Billing::Integrations.const_get(options.delete(:service).to_s.camelize)
46
-
47
- result = []
48
- result << form_tag(integration_module.service_url, options.delete(:html) || {})
49
-
50
46
  service_class = integration_module.const_get('Helper')
47
+
48
+ form_options = options.delete(:html) || {}
51
49
  service = service_class.new(order, account, options)
50
+ form_options[:method] = service.form_method
51
+ result = []
52
+ result << form_tag(integration_module.service_url, form_options)
52
53
 
53
54
  result << capture(service, &proc)
54
55
 
@@ -0,0 +1,38 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module FirstData
5
+ autoload :Helper, 'active_merchant/billing/integrations/first_data/helper.rb'
6
+ autoload :Notification, 'active_merchant/billing/integrations/first_data/notification.rb'
7
+
8
+ # Overwrite this if you want to change the ANS test url
9
+ mattr_accessor :test_url
10
+ self.test_url = 'https://demo.globalgatewaye4.firstdata.com/payment'
11
+
12
+ # Overwrite this if you want to change the ANS production url
13
+ mattr_accessor :production_url
14
+ self.production_url = 'https://checkout.globalgatewaye4.firstdata.com/payment'
15
+
16
+ def self.service_url
17
+ mode = ActiveMerchant::Billing::Base.integration_mode
18
+ case mode
19
+ when :production
20
+ self.production_url
21
+ when :test
22
+ self.test_url
23
+ else
24
+ raise StandardError, "Integration mode set to an invalid value: #{mode}"
25
+ end
26
+ end
27
+
28
+ def self.notification(post)
29
+ Notification.new(post)
30
+ end
31
+
32
+ def self.return(query_string)
33
+ Return.new(query_string)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,63 @@
1
+ require 'active_support/core_ext/float/rounding.rb' # Float#round(precision)
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ module Integrations #:nodoc:
6
+ module FirstData
7
+ # First Data payment pages emulates the Authorize.Net SIM API. See
8
+ # ActiveMerchant::Billing::Integrations::AuthorizeNetSim::Helper for
9
+ # more details.
10
+ #
11
+ # An example. Note the username as a parameter and transaction key you
12
+ # will want to use later.
13
+ #
14
+ # payment_service_for('order_id', 'first_data_payment_page_id', :service => :first_data, :amount => 157.0) do |service|
15
+ #
16
+ # # You must call setup_hash and invoice
17
+ #
18
+ # service.setup_hash :transaction_key => '8CP6zJ7uD875J6tY',
19
+ # :order_timestamp => 1206836763
20
+ # service.customer_id 8
21
+ # service.customer :first_name => 'g',
22
+ # :last_name => 'g',
23
+ # :email => 'g@g.com',
24
+ # :phone => '3'
25
+ # service.billing_address :zip => 'g',
26
+ # :country => 'United States of America',
27
+ # :address => 'g'
28
+ #
29
+ # service.ship_to_address :first_name => 'g',
30
+ # :last_name => 'g',
31
+ # :city => '',
32
+ # :address => 'g',
33
+ # :address2 => '',
34
+ # :state => address.state,
35
+ # :country => 'United States of America',
36
+ # :zip => 'g'
37
+ #
38
+ # service.invoice "516428355" # your invoice number
39
+ # # The end-user is presented with the HTML produced by the notify_url
40
+ # # (using the First Data Receipt Link feature).
41
+ # service.return_url "http://mysite/first_data_receipt_generator_page"
42
+ # service.payment_header 'My store name'
43
+ # service.add_line_item :name => 'item name', :quantity => 1, :unit_price => 0
44
+ # service.test_request 'true' # only if it's just a test
45
+ # service.shipping '25.0'
46
+ # # Tell it to display a "0" line item for shipping, with the price in
47
+ # # the name, otherwise it isn't shown at all, leaving the end user to
48
+ # # wonder why the total is different than the sum of the line items.
49
+ # service.add_shipping_as_line_item
50
+ # server.add_tax_as_line_item # same with tax
51
+ # # See the helper.rb file for various custom fields
52
+ # end
53
+ class Helper < ActiveMerchant::Billing::Integrations::AuthorizeNetSim::Helper
54
+ # Configure notify_url to use the "Relay Response" feature
55
+ mapping :notify_url, 'x_relay_url'
56
+
57
+ # Configure return_url to use the "Receipt Link" feature
58
+ mapping :return_url, 'x_receipt_link_url'
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,56 @@
1
+ require 'net/http'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ module Integrations #:nodoc:
6
+ # First Data payment pages emulates the Authorize.Net SIM API. See
7
+ # ActiveMerchant::Billing::Integrations::FirstData::Notification for
8
+ # more details.
9
+ #
10
+ # # Example:
11
+ # parser = FirstData::Notification.new(request.raw_post)
12
+ # passed = parser.complete?
13
+ #
14
+ # order = Order.find_by_order_number(parser.invoice_num)
15
+ #
16
+ # unless order
17
+ # @message = 'Error--unable to find your transaction! Please contact us directly.'
18
+ # return render :partial => 'first_data_payment_response'
19
+ # end
20
+ #
21
+ # if order.total != parser.gross.to_f
22
+ # logger.error "First Data said they paid for #{parser.gross} and it should have been #{order.total}!"
23
+ # passed = false
24
+ # end
25
+ #
26
+ # # Theoretically, First Data will *never* pass us the same transaction
27
+ # # ID twice, but we can double check that... by using
28
+ # # parser.transaction_id, and checking against previous orders' transaction
29
+ # # id's (which you can save when the order is completed)....
30
+ # unless parser.acknowledge FIRST_DATA_TRANSACTION_KEY, FIRST_DATA_RESPONSE_KEY
31
+ # passed = false
32
+ # logger.error "ALERT POSSIBLE FRAUD ATTEMPT"
33
+ # end
34
+ #
35
+ # unless parser.cavv_matches? and parser.avs_code_matches?
36
+ # logger.error 'Warning--non matching CC!' + params.inspect
37
+ # # Could fail them here, as well (recommended)...
38
+ # end
39
+ #
40
+ # if passed
41
+ # # Set up your session, and render something that will redirect them to
42
+ # # your site, most likely.
43
+ # else
44
+ # # Render failure or redirect them to your site where you will render failure
45
+ # end
46
+
47
+ module FirstData
48
+ class Notification < ActiveMerchant::Billing::Integrations::AuthorizeNetSim::Notification
49
+ def acknowledge(response_key, payment_page_id)
50
+ Digest::MD5.hexdigest(response_key + payment_page_id + params['x_trans_id'] + sprintf('%.2f', gross)) == params['x_MD5_Hash'].downcase
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -71,6 +71,10 @@ module ActiveMerchant #:nodoc:
71
71
  @test_mode ||= ActiveMerchant::Billing::Base.integration_mode == :test || @test
72
72
  end
73
73
 
74
+ def form_method
75
+ "POST"
76
+ end
77
+
74
78
  private
75
79
 
76
80
  def add_address(key, params)
@@ -0,0 +1,86 @@
1
+ require File.dirname(__FILE__) + '/maksuturva/helper.rb'
2
+ require File.dirname(__FILE__) + '/maksuturva/notification.rb'
3
+
4
+ # USAGE:
5
+ #
6
+ # First define Maksuturva seller id and authcode in an initializer:
7
+ #
8
+ # MAKSUTURVA_SELLERID = "testikauppias"
9
+ # MAKSUTURVA_AUTHCODE = "11223344556677889900"
10
+ #
11
+ # Then in view do something like this (use dynamic values for your app)
12
+ #
13
+ # <% payment_service_for 2, MAKSUTURVA_SELLERID,
14
+ # :amount => "200,00", :currency => 'EUR', :credential2 => MAKSUTURVA_AUTHCODE,
15
+ # :service => :maksuturva do |service|
16
+ # service.pmt_reference = "134662"
17
+ # service.pmt_duedate = "24.06.2012"
18
+ # service.customer :phone => "0405051909",
19
+ # :email => "antti@example.com"
20
+ # service.billing_address :city => "Helsinki",
21
+ # :address1 => "Lorem street",
22
+ # :state => "-",
23
+ # :country => 'Finland',
24
+ # :zip => "00530"
25
+ # service.pmt_orderid = "2"
26
+ # service.pmt_buyername = "Antti Akonniemi"
27
+ # service.pmt_deliveryname = "Antti Akonniemi"
28
+ # service.pmt_deliveryaddress = "Köydenpunojankatu 13"
29
+ # service.pmt_deliverypostalcode = "00180"
30
+ # service.pmt_deliverycity = "Helsinki"
31
+ # service.pmt_deliverycountry = "FI"
32
+ # service.pmt_rows = 1
33
+ # service.pmt_row_name1 = "testi"
34
+ # service.pmt_row_desc1 = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
35
+ # service.pmt_row_articlenr1 = "1"
36
+ # service.pmt_row_quantity1 = "1"
37
+ # service.pmt_row_deliverydate1 = "26.6.2012"
38
+ # service.pmt_row_price_gross1 = "200,00"
39
+ # service.pmt_row_vat1= "23,00"
40
+ # service.pmt_row_discountpercentage1 = "0,00"
41
+ # service.pmt_row_type1 = "1"
42
+ # service.pmt_charset = "UTF-8"
43
+ # service.pmt_charsethttp = "UTF-8"
44
+ #
45
+ # service.return_url "http://localhost:3000/process"
46
+ # service.cancel_return_url "http://example.com"
47
+ # service.pmt_errorreturn "http://example.com"
48
+ #
49
+ # service.pmt_delayedpayreturn "http://example.com"
50
+ # service.pmt_escrow "N"
51
+ # service.pmt_escrowchangeallowed "N"
52
+ # service.pmt_sellercosts "0,00"
53
+ # service.pmt_keygeneration "001"
54
+ # %>
55
+ #
56
+ # Then in the controller handle the return with something like this
57
+ #
58
+ # def ipn
59
+ # notify = ActiveMerchant::Billing::Integrations::Maksuturva::Notification.new(params)
60
+ #
61
+ # if notify.acknowledge(MAKSUTURVA_AUTHCODE)
62
+ # # Process order
63
+ # else
64
+ # # Show error
65
+ # end
66
+ # end
67
+ #
68
+ # For full list of available parameters etc check the integration documents
69
+ # here:
70
+ #
71
+ # https://www.maksuturva.fi/services/vendor_services/integration_guidelines.html
72
+
73
+ module ActiveMerchant #:nodoc:
74
+ module Billing #:nodoc:
75
+ module Integrations #:nodoc:
76
+ module Maksuturva
77
+ mattr_accessor :service_url
78
+ self.service_url = 'https://www.maksuturva.fi/NewPaymentExtended.pmt'
79
+
80
+ def self.notification(post)
81
+ Notification.new(post)
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,119 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Maksuturva
5
+ class Helper < ActiveMerchant::Billing::Integrations::Helper
6
+ def initialize(order, account, options = {})
7
+ md5secret options.delete(:credential2)
8
+ super
9
+ add_field("pmt_action", "NEW_PAYMENT_EXTENDED")
10
+ add_field("pmt_version", "0004")
11
+ add_field("pmt_sellerid", account)
12
+ add_field("pmt_hashversion", "MD5")
13
+ end
14
+
15
+ def md5secret(value)
16
+ @md5secret = value
17
+ end
18
+
19
+ def form_fields
20
+ @fields.merge("pmt_hash" => generate_md5string)
21
+ end
22
+
23
+ def generate_md5string
24
+ fields = [@fields["pmt_action"], @fields["pmt_version"]]
25
+ fields += [@fields["pmt_selleriban"]] unless @fields["pmt_selleriban"].nil?
26
+ fields += [@fields["pmt_id"], @fields["pmt_orderid"], @fields["pmt_reference"], @fields["pmt_duedate"],
27
+ @fields["pmt_amount"], @fields["pmt_currency"], @fields["pmt_okreturn"], @fields["pmt_errorreturn"], @fields["pmt_cancelreturn"],
28
+ @fields["pmt_delayedpayreturn"], @fields["pmt_escrow"], @fields["pmt_escrowchangeallowed"]]
29
+
30
+ fields += [@fields["pmt_invoicefromseller"]] unless @fields["pmt_invoicefromseller"].nil?
31
+ fields += [@fields["pmt_paymentmethod"]] unless @fields["pmt_paymentmethod"].nil?
32
+ fields += [@fields["pmt_buyeridentificationcode"]] unless @fields["pmt_buyeridentificationcode"].nil?
33
+
34
+
35
+ fields += [@fields["pmt_buyername"], @fields["pmt_buyeraddress"], @fields["pmt_buyerpostalcode"], @fields["pmt_buyercity"],
36
+ @fields["pmt_buyercountry"], @fields["pmt_deliveryname"], @fields["pmt_deliveryaddress"], @fields["pmt_deliverypostalcode"], @fields["pmt_deliverycity"],
37
+ @fields["pmt_deliverycountry"], @fields["pmt_sellercosts"]]
38
+
39
+ (1..@fields["pmt_rows"].to_i).each do |i|
40
+ fields += [@fields["pmt_row_name#{i}"], @fields["pmt_row_desc#{i}"], @fields["pmt_row_quantity#{i}"]]
41
+ fields += [@fields["pmt_row_articlenr#{i}"]] unless @fields["pmt_row_articlenr#{i}"].nil?
42
+ fields += [@fields["pmt_row_unit#{i}"]] unless @fields["pmt_row_unit#{i}"].nil?
43
+ fields += [@fields["pmt_row_deliverydate#{i}"]]
44
+ fields += [@fields["pmt_row_price_gross#{i}"]] unless @fields["pmt_row_price_gross#{i}"].nil?
45
+ fields += [@fields["pmt_row_price_net#{i}"]] unless @fields["pmt_row_price_net#{i}"].nil?
46
+ fields += [@fields["pmt_row_vat#{i}"], @fields["pmt_row_discountpercentage#{i}"], @fields["pmt_row_type#{i}"]]
47
+ end
48
+ fields += [@md5secret]
49
+ fields = fields.join("&") + "&"
50
+ Digest::MD5.hexdigest(fields).upcase
51
+ end
52
+
53
+ mapping :pmt_selleriban, "pmt_selleriban"
54
+ mapping :pmt_reference, "pmt_reference"
55
+ mapping :pmt_duedate, "pmt_duedate"
56
+ mapping :pmt_userlocale, "pmt_userlocale"
57
+ mapping :pmt_escrow, "pmt_escrow"
58
+ mapping :pmt_escrowchangeallowed, "pmt_escrowchangeallowed"
59
+ mapping :pmt_invoicefromseller, "pmt_invoicefromseller"
60
+ mapping :pmt_paymentmethod, "pmt_paymentmethod"
61
+ mapping :pmt_buyeridentificationcode, "pmt_buyeridentificationcode"
62
+ mapping :pmt_buyername, "pmt_buyername"
63
+
64
+ mapping :account, ''
65
+ mapping :currency, 'pmt_currency'
66
+ mapping :amount, 'pmt_amount'
67
+
68
+ mapping :order, 'pmt_id'
69
+ mapping :pmt_orderid, 'pmt_orderid'
70
+ mapping :pmt_deliveryname, "pmt_deliveryname"
71
+ mapping :pmt_deliveryaddress, "pmt_deliveryaddress"
72
+ mapping :pmt_deliverypostalcode, "pmt_deliverypostalcode"
73
+ mapping :pmt_deliverycity, "pmt_deliverycity"
74
+ mapping :pmt_deliverycountry, "pmt_deliverycountry"
75
+ mapping :pmt_sellercosts, "pmt_sellercosts"
76
+ mapping :pmt_rows, "pmt_rows"
77
+
78
+ (1..499.to_i).each do |i|
79
+ mapping "pmt_row_name#{i}".to_sym, "pmt_row_name#{i}"
80
+ mapping "pmt_row_desc#{i}".to_sym, "pmt_row_desc#{i}"
81
+ mapping "pmt_row_quantity#{i}".to_sym, "pmt_row_quantity#{i}"
82
+ mapping "pmt_row_articlenr#{i}".to_sym, "pmt_row_articlenr#{i}"
83
+ mapping "pmt_row_unit#{i}".to_sym, "pmt_row_unit#{i}"
84
+ mapping "pmt_row_deliverydate#{i}".to_sym, "pmt_row_deliverydate#{i}"
85
+ mapping "pmt_row_price_gross#{i}".to_sym, "pmt_row_price_gross#{i}"
86
+ mapping "pmt_row_price_net#{i}".to_sym, "pmt_row_price_net#{i}"
87
+ mapping "pmt_row_vat#{i}".to_sym, "pmt_row_vat#{i}"
88
+ mapping "pmt_row_discountpercentage#{i}".to_sym, "pmt_row_discountpercentage#{i}"
89
+ mapping "pmt_row_type#{i}".to_sym, "pmt_row_type#{i}"
90
+ end
91
+
92
+ mapping :pmt_charset, "pmt_charset"
93
+ mapping :pmt_charsethttp, "pmt_charsethttp"
94
+ mapping :pmt_hashversion, "pmt_hashversion"
95
+ mapping :pmt_keygeneration, "pmt_keygeneration"
96
+ mapping :customer, :email => 'pmt_buyeremail',
97
+ :phone => 'pmt_buyerphone'
98
+
99
+ mapping :billing_address, :city => 'pmt_buyercity',
100
+ :address1 => "pmt_buyeraddress",
101
+ :address2 => '',
102
+ :state => '',
103
+ :zip => "pmt_buyerpostalcode",
104
+ :country => 'pmt_buyercountry'
105
+
106
+ mapping :notify_url, ''
107
+ mapping :return_url, 'pmt_okreturn'
108
+ mapping :pmt_errorreturn, 'pmt_errorreturn'
109
+ mapping :pmt_delayedpayreturn, 'pmt_delayedpayreturn'
110
+ mapping :cancel_return_url, 'pmt_cancelreturn'
111
+
112
+ mapping :description, ''
113
+ mapping :tax, ''
114
+ mapping :shipping, ''
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,48 @@
1
+ require "net/http"
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ module Integrations #:nodoc:
6
+ module Maksuturva
7
+ class Notification < ActiveMerchant::Billing::Integrations::Notification
8
+ def complete?
9
+ true
10
+ end
11
+
12
+ def transaction_id
13
+ params["pmt_id"]
14
+ end
15
+
16
+ def security_key
17
+ params["pmt_hash"]
18
+ end
19
+
20
+ def gross
21
+ params["pmt_amount"]
22
+ end
23
+
24
+ def currency
25
+ params["pmt_currency"]
26
+ end
27
+
28
+ def status
29
+ "PAID"
30
+ end
31
+
32
+ def acknowledge(authcode)
33
+ return_authcode = [params["pmt_action"], params["pmt_version"], params["pmt_id"], params["pmt_reference"], params["pmt_amount"], params["pmt_currency"], params["pmt_sellercosts"], params["pmt_paymentmethod"], params["pmt_escrow"], authcode].join("&")
34
+ (Digest::MD5.hexdigest(return_authcode + "&").upcase == params["pmt_hash"])
35
+ end
36
+
37
+ private
38
+
39
+ def parse(post)
40
+ post.each do |key, value|
41
+ params[key] = value
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end