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,162 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
class PayJunctionTest < Test::Unit::TestCase
|
|
4
|
+
include ActiveMerchant::Billing
|
|
5
|
+
|
|
6
|
+
cattr_accessor :current_invoice
|
|
7
|
+
|
|
8
|
+
AMOUNT = 250
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
@gateway = PayJunctionGateway.new(fixtures(:pay_junction))
|
|
12
|
+
|
|
13
|
+
@creditcard = credit_card('4433221111223344')
|
|
14
|
+
|
|
15
|
+
@valid_verification_value = '123'
|
|
16
|
+
@invalid_verification_value = '1234'
|
|
17
|
+
|
|
18
|
+
@valid_address = {
|
|
19
|
+
:address1 => '123 Test St.',
|
|
20
|
+
:address2 => nil,
|
|
21
|
+
:city => 'Somewhere',
|
|
22
|
+
:state => 'CA',
|
|
23
|
+
:zip => '90001'
|
|
24
|
+
}
|
|
25
|
+
@invalid_address = {
|
|
26
|
+
:address1 => '187 Apple Tree Lane.',
|
|
27
|
+
:address2 => nil,
|
|
28
|
+
:city => 'Woodside',
|
|
29
|
+
:state => 'CA',
|
|
30
|
+
:zip => '94062'
|
|
31
|
+
}
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_successful_purchase
|
|
35
|
+
assert response = @gateway.purchase(AMOUNT,
|
|
36
|
+
@creditcard,
|
|
37
|
+
:order_id => generate_order_id)
|
|
38
|
+
|
|
39
|
+
#p response
|
|
40
|
+
assert_equal Response, response.class
|
|
41
|
+
assert_match /APPROVAL/, response.message
|
|
42
|
+
assert_equal 'capture', response.params["posture"], 'Should be captured funds'
|
|
43
|
+
assert_equal 'charge', response.params["transaction_action"]
|
|
44
|
+
|
|
45
|
+
assert_equal true, response.success?
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_successful_purchase_with_cvv
|
|
49
|
+
@creditcard.verification_value = @valid_verification_value
|
|
50
|
+
assert response = @gateway.purchase(AMOUNT,
|
|
51
|
+
@creditcard,
|
|
52
|
+
:order_id => generate_order_id)
|
|
53
|
+
|
|
54
|
+
assert_equal Response, response.class
|
|
55
|
+
assert_match /APPROVAL/, response.message
|
|
56
|
+
assert_equal 'capture', response.params["posture"], 'Should be captured funds'
|
|
57
|
+
assert_equal 'charge', response.params["transaction_action"]
|
|
58
|
+
|
|
59
|
+
assert_equal true, response.success?
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_successful_authorize
|
|
63
|
+
assert response = @gateway.authorize( AMOUNT,
|
|
64
|
+
@creditcard,
|
|
65
|
+
:order_id => generate_order_id)
|
|
66
|
+
|
|
67
|
+
assert_equal Response, response.class
|
|
68
|
+
assert_match /APPROVAL/, response.message
|
|
69
|
+
assert_equal 'hold', response.params["posture"], 'Should be a held charge'
|
|
70
|
+
assert_equal 'charge', response.params["transaction_action"]
|
|
71
|
+
|
|
72
|
+
assert_equal true, response.success?
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_successful_capture
|
|
76
|
+
order_id = generate_order_id
|
|
77
|
+
auth = @gateway.authorize(AMOUNT, @creditcard, :order_id => order_id)
|
|
78
|
+
assert_success auth
|
|
79
|
+
response = @gateway.capture(AMOUNT, auth.authorization, :order_id => order_id)
|
|
80
|
+
|
|
81
|
+
assert_success response
|
|
82
|
+
assert_equal 'capture', response.params["posture"], 'Should be a capture'
|
|
83
|
+
assert_equal auth.authorization, response.authorization,
|
|
84
|
+
"Should maintain transaction ID across request"
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def test_successful_credit
|
|
88
|
+
purchase = @gateway.purchase(AMOUNT, @creditcard, :order_id => generate_order_id)
|
|
89
|
+
assert_success purchase
|
|
90
|
+
|
|
91
|
+
assert response = @gateway.credit(success_price, purchase.authorization)
|
|
92
|
+
|
|
93
|
+
assert_equal Response, response.class
|
|
94
|
+
assert_equal 'refund', response.params["transaction_action"]
|
|
95
|
+
|
|
96
|
+
assert_equal true, response.success?
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def test_successful_void
|
|
100
|
+
order_id = generate_order_id
|
|
101
|
+
purchase = @gateway.purchase(AMOUNT, @creditcard, :order_id => order_id)
|
|
102
|
+
assert_success purchase
|
|
103
|
+
|
|
104
|
+
assert response = @gateway.void(AMOUNT, purchase.authorization, :order_id => order_id)
|
|
105
|
+
assert_equal Response, response.class
|
|
106
|
+
|
|
107
|
+
assert_equal true, response.success?
|
|
108
|
+
assert_equal 'void', response.params["posture"], 'Should be a capture'
|
|
109
|
+
assert_equal purchase.authorization, response.authorization,
|
|
110
|
+
"Should maintain transaction ID across request"
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def test_successful_instant_purchase
|
|
114
|
+
# this takes advatange of the PayJunction feature where another
|
|
115
|
+
# transaction can be executed if you have the transaction ID of a
|
|
116
|
+
# previous successful transaction.
|
|
117
|
+
|
|
118
|
+
purchase = @gateway.purchase( AMOUNT,
|
|
119
|
+
@creditcard,
|
|
120
|
+
:order_id => generate_order_id)
|
|
121
|
+
assert_success purchase
|
|
122
|
+
|
|
123
|
+
assert response = @gateway.purchase(AMOUNT,
|
|
124
|
+
purchase.authorization,
|
|
125
|
+
:order_id => generate_order_id)
|
|
126
|
+
|
|
127
|
+
assert_equal Response, response.class
|
|
128
|
+
assert_match /APPROVAL/, response.message
|
|
129
|
+
assert_equal 'capture', response.params["posture"], 'Should be captured funds'
|
|
130
|
+
assert_equal 'charge', response.params["transaction_action"]
|
|
131
|
+
assert_not_equal purchase.authorization, response.authorization,
|
|
132
|
+
'Should have recieved new transaction ID'
|
|
133
|
+
|
|
134
|
+
assert_equal true, response.success?
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def test_successful_recurring
|
|
138
|
+
assert response = @gateway.recurring(AMOUNT, @creditcard,
|
|
139
|
+
:periodicity => :monthly,
|
|
140
|
+
:payments => 12,
|
|
141
|
+
:order_id => generate_order_id)
|
|
142
|
+
assert_equal Response, response.class
|
|
143
|
+
assert_match /APPROVAL/, response.message
|
|
144
|
+
assert_equal 'charge', response.params["transaction_action"]
|
|
145
|
+
|
|
146
|
+
assert_equal true, response.success?
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def test_should_send_invoice
|
|
150
|
+
order_id = generate_order_id
|
|
151
|
+
|
|
152
|
+
response = @gateway.purchase(AMOUNT, @creditcard, :order_id => order_id)
|
|
153
|
+
assert_success response
|
|
154
|
+
|
|
155
|
+
assert_equal order_id, response.params["invoice_number"], 'Should have set invoice'
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
private
|
|
159
|
+
def success_price
|
|
160
|
+
200 + rand(200)
|
|
161
|
+
end
|
|
162
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
class RemotePayflowTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
Base.gateway_mode = :test
|
|
6
|
+
|
|
7
|
+
@gateway = PayflowExpressGateway.new(fixtures(:payflow))
|
|
8
|
+
|
|
9
|
+
@options = { :address => {
|
|
10
|
+
:name => 'Cody Fauser',
|
|
11
|
+
:address1 => '1234 Shady Brook Lane',
|
|
12
|
+
:city => 'Ottawa',
|
|
13
|
+
:state => 'ON',
|
|
14
|
+
:country => 'CA',
|
|
15
|
+
:zip => '90210',
|
|
16
|
+
:phone => '555-555-5555'
|
|
17
|
+
},
|
|
18
|
+
:email => 'cody@example.com'
|
|
19
|
+
}
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Only works with a Payflow 2.0 account or by requesting the addition
|
|
23
|
+
# of Express checkout to an existing Payflow Pro account. This can be done
|
|
24
|
+
# by contacting Payflow sales. The PayPal account used must be a business
|
|
25
|
+
# account and the Payflow Pro account must be in Live mode in order for
|
|
26
|
+
# the tests to work correctly
|
|
27
|
+
def test_set_express_authorization
|
|
28
|
+
@options.update(
|
|
29
|
+
:return_url => 'http://example.com',
|
|
30
|
+
:cancel_return_url => 'http://example.com',
|
|
31
|
+
:email => 'Buyer1@paypal.com'
|
|
32
|
+
)
|
|
33
|
+
response = @gateway.setup_authorization(500, @options)
|
|
34
|
+
assert response.success?
|
|
35
|
+
assert response.test?
|
|
36
|
+
assert !response.params['token'].blank?
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_set_express_purchase
|
|
40
|
+
@options.update(
|
|
41
|
+
:return_url => 'http://example.com',
|
|
42
|
+
:cancel_return_url => 'http://example.com',
|
|
43
|
+
:email => 'Buyer1@paypal.com'
|
|
44
|
+
)
|
|
45
|
+
response = @gateway.setup_purchase(500, @options)
|
|
46
|
+
assert response.success?
|
|
47
|
+
assert response.test?
|
|
48
|
+
assert !response.params['token'].blank?
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
class RemotePayflowTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
ActiveMerchant::Billing::Base.gateway_mode = :test
|
|
6
|
+
|
|
7
|
+
@gateway = PayflowGateway.new(fixtures(:payflow))
|
|
8
|
+
|
|
9
|
+
@creditcard = credit_card('5105105105105100',
|
|
10
|
+
:type => 'master'
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
@options = { :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
|
+
}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_successful_purchase
|
|
27
|
+
assert response = @gateway.purchase(100000, @creditcard, @options)
|
|
28
|
+
assert_equal "Approved", response.message
|
|
29
|
+
assert_success response
|
|
30
|
+
assert response.test?
|
|
31
|
+
assert_not_nil response.authorization
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_declined_purchase
|
|
35
|
+
assert response = @gateway.purchase(210000, @creditcard, @options)
|
|
36
|
+
assert_equal 'Declined', response.message
|
|
37
|
+
assert_failure response
|
|
38
|
+
assert response.test?
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_successful_authorization
|
|
42
|
+
assert response = @gateway.authorize(100, @creditcard, @options)
|
|
43
|
+
assert_equal "Approved", response.message
|
|
44
|
+
assert_success response
|
|
45
|
+
assert response.test?
|
|
46
|
+
assert_not_nil response.authorization
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_authorize_and_capture
|
|
50
|
+
assert auth = @gateway.authorize(100, @creditcard, @options)
|
|
51
|
+
assert_success auth
|
|
52
|
+
assert_equal 'Approved', auth.message
|
|
53
|
+
assert auth.authorization
|
|
54
|
+
assert capture = @gateway.capture(100, auth.authorization)
|
|
55
|
+
assert_success capture
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_authorize_and_partial_capture
|
|
59
|
+
assert auth = @gateway.authorize(100 * 2, @creditcard, @options)
|
|
60
|
+
assert_success auth
|
|
61
|
+
assert_equal 'Approved', auth.message
|
|
62
|
+
assert auth.authorization
|
|
63
|
+
|
|
64
|
+
assert capture = @gateway.capture(100, auth.authorization)
|
|
65
|
+
assert_success capture
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def test_failed_capture
|
|
69
|
+
assert response = @gateway.capture(100, '999')
|
|
70
|
+
assert_failure response
|
|
71
|
+
assert_equal 'Invalid tender', response.message
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def test_authorize_and_void
|
|
75
|
+
assert auth = @gateway.authorize(100, @creditcard, @options)
|
|
76
|
+
assert_success auth
|
|
77
|
+
assert_equal 'Approved', auth.message
|
|
78
|
+
assert auth.authorization
|
|
79
|
+
assert void = @gateway.void(auth.authorization)
|
|
80
|
+
assert_success void
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def test_invalid_login
|
|
84
|
+
gateway = PayflowGateway.new(
|
|
85
|
+
:login => '',
|
|
86
|
+
:password => ''
|
|
87
|
+
)
|
|
88
|
+
assert response = gateway.purchase(100, @creditcard, @options)
|
|
89
|
+
assert_equal 'Invalid vendor account', response.message
|
|
90
|
+
assert_failure response
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def test_duplicate_request_id
|
|
94
|
+
gateway = PayflowGateway.new(
|
|
95
|
+
:login => @login,
|
|
96
|
+
:password => @password,
|
|
97
|
+
:partner => @partner
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
request_id = Digest::MD5.hexdigest(rand.to_s)
|
|
101
|
+
gateway.expects(:generate_unique_id).times(2).returns(request_id)
|
|
102
|
+
|
|
103
|
+
response1 = gateway.purchase(100, @creditcard, @options)
|
|
104
|
+
assert_nil response1.params['duplicate']
|
|
105
|
+
response2 = gateway.purchase(100, @creditcard, @options)
|
|
106
|
+
assert response2.params['duplicate']
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def test_create_recurring_profile
|
|
110
|
+
response = @gateway.recurring(1000, @creditcard, :periodicity => :monthly)
|
|
111
|
+
assert_success response
|
|
112
|
+
assert !response.params['profile_id'].blank?
|
|
113
|
+
assert response.test?
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def test_create_recurring_profile_with_invalid_date
|
|
117
|
+
response = @gateway.recurring(1000, @creditcard, :periodicity => :monthly, :starting_at => Time.now)
|
|
118
|
+
assert_failure response
|
|
119
|
+
assert_equal 'Field format error: Start or next payment date must be a valid future date', response.message
|
|
120
|
+
assert response.params['profile_id'].blank?
|
|
121
|
+
assert response.test?
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def test_create_and_cancel_recurring_profile
|
|
125
|
+
response = @gateway.recurring(1000, @creditcard, :periodicity => :monthly)
|
|
126
|
+
assert_success response
|
|
127
|
+
assert !response.params['profile_id'].blank?
|
|
128
|
+
assert response.test?
|
|
129
|
+
|
|
130
|
+
response = @gateway.cancel_recurring(response.params['profile_id'])
|
|
131
|
+
assert_success response
|
|
132
|
+
assert response.test?
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def test_full_feature_set_for_recurring_profiles
|
|
136
|
+
# Test add
|
|
137
|
+
@options.update(
|
|
138
|
+
:periodicity => :weekly,
|
|
139
|
+
:payments => '12',
|
|
140
|
+
:starting_at => Time.now + 1.day,
|
|
141
|
+
:comment => "Test Profile"
|
|
142
|
+
)
|
|
143
|
+
response = @gateway.recurring(100, @creditcard, @options)
|
|
144
|
+
assert_equal "Approved", response.params['message']
|
|
145
|
+
assert_equal "0", response.params['result']
|
|
146
|
+
assert_success response
|
|
147
|
+
assert response.test?
|
|
148
|
+
assert !response.params['profile_id'].blank?
|
|
149
|
+
@recurring_profile_id = response.params['profile_id']
|
|
150
|
+
|
|
151
|
+
# Test modify
|
|
152
|
+
@options.update(
|
|
153
|
+
:periodicity => :monthly,
|
|
154
|
+
:starting_at => Time.now + 1.day,
|
|
155
|
+
:payments => '4',
|
|
156
|
+
:profile_id => @recurring_profile_id
|
|
157
|
+
)
|
|
158
|
+
response = @gateway.recurring(400, @creditcard, @options)
|
|
159
|
+
assert_equal "Approved", response.params['message']
|
|
160
|
+
assert_equal "0", response.params['result']
|
|
161
|
+
assert_success response
|
|
162
|
+
assert response.test?
|
|
163
|
+
|
|
164
|
+
# Test inquiry
|
|
165
|
+
response = @gateway.recurring_inquiry(@recurring_profile_id)
|
|
166
|
+
assert_equal "0", response.params['result']
|
|
167
|
+
assert_success response
|
|
168
|
+
assert response.test?
|
|
169
|
+
|
|
170
|
+
# Test cancel
|
|
171
|
+
response = @gateway.cancel_recurring(@recurring_profile_id)
|
|
172
|
+
assert_equal "Approved", response.params['message']
|
|
173
|
+
assert_equal "0", response.params['result']
|
|
174
|
+
assert_success response
|
|
175
|
+
assert response.test?
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# Note that this test will only work if you enable reference transactions!!
|
|
179
|
+
def test_reference_purchase
|
|
180
|
+
assert response = @gateway.purchase(10000, @creditcard, @options)
|
|
181
|
+
assert_equal "Approved", response.message
|
|
182
|
+
assert_success response
|
|
183
|
+
assert response.test?
|
|
184
|
+
assert_not_nil pn_ref = response.authorization
|
|
185
|
+
|
|
186
|
+
# now another purchase, by reference
|
|
187
|
+
assert response = @gateway.purchase(10000, pn_ref)
|
|
188
|
+
assert_equal "Approved", response.message
|
|
189
|
+
assert_success response
|
|
190
|
+
assert response.test?
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def test_recurring_with_initial_authorization
|
|
194
|
+
response = @gateway.recurring(1000, @creditcard,
|
|
195
|
+
:periodicity => :monthly,
|
|
196
|
+
:initial_transaction => {
|
|
197
|
+
:type => :authorization
|
|
198
|
+
}
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
assert_success response
|
|
202
|
+
assert !response.params['profile_id'].blank?
|
|
203
|
+
assert response.test?
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def test_recurring_with_initial_authorization
|
|
207
|
+
response = @gateway.recurring(1000, @creditcard,
|
|
208
|
+
:periodicity => :monthly,
|
|
209
|
+
:initial_transaction => {
|
|
210
|
+
:type => :purchase,
|
|
211
|
+
:amount => 500
|
|
212
|
+
}
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
assert_success response
|
|
216
|
+
assert !response.params['profile_id'].blank?
|
|
217
|
+
assert response.test?
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def test_purchase_and_referenced_credit
|
|
221
|
+
amount = 100
|
|
222
|
+
|
|
223
|
+
assert purchase = @gateway.purchase(amount, @creditcard, @options)
|
|
224
|
+
assert_success purchase
|
|
225
|
+
assert_equal 'Approved', purchase.message
|
|
226
|
+
assert !purchase.authorization.blank?
|
|
227
|
+
|
|
228
|
+
assert credit = @gateway.credit(amount, purchase.authorization)
|
|
229
|
+
assert_success credit
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
# The default security setting for Payflow Pro accounts is Allow
|
|
233
|
+
# non-referenced credits = No.
|
|
234
|
+
#
|
|
235
|
+
# Non-referenced credits will fail with Result code 117 (failed the security
|
|
236
|
+
# check) unless Allow non-referenced credits = Yes in PayPal manager
|
|
237
|
+
def test_purchase_and_non_referenced_credit
|
|
238
|
+
assert credit = @gateway.credit(100, @creditcard, @options)
|
|
239
|
+
assert_success credit
|
|
240
|
+
end
|
|
241
|
+
end
|