activemerchant 1.3.2 → 1.4.0

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 (85) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +58 -0
  3. data/CONTRIBUTERS +25 -0
  4. data/MIT-LICENSE +3 -3
  5. data/README +16 -10
  6. data/Rakefile +4 -3
  7. data/lib/active_merchant.rb +7 -1
  8. data/lib/active_merchant/billing/check.rb +16 -9
  9. data/lib/active_merchant/billing/gateway.rb +1 -1
  10. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +702 -0
  11. data/lib/active_merchant/billing/gateways/beanstream.rb +102 -0
  12. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +233 -0
  13. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
  14. data/lib/active_merchant/billing/gateways/braintree.rb +10 -1
  15. data/lib/active_merchant/billing/gateways/cyber_source.rb +26 -2
  16. data/lib/active_merchant/billing/gateways/data_cash.rb +255 -59
  17. data/lib/active_merchant/billing/gateways/modern_payments.rb +36 -0
  18. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +214 -0
  19. data/lib/active_merchant/billing/gateways/net_registry.rb +1 -0
  20. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +2 -2
  21. data/lib/active_merchant/billing/gateways/payflow_express.rb +3 -11
  22. data/lib/active_merchant/billing/gateways/payment_express.rb +2 -2
  23. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +39 -21
  24. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  25. data/lib/active_merchant/billing/gateways/paypal_express.rb +3 -12
  26. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +20 -0
  27. data/lib/active_merchant/billing/gateways/protx.rb +25 -25
  28. data/lib/active_merchant/billing/gateways/sage.rb +145 -0
  29. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
  30. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +110 -0
  31. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
  32. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +3 -1
  33. data/lib/active_merchant/billing/gateways/skip_jack.rb +2 -0
  34. data/lib/active_merchant/billing/gateways/trust_commerce.rb +1 -1
  35. data/lib/active_merchant/billing/gateways/wirecard.rb +304 -0
  36. data/lib/active_merchant/billing/integrations.rb +8 -2
  37. data/lib/active_merchant/billing/integrations/action_view_helper.rb +18 -4
  38. data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +4 -2
  39. data/lib/active_merchant/billing/integrations/notification.rb +10 -1
  40. data/lib/active_merchant/lib/posts_data.rb +12 -3
  41. data/script/destroy +0 -0
  42. data/script/generate +0 -0
  43. data/test/extra/binding_of_caller.rb +0 -0
  44. data/test/extra/breakpoint.rb +0 -0
  45. data/test/fixtures.yml +24 -0
  46. data/test/remote/gateways/remote_authorize_net_cim_test.rb +459 -0
  47. data/test/remote/gateways/remote_beanstream_interac_test.rb +53 -0
  48. data/test/remote/gateways/remote_beanstream_test.rb +150 -0
  49. data/test/remote/gateways/remote_braintree_test.rb +22 -0
  50. data/test/remote/gateways/remote_cyber_source_test.rb +28 -3
  51. data/test/remote/gateways/remote_data_cash_test.rb +250 -48
  52. data/test/remote/gateways/remote_modern_payments_cim_test.rb +58 -0
  53. data/test/remote/gateways/remote_modern_payments_test.rb +43 -0
  54. data/test/remote/gateways/remote_sage_bankcard_test.rb +109 -0
  55. data/test/remote/gateways/remote_sage_test.rb +87 -0
  56. data/test/remote/gateways/remote_sage_virtual_check_test.rb +62 -0
  57. data/test/remote/gateways/remote_wirecard_test.rb +76 -0
  58. data/test/remote/integrations/remote_paypal_integration_test.rb +15 -3
  59. data/test/test_helper.rb +31 -13
  60. data/test/unit/check_test.rb +14 -2
  61. data/test/unit/credit_card_methods_test.rb +18 -0
  62. data/test/unit/gateways/authorize_net_cim_test.rb +641 -0
  63. data/test/unit/gateways/beanstream_interac_test.rb +51 -0
  64. data/test/unit/gateways/beanstream_test.rb +108 -0
  65. data/test/unit/gateways/braintree_test.rb +2 -5
  66. data/test/unit/gateways/cyber_source_test.rb +18 -0
  67. data/test/unit/gateways/data_cash_test.rb +32 -4
  68. data/test/unit/gateways/gateway_test.rb +8 -1
  69. data/test/unit/gateways/modern_payments_cim_test.rb +171 -0
  70. data/test/unit/gateways/net_registry_test.rb +6 -0
  71. data/test/unit/gateways/payflow_express_test.rb +18 -2
  72. data/test/unit/gateways/paypal_express_test.rb +154 -0
  73. data/test/unit/gateways/paypal_test.rb +140 -0
  74. data/test/unit/gateways/sage_bankcard_test.rb +162 -0
  75. data/test/unit/gateways/sage_virtual_check_test.rb +71 -0
  76. data/test/unit/gateways/secure_pay_au_test.rb +58 -1
  77. data/test/unit/gateways/skip_jack_test.rb +8 -0
  78. data/test/unit/gateways/verifi_test.rb +0 -1
  79. data/test/unit/gateways/wirecard_test.rb +232 -0
  80. data/test/unit/integrations/action_view_helper_test.rb +3 -0
  81. data/test/unit/integrations/notifications/hi_trust_notification_test.rb +23 -2
  82. data/test/unit/integrations/notifications/notification_test.rb +13 -0
  83. data/test/unit/posts_data_test.rb +20 -6
  84. metadata +40 -5
  85. metadata.gz.sig +0 -0
@@ -0,0 +1,58 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class RemoteModernPaymentsCimTest < Test::Unit::TestCase
4
+
5
+
6
+ def setup
7
+ @gateway = ModernPaymentsCimGateway.new(fixtures(:modern_payments))
8
+
9
+ @amount = 100
10
+ @credit_card = credit_card('4111111111111111')
11
+ @declined_card = credit_card('4000000000000000')
12
+
13
+ @options = {
14
+ :billing_address => address,
15
+ :customer => 'JIMSMITH2000'
16
+ }
17
+ end
18
+
19
+ def test_successful_create_customer
20
+ response = @gateway.create_customer(@options)
21
+ assert_success response
22
+ assert !response.params["create_customer_result"].blank?
23
+ end
24
+
25
+ def test_successful_modify_customer_credit_card
26
+ customer = @gateway.create_customer(@options)
27
+ assert_success customer
28
+
29
+ customer_id = customer.params["create_customer_result"]
30
+
31
+ credit_card = @gateway.modify_customer_credit_card(customer_id, @credit_card)
32
+ assert_success credit_card
33
+ assert !credit_card.params["modify_customer_credit_card_result"].blank?
34
+ end
35
+
36
+ def test_succsessful_authorize_credit_card_payment
37
+ customer = @gateway.create_customer(@options)
38
+ assert_success customer
39
+
40
+ customer_id = customer.params["create_customer_result"]
41
+
42
+ credit_card = @gateway.modify_customer_credit_card(customer_id, @credit_card)
43
+ assert_success credit_card
44
+
45
+ payment = @gateway.authorize_credit_card_payment(customer_id, @amount)
46
+ assert_success payment
47
+ end
48
+
49
+ def test_invalid_login
50
+ gateway = ModernPaymentsCimGateway.new(
51
+ :login => '',
52
+ :password => ''
53
+ )
54
+ assert response = gateway.create_customer(@options)
55
+ assert_failure response
56
+ assert_equal ModernPaymentsCimGateway::ERROR_MESSAGE, response.message
57
+ end
58
+ end
@@ -0,0 +1,43 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class RemoteModernPaymentTest < Test::Unit::TestCase
4
+
5
+
6
+ def setup
7
+ @gateway = ModernPaymentsGateway.new(fixtures(:modern_payments))
8
+
9
+ @amount = 100
10
+ @credit_card = credit_card('4111111111111111')
11
+ @declined_card = credit_card('4000000000000000')
12
+
13
+ @options = {
14
+ :order_id => '1',
15
+ :billing_address => address,
16
+ :description => 'Store Purchase'
17
+ }
18
+ end
19
+
20
+ def test_successful_purchase
21
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
22
+ assert_success response
23
+ assert_match /RESPONSECODE=A/, response.params["auth_string"]
24
+ assert_equal ModernPaymentsCimGateway::SUCCESS_MESSAGE, response.message
25
+ end
26
+
27
+ def test_unsuccessful_purchase
28
+ assert response = @gateway.purchase(@amount, @declined_card, @options)
29
+ assert_success response
30
+ assert_match /RESPONSECODE=D/, response.params["auth_string"]
31
+ assert_equal ModernPaymentsCimGateway::SUCCESS_MESSAGE, response.message
32
+ end
33
+
34
+ def test_invalid_login
35
+ gateway = ModernPaymentsGateway.new(
36
+ :login => '',
37
+ :password => ''
38
+ )
39
+ assert response = gateway.purchase(@amount, @credit_card, @options)
40
+ assert_failure response
41
+ assert_equal ModernPaymentsCimGateway::ERROR_MESSAGE, response.message
42
+ end
43
+ end
@@ -0,0 +1,109 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class RemoteSageBankcardTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @gateway = SageBankcardGateway.new(fixtures(:sage))
7
+
8
+ @amount = 100
9
+
10
+ @visa = credit_card("4111111111111111")
11
+ @mastercard = credit_card("5499740000000057")
12
+ @discover = credit_card("6011000993026909")
13
+ @amex = credit_card("371449635392376")
14
+
15
+ @options = {
16
+ :order_id => generate_unique_id,
17
+ :billing_address => address,
18
+ :shipping_address => address,
19
+ :email => 'longbob@example.com'
20
+ }
21
+ end
22
+
23
+ def test_successful_visa_purchase
24
+ assert response = @gateway.purchase(@amount, @visa, @options)
25
+ assert_success response
26
+ assert response.test?
27
+ assert_false response.authorization.blank?
28
+ end
29
+
30
+ def test_successful_visa_authorization
31
+ assert response = @gateway.authorize(@amount, @visa, @options)
32
+ assert_success response
33
+ assert response.test?
34
+ assert_false response.authorization.blank?
35
+ end
36
+
37
+ def test_declined_visa_purchase
38
+ @amount = 200
39
+
40
+ assert response = @gateway.purchase(@amount, @visa, @options)
41
+ assert_failure response
42
+ assert response.test?
43
+ end
44
+
45
+ def test_successful_mastercard_purchase
46
+ assert response = @gateway.purchase(@amount, @mastercard, @options)
47
+ assert_success response
48
+ assert response.test?
49
+ assert_false response.authorization.blank?
50
+ end
51
+
52
+ def test_successful_discover_purchase
53
+ assert response = @gateway.purchase(@amount, @discover, @options)
54
+ assert_success response
55
+ assert response.test?
56
+ assert_false response.authorization.blank?
57
+ end
58
+
59
+ def test_successful_amex_purchase
60
+ assert response = @gateway.purchase(@amount, @amex, @options)
61
+ assert_success response
62
+ assert response.test?
63
+ assert_false response.authorization.blank?
64
+ end
65
+
66
+ def test_authorization_and_capture
67
+ assert auth = @gateway.authorize(@amount, @visa, @options)
68
+ assert_success auth
69
+
70
+ assert capture = @gateway.capture(@amount, auth.authorization)
71
+ assert_success capture
72
+ end
73
+
74
+ def test_failed_capture
75
+ assert response = @gateway.capture(@amount, '')
76
+ assert_failure response
77
+ assert_equal 'INVALID T_REFERENCE', response.message
78
+ end
79
+
80
+ def test_authorization_and_void
81
+ assert auth = @gateway.authorize(@amount, @visa, @options)
82
+ assert_success auth
83
+
84
+ assert void = @gateway.void(auth.authorization)
85
+ assert_success void
86
+ end
87
+
88
+ def test_failed_void
89
+ assert response = @gateway.void('')
90
+ assert_failure response
91
+ assert_equal 'INVALID T_REFERENCE', response.message
92
+ end
93
+
94
+ def test_successful_credit
95
+ assert response = @gateway.credit(@amount, @visa, @options)
96
+ assert_success response
97
+ assert response.test?
98
+ end
99
+
100
+ def test_invalid_login
101
+ gateway = SageBankcardGateway.new(
102
+ :login => '',
103
+ :password => ''
104
+ )
105
+ assert response = gateway.purchase(@amount, @visa, @options)
106
+ assert_failure response
107
+ assert_equal 'SECURITY VIOLATION', response.message
108
+ end
109
+ end
@@ -0,0 +1,87 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class RemoteSageTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @gateway = SageGateway.new(fixtures(:sage))
7
+
8
+ @amount = 100
9
+
10
+ @visa = credit_card("4111111111111111")
11
+ @check = check
12
+
13
+ @options = {
14
+ :order_id => generate_unique_id,
15
+ :billing_address => address,
16
+ :shipping_address => address,
17
+ :email => 'longbob@example.com'
18
+ }
19
+ end
20
+
21
+ def test_successful_visa_purchase
22
+ assert response = @gateway.purchase(@amount, @visa, @options)
23
+ assert_success response
24
+ assert response.test?
25
+ assert_false response.authorization.blank?
26
+ end
27
+
28
+ def test_successful_check_purchase
29
+ assert response = @gateway.purchase(@amount, @check, @options)
30
+ assert_success response
31
+ assert response.test?
32
+ assert_false response.authorization.blank?
33
+ end
34
+
35
+ def test_successful_visa_authorization
36
+ assert response = @gateway.authorize(@amount, @visa, @options)
37
+ assert_success response
38
+ assert response.test?
39
+ assert_false response.authorization.blank?
40
+ end
41
+
42
+ def test_authorization_and_capture
43
+ assert auth = @gateway.authorize(@amount, @visa, @options)
44
+ assert_success auth
45
+
46
+ assert capture = @gateway.capture(@amount, auth.authorization)
47
+ assert_success capture
48
+ end
49
+
50
+ def test_visa_authorization_and_void
51
+ assert auth = @gateway.authorize(@amount, @visa, @options)
52
+ assert_success auth
53
+
54
+ assert void = @gateway.void(auth.authorization)
55
+ assert_success void
56
+ end
57
+
58
+ def test_check_purchase_and_void
59
+ assert purchase = @gateway.purchase(@amount, @check, @options)
60
+ assert_success purchase
61
+
62
+ assert void = @gateway.void(purchase.authorization)
63
+ assert_success void
64
+ end
65
+
66
+ def test_visa_credit
67
+ assert response = @gateway.credit(@amount, @visa, @options)
68
+ assert_success response
69
+ assert response.test?
70
+ end
71
+
72
+ def test_check_credit
73
+ assert response = @gateway.credit(@amount, @check, @options)
74
+ assert_success response
75
+ assert response.test?
76
+ end
77
+
78
+ def test_invalid_login
79
+ gateway = SageGateway.new(
80
+ :login => '',
81
+ :password => ''
82
+ )
83
+ assert response = gateway.purchase(@amount, @visa, @options)
84
+ assert_failure response
85
+ assert_equal 'SECURITY VIOLATION', response.message
86
+ end
87
+ end
@@ -0,0 +1,62 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class RemoteSageCheckTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @gateway = SageVirtualCheckGateway.new(fixtures(:sage))
7
+
8
+ @amount = 100
9
+ @check = check
10
+
11
+ @options = {
12
+ :order_id => generate_unique_id,
13
+ :billing_address => address,
14
+ :shipping_address => address,
15
+ :email => 'longbob@example.com',
16
+ :drivers_license_state => 'CA',
17
+ :drivers_license_number => '12345689',
18
+ :date_of_birth => Date.new(1978, 8, 11),
19
+ :ssn => '078051120'
20
+ }
21
+ end
22
+
23
+ def test_successful_check_purchase
24
+ assert response = @gateway.purchase(@amount, @check, @options)
25
+ assert_success response
26
+ assert response.test?
27
+ assert_false response.authorization.blank?
28
+ end
29
+
30
+ def test_failed_check_purchase
31
+ @check.routing_number = ""
32
+
33
+ assert response = @gateway.purchase(@amount, @check, @options)
34
+ assert_failure response
35
+ assert response.test?
36
+ assert_false response.authorization.blank?
37
+ end
38
+
39
+ def test_purchase_and_void
40
+ assert purchase = @gateway.purchase(@amount, @check, @options)
41
+ assert_success purchase
42
+
43
+ assert void = @gateway.void(purchase.authorization)
44
+ assert_success void
45
+ end
46
+
47
+ def test_credit
48
+ assert response = @gateway.credit(@amount, @check, @options)
49
+ assert_success response
50
+ assert response.test?
51
+ end
52
+
53
+ def test_invalid_login
54
+ gateway = SageVirtualCheckGateway.new(
55
+ :login => '',
56
+ :password => ''
57
+ )
58
+ assert response = gateway.purchase(@amount, @check, @options)
59
+ assert_failure response
60
+ assert_equal 'SECURITY VIOLATION', response.message
61
+ end
62
+ end
@@ -0,0 +1,76 @@
1
+ require File.join(File.dirname(__FILE__), '../../test_helper')
2
+
3
+ class RemoteWirecardTest < Test::Unit::TestCase
4
+
5
+
6
+ def setup
7
+ test_account = fixtures(:wirecard)
8
+ test_account[:signature] = test_account[:login]
9
+ @gateway = WirecardGateway.new(test_account)
10
+
11
+ @amount = 100
12
+ @credit_card = credit_card('4200000000000000')
13
+ @declined_card = credit_card('4000300011112220')
14
+
15
+ @options = {
16
+ :order_id => 1,
17
+ :billing_address => address,
18
+ :description => 'Wirecard remote test purchase',
19
+ :email => 'soleone@example.com'
20
+ }
21
+ end
22
+
23
+ # Success tested
24
+ def test_successful_authorization
25
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
26
+ assert_success response
27
+ assert response.test?
28
+ assert response.message[/THIS IS A DEMO/]
29
+ assert response.authorization
30
+ end
31
+
32
+ def test_successful_authorize_and_capture
33
+ amount = @amount
34
+ assert auth = @gateway.authorize(amount, @credit_card, @options)
35
+ assert_success auth
36
+ assert auth.message[/THIS IS A DEMO/]
37
+ assert auth.authorization
38
+ assert capture = @gateway.capture(amount, auth.authorization, @options)
39
+ assert_success capture
40
+ end
41
+
42
+ def test_successful_purchase
43
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
44
+ assert_success response
45
+ assert response.message[/THIS IS A DEMO/]
46
+ end
47
+
48
+ # Failure tested
49
+
50
+ def test_wrong_creditcard_authorization
51
+ assert response = @gateway.authorize(@amount, @declined_card, @options)
52
+ assert_failure response
53
+ assert response.test?
54
+ assert response.message[/credit card number not allowed in demo mode/i]
55
+ end
56
+
57
+ def test_wrong_creditcard_purchase
58
+ assert response = @gateway.purchase(@amount, @declined_card, @options)
59
+ assert_failure response
60
+ assert response.message[ /Credit card number not allowed in demo mode/ ]
61
+ end
62
+
63
+ def test_unauthorized_capture
64
+ assert response = @gateway.capture(@amount, "1234567890123456789012")
65
+ assert_failure response
66
+ assert response.message == "Could not find referenced transaction for GuWID 1234567890123456789012."
67
+ end
68
+
69
+ def test_invalid_login
70
+ gateway = WirecardGateway.new(:login => '', :password => '', :signature => '')
71
+ assert response = gateway.purchase(@amount, @credit_card, @options)
72
+ assert_failure response
73
+ assert response.message[ /wrong credentials/ ]
74
+ end
75
+
76
+ end
@@ -3,12 +3,24 @@ require File.dirname(__FILE__) + '/../../test_helper'
3
3
  class RemotePaypalIntegrationTest < Test::Unit::TestCase
4
4
  include ActiveMerchant::Billing::Integrations
5
5
 
6
+ def setup
7
+ @paypal = Paypal::Notification.new('')
8
+ end
9
+
10
+ def tear_down
11
+ ActiveMerchant::Billing::Base.integration_mode = :test
12
+ end
13
+
6
14
  def test_raw
7
15
  assert_equal "https://www.sandbox.paypal.com/cgi-bin/webscr", Paypal.service_url
8
- @paypal = Paypal::Notification.new('')
9
-
10
16
  assert_nothing_raised do
11
- assert_equal false, @paypal.acknowledge
17
+ assert_equal false, @paypal.acknowledge
12
18
  end
13
19
  end
20
+
21
+ def test_valid_sender_always_true
22
+ ActiveMerchant::Billing::Base.integration_mode = :production
23
+ assert @paypal.valid_sender?(nil)
24
+ assert @paypal.valid_sender?('127.0.0.1')
25
+ end
14
26
  end