activemerchant 1.1.0 → 1.2.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.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +226 -0
- data/CONTRIBUTERS +52 -0
- data/README +34 -24
- data/Rakefile +152 -0
- data/gem-public_cert.pem +20 -0
- data/init.rb +3 -0
- data/lib/active_merchant.rb +3 -1
- data/lib/active_merchant/billing/credit_card.rb +21 -17
- data/lib/active_merchant/billing/credit_card_methods.rb +17 -19
- data/lib/active_merchant/billing/gateway.rb +160 -44
- data/lib/active_merchant/billing/gateways.rb +2 -15
- data/lib/active_merchant/billing/gateways/authorize_net.rb +21 -21
- data/lib/active_merchant/billing/gateways/bogus.rb +6 -6
- data/lib/active_merchant/billing/gateways/brain_tree.rb +191 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +207 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +402 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +41 -97
- data/lib/active_merchant/billing/gateways/efsnet.rb +256 -0
- data/lib/active_merchant/billing/gateways/eway.rb +77 -29
- data/lib/active_merchant/billing/gateways/exact.rb +230 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +6 -33
- data/lib/active_merchant/billing/gateways/moneris.rb +155 -125
- data/lib/active_merchant/billing/gateways/net_registry.rb +257 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +407 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +163 -25
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +56 -38
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +10 -1
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +9 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +36 -11
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +6 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +7 -3
- data/lib/active_merchant/billing/gateways/payment_express.rb +261 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +18 -4
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +31 -15
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +8 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +33 -8
- data/lib/active_merchant/billing/gateways/plugnpay.rb +300 -0
- data/lib/active_merchant/billing/gateways/protx.rb +285 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +13 -12
- data/lib/active_merchant/billing/gateways/psl_card.rb +297 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +197 -0
- data/lib/active_merchant/billing/gateways/realex.rb +212 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +136 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +43 -20
- data/lib/active_merchant/billing/gateways/usa_epay.rb +6 -5
- data/lib/active_merchant/billing/gateways/verifi.rb +235 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
- data/lib/active_merchant/billing/integrations/gestpay/helper.rb +0 -2
- data/lib/active_merchant/billing/integrations/helper.rb +8 -1
- data/lib/active_merchant/billing/integrations/nochex.rb +62 -1
- data/lib/active_merchant/billing/integrations/nochex/notification.rb +9 -16
- data/lib/active_merchant/billing/integrations/notification.rb +1 -1
- data/lib/active_merchant/billing/integrations/paypal/helper.rb +59 -46
- data/lib/active_merchant/billing/integrations/paypal/notification.rb +14 -47
- data/lib/active_merchant/lib/error.rb +4 -0
- data/lib/active_merchant/lib/post_data.rb +22 -0
- data/lib/active_merchant/lib/posts_data.rb +23 -5
- data/lib/active_merchant/lib/requires_parameters.rb +2 -2
- data/lib/active_merchant/lib/validateable.rb +1 -1
- data/lib/support/gateway_support.rb +45 -0
- data/lib/tasks/cia.rb +1 -1
- data/script/generate +14 -0
- data/script/generator/base.rb +45 -0
- data/script/generator/generator.rb +24 -0
- data/script/generator/generators/gateway/gateway_generator.rb +14 -0
- data/script/generator/generators/gateway/templates/gateway.rb +73 -0
- data/script/generator/generators/gateway/templates/gateway_test.rb +41 -0
- data/script/generator/generators/gateway/templates/remote_gateway_test.rb +56 -0
- data/script/generator/generators/integration/integration_generator.rb +25 -0
- data/script/generator/generators/integration/templates/helper.rb +34 -0
- data/script/generator/generators/integration/templates/helper_test.rb +54 -0
- data/script/generator/generators/integration/templates/integration.rb +18 -0
- data/script/generator/generators/integration/templates/module_test.rb +9 -0
- data/script/generator/generators/integration/templates/notification.rb +100 -0
- data/script/generator/generators/integration/templates/notification_test.rb +41 -0
- data/script/generator/manifest.rb +20 -0
- data/test/extra/binding_of_caller.rb +80 -0
- data/test/extra/breakpoint.rb +547 -0
- data/test/fixtures.yml +251 -0
- data/test/remote_tests/remote_authorize_net_test.rb +113 -0
- data/test/remote_tests/remote_brain_tree_test.rb +78 -0
- data/test/remote_tests/remote_card_stream_test.rb +160 -0
- data/test/remote_tests/remote_cyber_source_test.rb +130 -0
- data/test/remote_tests/remote_data_cash_test.rb +155 -0
- data/test/remote_tests/remote_efsnet_test.rb +93 -0
- data/test/remote_tests/remote_eway_test.rb +71 -0
- data/test/remote_tests/remote_exact_test.rb +59 -0
- data/test/remote_tests/remote_gestpay_integration_test.rb +37 -0
- data/test/remote_tests/remote_linkpoint_test.rb +144 -0
- data/test/remote_tests/remote_moneris_test.rb +110 -0
- data/test/remote_tests/remote_net_registry_test.rb +120 -0
- data/test/remote_tests/remote_pay_junction_test.rb +162 -0
- data/test/remote_tests/remote_payflow_express_test.rb +50 -0
- data/test/remote_tests/remote_payflow_test.rb +241 -0
- data/test/remote_tests/remote_payflow_uk_test.rb +172 -0
- data/test/remote_tests/remote_payment_express_test.rb +136 -0
- data/test/remote_tests/remote_paypal_express_test.rb +49 -0
- data/test/remote_tests/remote_paypal_integration_test.rb +14 -0
- data/test/remote_tests/remote_paypal_test.rb +163 -0
- data/test/remote_tests/remote_plugnpay_test.rb +70 -0
- data/test/remote_tests/remote_protx_test.rb +184 -0
- data/test/remote_tests/remote_psigate_test.rb +87 -0
- data/test/remote_tests/remote_psl_card_test.rb +105 -0
- data/test/remote_tests/remote_quickpay_test.rb +182 -0
- data/test/remote_tests/remote_realex_test.rb +227 -0
- data/test/remote_tests/remote_secure_pay_test.rb +36 -0
- data/test/remote_tests/remote_trans_first_test.rb +37 -0
- data/test/remote_tests/remote_trust_commerce_test.rb +136 -0
- data/test/remote_tests/remote_usa_epay_test.rb +57 -0
- data/test/remote_tests/remote_verifi_test.rb +107 -0
- data/test/remote_tests/remote_viaklix_test.rb +53 -0
- data/test/test_helper.rb +132 -0
- data/test/unit/base_test.rb +61 -0
- data/test/unit/country_code_test.rb +33 -0
- data/test/unit/country_test.rb +64 -0
- data/test/unit/credit_card_formatting_test.rb +24 -0
- data/test/unit/credit_card_methods_test.rb +37 -0
- data/test/unit/credit_card_test.rb +365 -0
- data/test/unit/gateways/authorize_net_test.rb +140 -0
- data/test/unit/gateways/bogus_test.rb +43 -0
- data/test/unit/gateways/brain_tree_test.rb +77 -0
- data/test/unit/gateways/card_stream_test.rb +37 -0
- data/test/unit/gateways/cyber_source_test.rb +151 -0
- data/test/unit/gateways/data_cash_test.rb +23 -0
- data/test/unit/gateways/efsnet_test.rb +70 -0
- data/test/unit/gateways/eway_test.rb +105 -0
- data/test/unit/gateways/exact_test.rb +118 -0
- data/test/unit/gateways/gateway_test.rb +24 -0
- data/test/unit/gateways/linkpoint_test.rb +165 -0
- data/test/unit/gateways/moneris_test.rb +167 -0
- data/test/unit/gateways/net_registry_test.rb +478 -0
- data/test/unit/gateways/pay_junction_test.rb +61 -0
- data/test/unit/gateways/payflow_express_test.rb +165 -0
- data/test/unit/gateways/payflow_express_uk_test.rb +14 -0
- data/test/unit/gateways/payflow_test.rb +230 -0
- data/test/unit/gateways/payflow_uk_test.rb +68 -0
- data/test/unit/gateways/payment_express_test.rb +215 -0
- data/test/unit/gateways/paypal_express_test.rb +222 -0
- data/test/unit/gateways/paypal_test.rb +241 -0
- data/test/unit/gateways/plugnpay_test.rb +79 -0
- data/test/unit/gateways/protx_test.rb +110 -0
- data/test/unit/gateways/psigate_test.rb +110 -0
- data/test/unit/gateways/psl_card_test.rb +51 -0
- data/test/unit/gateways/quickpay_test.rb +125 -0
- data/test/unit/gateways/realex_test.rb +150 -0
- data/test/unit/gateways/secure_pay_test.rb +78 -0
- data/test/unit/gateways/trans_first_test.rb +125 -0
- data/test/unit/gateways/trust_commerce_test.rb +57 -0
- data/test/unit/gateways/usa_epay_test.rb +117 -0
- data/test/unit/gateways/verifi_test.rb +91 -0
- data/test/unit/gateways/viaklix_test.rb +72 -0
- data/test/unit/integrations/action_view_helper_test.rb +54 -0
- data/test/unit/integrations/bogus_module_test.rb +16 -0
- data/test/unit/integrations/chronopay_module_test.rb +9 -0
- data/test/unit/integrations/gestpay_module_test.rb +10 -0
- data/test/unit/integrations/helpers/bogus_helper_test.rb +28 -0
- data/test/unit/integrations/helpers/chronopay_helper_test.rb +67 -0
- data/test/unit/integrations/helpers/gestpay_helper_test.rb +100 -0
- data/test/unit/integrations/helpers/nochex_helper_test.rb +53 -0
- data/test/unit/integrations/helpers/paypal_helper_test.rb +162 -0
- data/test/unit/integrations/helpers/two_checkout_helper_test.rb +92 -0
- data/test/unit/integrations/nochex_module_test.rb +9 -0
- data/test/unit/integrations/notifications/chronopay_notification_test.rb +66 -0
- data/test/unit/integrations/notifications/gestpay_notification_test.rb +60 -0
- data/test/unit/integrations/notifications/nochex_notification_test.rb +51 -0
- data/test/unit/integrations/notifications/notification_test.rb +41 -0
- data/test/unit/integrations/notifications/paypal_notification_test.rb +85 -0
- data/test/unit/integrations/notifications/two_checkout_notification_test.rb +55 -0
- data/test/unit/integrations/paypal_module_test.rb +24 -0
- data/test/unit/integrations/two_checkout_module_test.rb +9 -0
- data/test/unit/post_data_test.rb +55 -0
- data/test/unit/response_test.rb +14 -0
- data/test/unit/validateable_test.rb +56 -0
- metadata +160 -7
- metadata.gz.sig +0 -0
- data/lib/active_merchant/billing/gateways/payflow/f73e89fd.0 +0 -17
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
class RemotePayflowUkTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
ActiveMerchant::Billing::Base.gateway_mode = :test
|
|
6
|
+
|
|
7
|
+
# The default partner is PayPalUk
|
|
8
|
+
@gateway = PayflowUkGateway.new(fixtures(:payflow_uk))
|
|
9
|
+
|
|
10
|
+
@creditcard = CreditCard.new(
|
|
11
|
+
:number => '5105105105105100',
|
|
12
|
+
:month => 11,
|
|
13
|
+
:year => 2009,
|
|
14
|
+
:first_name => 'Cody',
|
|
15
|
+
:last_name => 'Fauser',
|
|
16
|
+
:verification_value => '000',
|
|
17
|
+
:type => 'master'
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
@solo = CreditCard.new(
|
|
21
|
+
:type => "solo",
|
|
22
|
+
:number => "6334900000000005",
|
|
23
|
+
:month => Time.now.month,
|
|
24
|
+
:year => Time.now.year + 1,
|
|
25
|
+
:first_name => "Test",
|
|
26
|
+
:last_name => "Mensch",
|
|
27
|
+
:issue_number => '01'
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
@switch = CreditCard.new(
|
|
31
|
+
:type => "switch",
|
|
32
|
+
:number => "5641820000000005",
|
|
33
|
+
:verification_value => "000",
|
|
34
|
+
:month => 1,
|
|
35
|
+
:year => 2008,
|
|
36
|
+
:first_name => 'Fred',
|
|
37
|
+
:last_name => 'Brooks'
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
@options = { :address => {
|
|
41
|
+
:name => 'Cody Fauser',
|
|
42
|
+
:address1 => '1234 Shady Brook Lane',
|
|
43
|
+
:city => 'Ottawa',
|
|
44
|
+
:state => 'ON',
|
|
45
|
+
:country => 'CA',
|
|
46
|
+
:zip => '90210',
|
|
47
|
+
:phone => '555-555-5555'
|
|
48
|
+
},
|
|
49
|
+
:email => 'cody@example.com'
|
|
50
|
+
}
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_successful_purchase
|
|
54
|
+
assert response = @gateway.purchase(100000, @creditcard, @options)
|
|
55
|
+
assert_equal "Approved", response.message
|
|
56
|
+
assert_success response
|
|
57
|
+
assert response.test?
|
|
58
|
+
assert_not_nil response.authorization
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_declined_purchase
|
|
62
|
+
assert response = @gateway.purchase(210000, @creditcard, @options)
|
|
63
|
+
assert_equal 'Failed merchant rule check', response.message
|
|
64
|
+
assert_failure response
|
|
65
|
+
assert response.test?
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def test_successful_purchase_solo
|
|
69
|
+
assert response = @gateway.purchase(100000, @solo, @options)
|
|
70
|
+
assert_equal "Approved", response.message
|
|
71
|
+
assert_success response
|
|
72
|
+
assert response.test?
|
|
73
|
+
assert_not_nil response.authorization
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_no_card_issue_or_card_start_with_switch
|
|
77
|
+
assert response = @gateway.purchase(100000, @switch, @options)
|
|
78
|
+
assert_failure response
|
|
79
|
+
|
|
80
|
+
assert_equal "Field format error: CARDSTART or CARDISSUE must be present", response.message
|
|
81
|
+
assert_failure response
|
|
82
|
+
assert response.test?
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_successful_purchase_switch_with_issue_number
|
|
86
|
+
@switch.issue_number = '01'
|
|
87
|
+
assert response = @gateway.purchase(100000, @switch, @options)
|
|
88
|
+
assert_equal "Approved", response.message
|
|
89
|
+
assert_success response
|
|
90
|
+
assert response.test?
|
|
91
|
+
assert_not_nil response.authorization
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def test_successful_purchase_switch_with_start_date
|
|
95
|
+
@switch.start_month = 12
|
|
96
|
+
@switch.start_year = 1999
|
|
97
|
+
assert response = @gateway.purchase(100000, @switch, @options)
|
|
98
|
+
assert_equal "Approved", response.message
|
|
99
|
+
assert_success response
|
|
100
|
+
assert response.test?
|
|
101
|
+
assert_not_nil response.authorization
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def test_successful_purchase_switch_with_start_date_and_issue_number
|
|
105
|
+
@switch.issue_number = '05'
|
|
106
|
+
@switch.start_month = 12
|
|
107
|
+
@switch.start_year = 1999
|
|
108
|
+
assert response = @gateway.purchase(100000, @switch, @options)
|
|
109
|
+
assert_equal "Approved", response.message
|
|
110
|
+
assert_success response
|
|
111
|
+
assert response.test?
|
|
112
|
+
assert_not_nil response.authorization
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def test_successful_authorization
|
|
116
|
+
assert response = @gateway.authorize(100, @creditcard, @options)
|
|
117
|
+
assert_equal "Approved", response.message
|
|
118
|
+
assert_success response
|
|
119
|
+
assert response.test?
|
|
120
|
+
assert_not_nil response.authorization
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def test_authorize_and_capture
|
|
124
|
+
amount = 100
|
|
125
|
+
assert auth = @gateway.authorize(amount, @creditcard, @options)
|
|
126
|
+
assert_success auth
|
|
127
|
+
assert_equal 'Approved', auth.message
|
|
128
|
+
assert auth.authorization
|
|
129
|
+
assert capture = @gateway.capture(amount, auth.authorization)
|
|
130
|
+
assert_success capture
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def test_failed_capture
|
|
134
|
+
assert response = @gateway.capture(100, '999')
|
|
135
|
+
assert_failure response
|
|
136
|
+
assert_equal 'Invalid tender', response.message
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def test_authorize_and_void
|
|
140
|
+
assert auth = @gateway.authorize(100, @creditcard, @options)
|
|
141
|
+
assert_success auth
|
|
142
|
+
assert_equal 'Approved', auth.message
|
|
143
|
+
assert auth.authorization
|
|
144
|
+
assert void = @gateway.void(auth.authorization)
|
|
145
|
+
assert_success void
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def test_invalid_login
|
|
149
|
+
gateway = PayflowGateway.new(
|
|
150
|
+
:login => '',
|
|
151
|
+
:password => ''
|
|
152
|
+
)
|
|
153
|
+
assert response = gateway.purchase(100, @creditcard, @options)
|
|
154
|
+
assert_equal 'Invalid vendor account', response.message
|
|
155
|
+
assert_failure response
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def test_duplicate_request_id
|
|
159
|
+
gateway = PayflowUkGateway.new(
|
|
160
|
+
:login => @login,
|
|
161
|
+
:password => @password
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
request_id = Digest::SHA1.hexdigest(rand.to_s).slice(0,32)
|
|
165
|
+
gateway.expects(:generate_unique_id).times(2).returns(request_id)
|
|
166
|
+
|
|
167
|
+
response1 = gateway.purchase(100, @creditcard, @options)
|
|
168
|
+
assert_nil response1.params['duplicate']
|
|
169
|
+
response2 = gateway.purchase(100, @creditcard, @options)
|
|
170
|
+
assert response2.params['duplicate']
|
|
171
|
+
end
|
|
172
|
+
end
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
class RemotePaymentExpressTest < Test::Unit::TestCase
|
|
4
|
+
LOGIN = 'LOGIN'
|
|
5
|
+
PASSWORD = 'PASSWORD'
|
|
6
|
+
|
|
7
|
+
def setup
|
|
8
|
+
@gateway = PaymentExpressGateway.new(fixtures(:payment_express))
|
|
9
|
+
|
|
10
|
+
@creditcard = credit_card('4111111111111111')
|
|
11
|
+
|
|
12
|
+
@options = {
|
|
13
|
+
:address => {
|
|
14
|
+
:name => 'Cody Fauser',
|
|
15
|
+
:address1 => '1234 Shady Brook Lane',
|
|
16
|
+
:city => 'Ottawa',
|
|
17
|
+
:state => 'ON',
|
|
18
|
+
:country => 'CA',
|
|
19
|
+
:zip => '90210',
|
|
20
|
+
:phone => '555-555-5555'
|
|
21
|
+
},
|
|
22
|
+
:email => 'cody@example.com',
|
|
23
|
+
:description => 'Store purchase'
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_successful_purchase
|
|
28
|
+
assert response = @gateway.purchase(100, @creditcard, @options)
|
|
29
|
+
assert_equal "APPROVED", response.message
|
|
30
|
+
assert_success response
|
|
31
|
+
assert response.test?
|
|
32
|
+
assert_not_nil response.authorization
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_successful_purchase_with_reference_id
|
|
36
|
+
@options[:order_id] = rand(100000)
|
|
37
|
+
assert response = @gateway.purchase(100, @creditcard, @options)
|
|
38
|
+
assert_equal "APPROVED", response.message
|
|
39
|
+
assert_success response
|
|
40
|
+
assert response.test?
|
|
41
|
+
assert_not_nil response.authorization
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_declined_purchase
|
|
45
|
+
assert response = @gateway.purchase(176, @creditcard, @options)
|
|
46
|
+
assert_equal 'DECLINED', response.message
|
|
47
|
+
assert_failure response
|
|
48
|
+
assert response.test?
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_successful_authorization
|
|
52
|
+
assert response = @gateway.authorize(100, @creditcard, @options)
|
|
53
|
+
assert_equal "APPROVED", response.message
|
|
54
|
+
assert_success response
|
|
55
|
+
assert response.test?
|
|
56
|
+
assert_not_nil response.authorization
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_authorize_and_capture
|
|
60
|
+
amount = 100
|
|
61
|
+
assert auth = @gateway.authorize(amount, @creditcard, @options)
|
|
62
|
+
assert_success auth
|
|
63
|
+
assert_equal 'APPROVED', auth.message
|
|
64
|
+
assert auth.authorization
|
|
65
|
+
assert capture = @gateway.capture(amount, auth.authorization)
|
|
66
|
+
assert_success capture
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_purchase_and_credit
|
|
70
|
+
amount = 10000
|
|
71
|
+
assert purchase = @gateway.purchase(amount, @creditcard, @options)
|
|
72
|
+
assert_success purchase
|
|
73
|
+
assert_equal 'APPROVED', purchase.message
|
|
74
|
+
assert !purchase.authorization.blank?
|
|
75
|
+
assert credit = @gateway.credit(amount, purchase.authorization, :description => "Giving a refund")
|
|
76
|
+
assert_success credit
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def test_failed_capture
|
|
80
|
+
assert response = @gateway.capture(100, '999')
|
|
81
|
+
assert_failure response
|
|
82
|
+
assert_equal 'IVL DPSTXNREF', response.message
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_invalid_login
|
|
86
|
+
gateway = PaymentExpressGateway.new(
|
|
87
|
+
:login => '',
|
|
88
|
+
:password => ''
|
|
89
|
+
)
|
|
90
|
+
assert response = gateway.purchase(100, @creditcard, @options)
|
|
91
|
+
assert_equal 'Invalid Credentials', response.message
|
|
92
|
+
assert_failure response
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def test_store_credit_card
|
|
96
|
+
assert response = @gateway.store(@creditcard)
|
|
97
|
+
assert_success response
|
|
98
|
+
assert_equal "APPROVED", response.message
|
|
99
|
+
assert !response.token.blank?
|
|
100
|
+
assert_not_nil response.token
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def test_store_with_custom_token
|
|
104
|
+
token = Time.now.to_i.to_s #hehe
|
|
105
|
+
assert response = @gateway.store(@creditcard, :billing_id => token)
|
|
106
|
+
assert_success response
|
|
107
|
+
assert_equal "APPROVED", response.message
|
|
108
|
+
assert !response.token.blank?
|
|
109
|
+
assert_not_nil response.token
|
|
110
|
+
assert_equal token, response.token
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def test_store_invalid_credit_card
|
|
114
|
+
original_number = @creditcard.number
|
|
115
|
+
@creditcard.number = 2
|
|
116
|
+
|
|
117
|
+
assert response = @gateway.store(@creditcard)
|
|
118
|
+
assert_failure response
|
|
119
|
+
ensure
|
|
120
|
+
@creditcard.number = original_number
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def test_store_and_charge
|
|
124
|
+
assert response = @gateway.store(@creditcard)
|
|
125
|
+
assert_success response
|
|
126
|
+
assert_equal "APPROVED", response.message
|
|
127
|
+
assert (token = response.token)
|
|
128
|
+
|
|
129
|
+
assert purchase = @gateway.purchase( 100, token)
|
|
130
|
+
assert_equal "APPROVED", purchase.message
|
|
131
|
+
assert_success purchase
|
|
132
|
+
assert_not_nil purchase.authorization
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
class PaypalExpressTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
Base.gateway_mode = :test
|
|
6
|
+
|
|
7
|
+
@gateway = PaypalExpressGateway.new(fixtures(:paypal))
|
|
8
|
+
|
|
9
|
+
@options = {
|
|
10
|
+
:order_id => '230000',
|
|
11
|
+
:email => 'buyer@jadedpallet.com',
|
|
12
|
+
:address => { :name => 'Fred Brooks',
|
|
13
|
+
:address1 => '1234 Penny Lane',
|
|
14
|
+
:city => 'Jonsetown',
|
|
15
|
+
:state => 'NC',
|
|
16
|
+
:country => 'US',
|
|
17
|
+
:zip => '23456'
|
|
18
|
+
} ,
|
|
19
|
+
:description => 'Stuff that you purchased, yo!',
|
|
20
|
+
:ip => '10.0.0.1',
|
|
21
|
+
:return_url => 'http://example.com/return',
|
|
22
|
+
:cancel_return_url => 'http://example.com/cancel'
|
|
23
|
+
}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_set_express_authorization
|
|
27
|
+
@options.update(
|
|
28
|
+
:return_url => 'http://example.com',
|
|
29
|
+
:cancel_return_url => 'http://example.com',
|
|
30
|
+
:email => 'Buyer1@paypal.com'
|
|
31
|
+
)
|
|
32
|
+
response = @gateway.setup_authorization(500, @options)
|
|
33
|
+
assert response.success?
|
|
34
|
+
assert response.test?
|
|
35
|
+
assert !response.params['token'].blank?
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_set_express_purchase
|
|
39
|
+
@options.update(
|
|
40
|
+
:return_url => 'http://example.com',
|
|
41
|
+
:cancel_return_url => 'http://example.com',
|
|
42
|
+
:email => 'Buyer1@paypal.com'
|
|
43
|
+
)
|
|
44
|
+
response = @gateway.setup_purchase(500, @options)
|
|
45
|
+
assert response.success?
|
|
46
|
+
assert response.test?
|
|
47
|
+
assert !response.params['token'].blank?
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
class RemotePaypalIntegrationTest < Test::Unit::TestCase
|
|
4
|
+
include ActiveMerchant::Billing::Integrations
|
|
5
|
+
|
|
6
|
+
def test_raw
|
|
7
|
+
assert_equal "https://www.sandbox.paypal.com/cgi-bin/webscr", Paypal.service_url
|
|
8
|
+
@paypal = Paypal::Notification.new('')
|
|
9
|
+
|
|
10
|
+
assert_nothing_raised do
|
|
11
|
+
assert_equal false, @paypal.acknowledge
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
class PaypalTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
Base.gateway_mode = :test
|
|
6
|
+
|
|
7
|
+
@gateway = PaypalGateway.new(fixtures(:paypal))
|
|
8
|
+
|
|
9
|
+
@creditcard = CreditCard.new(
|
|
10
|
+
:type => "Visa",
|
|
11
|
+
:number => "4381258770269608", # Use a generated CC from the paypal Sandbox
|
|
12
|
+
:verification_value => "000",
|
|
13
|
+
:month => 1,
|
|
14
|
+
:year => 2008,
|
|
15
|
+
:first_name => 'Fred',
|
|
16
|
+
:last_name => 'Brooks'
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
@params = {
|
|
20
|
+
:order_id => generate_order_id,
|
|
21
|
+
:email => 'buyer@jadedpallet.com',
|
|
22
|
+
:address => { :name => 'Fred Brooks',
|
|
23
|
+
:address1 => '1234 Penny Lane',
|
|
24
|
+
:city => 'Jonsetown',
|
|
25
|
+
:state => 'NC',
|
|
26
|
+
:country => 'US',
|
|
27
|
+
:zip => '23456'
|
|
28
|
+
} ,
|
|
29
|
+
:description => 'Stuff that you purchased, yo!',
|
|
30
|
+
:ip => '10.0.0.1',
|
|
31
|
+
:return_url => 'http://example.com/return',
|
|
32
|
+
:cancel_return_url => 'http://example.com/cancel'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
# test re-authorization, auth-id must be more than 3 days old.
|
|
36
|
+
# each auth-id can only be reauthorized and tested once.
|
|
37
|
+
# leave it commented if you don't want to test reauthorization.
|
|
38
|
+
#
|
|
39
|
+
#@three_days_old_auth_id = "9J780651TU4465545"
|
|
40
|
+
#@three_days_old_auth_id2 = "62503445A3738160X"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_successful_purchase
|
|
44
|
+
response = @gateway.purchase(300, @creditcard, @params)
|
|
45
|
+
assert_success response
|
|
46
|
+
assert response.params['transaction_id']
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_failed_purchase
|
|
50
|
+
@creditcard.number = '234234234234'
|
|
51
|
+
response = @gateway.purchase(300, @creditcard, @params)
|
|
52
|
+
assert_failure response
|
|
53
|
+
assert_nil response.params['transaction_id']
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_successful_authorization
|
|
57
|
+
response = @gateway.authorize(300, @creditcard, @params)
|
|
58
|
+
assert_success response
|
|
59
|
+
assert response.params['transaction_id']
|
|
60
|
+
assert_equal '3.00', response.params['amount']
|
|
61
|
+
assert_equal 'USD', response.params['amount_currency_id']
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_failed_authorization
|
|
65
|
+
@creditcard.number = '234234234234'
|
|
66
|
+
response = @gateway.authorize(300, @creditcard, @params)
|
|
67
|
+
assert_failure response
|
|
68
|
+
assert_nil response.params['transaction_id']
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_successful_reauthorization
|
|
72
|
+
return if not @three_days_old_auth_id
|
|
73
|
+
auth = @gateway.reauthorize(1000, @three_days_old_auth_id)
|
|
74
|
+
assert_success auth
|
|
75
|
+
assert auth.authorization
|
|
76
|
+
|
|
77
|
+
response = @gateway.capture(1000, auth.authorization)
|
|
78
|
+
assert_success response
|
|
79
|
+
assert response.params['transaction_id']
|
|
80
|
+
assert_equal '10.00', response.params['gross_amount']
|
|
81
|
+
assert_equal 'USD', response.params['gross_amount_currency_id']
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def test_failed_reauthorization
|
|
85
|
+
return if not @three_days_old_auth_id2 # was authed for $10, attempt $20
|
|
86
|
+
auth = @gateway.reauthorize(2000, @three_days_old_auth_id2)
|
|
87
|
+
assert_false auth?
|
|
88
|
+
assert !auth.authorization
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def test_successful_capture
|
|
92
|
+
auth = @gateway.authorize(300, @creditcard, @params)
|
|
93
|
+
assert_success auth
|
|
94
|
+
response = @gateway.capture(300, auth.authorization)
|
|
95
|
+
assert_success response
|
|
96
|
+
assert response.params['transaction_id']
|
|
97
|
+
assert_equal '3.00', response.params['gross_amount']
|
|
98
|
+
assert_equal 'USD', response.params['gross_amount_currency_id']
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def test_successful_voiding
|
|
102
|
+
auth = @gateway.authorize(300, @creditcard, @params)
|
|
103
|
+
assert_success auth
|
|
104
|
+
response = @gateway.void(auth.authorization)
|
|
105
|
+
assert_success response
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def test_purchase_and_full_credit
|
|
109
|
+
amount = 300
|
|
110
|
+
|
|
111
|
+
purchase = @gateway.purchase(amount, @creditcard, @params)
|
|
112
|
+
assert_success purchase
|
|
113
|
+
|
|
114
|
+
credit = @gateway.credit(amount, purchase.authorization, :note => 'Sorry')
|
|
115
|
+
assert_success credit
|
|
116
|
+
assert credit.test?
|
|
117
|
+
assert_equal 'USD', credit.params['net_refund_amount_currency_id']
|
|
118
|
+
assert_equal '2.61', credit.params['net_refund_amount']
|
|
119
|
+
assert_equal 'USD', credit.params['gross_refund_amount_currency_id']
|
|
120
|
+
assert_equal '3.00', credit.params['gross_refund_amount']
|
|
121
|
+
assert_equal 'USD', credit.params['fee_refund_amount_currency_id']
|
|
122
|
+
assert_equal '0.39', credit.params['fee_refund_amount']
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def test_failed_voiding
|
|
126
|
+
response = @gateway.void('foo')
|
|
127
|
+
assert_failure response
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def test_successful_transfer
|
|
131
|
+
response = @gateway.purchase(300, @creditcard, @params)
|
|
132
|
+
assert_success response, response.message
|
|
133
|
+
|
|
134
|
+
response = @gateway.transfer(300, 'joe@example.com', :subject => 'Your money', :note => 'Thanks for taking care of that')
|
|
135
|
+
assert_success response, response.message
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def test_failed_transfer
|
|
139
|
+
# paypal allows a max transfer of $10,000
|
|
140
|
+
response = @gateway.transfer(1000001, 'joe@example.com')
|
|
141
|
+
assert_failure response, response.message
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def test_successful_multiple_transfer
|
|
145
|
+
response = @gateway.purchase(900, @creditcard, @params)
|
|
146
|
+
assert_success response, response.message
|
|
147
|
+
|
|
148
|
+
response = @gateway.transfer([300, 'joe@example.com'],
|
|
149
|
+
[600, 'jane@example.com', {:note => 'Thanks for taking care of that'}],
|
|
150
|
+
:subject => 'Your money')
|
|
151
|
+
assert_success response, response.message
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def test_failed_multiple_transfer
|
|
155
|
+
response = @gateway.purchase(25100, @creditcard, @params)
|
|
156
|
+
assert_success response, response.message
|
|
157
|
+
|
|
158
|
+
# You can only include up to 250 recipients
|
|
159
|
+
recipients = (1..251).collect {|i| [100, "person#{i}@example.com"]}
|
|
160
|
+
response = @gateway.transfer(*recipients)
|
|
161
|
+
assert_failure response, response.message
|
|
162
|
+
end
|
|
163
|
+
end
|