judopay 2.1.0 → 2.1.3
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.
- checksums.yaml +5 -5
- data/.gitignore +24 -23
- data/.rspec +1 -1
- data/.rubocop.yml +54 -51
- data/.travis.yml +6 -6
- data/CHANGELOG.md +17 -17
- data/Gemfile +4 -4
- data/LICENSE +21 -21
- data/README.md +96 -94
- data/Rakefile +22 -22
- data/judopay.gemspec +38 -38
- data/lib/certs/digicert_sha256_ca.pem +49 -49
- data/lib/certs/rapidssl_ca.crt +63 -63
- data/lib/faraday/judo_mashify.rb +11 -11
- data/lib/faraday/raise_http_exception.rb +19 -19
- data/lib/judopay.rb +70 -70
- data/lib/judopay/api.rb +10 -10
- data/lib/judopay/connection.rb +77 -77
- data/lib/judopay/core_ext/hash.rb +29 -29
- data/lib/judopay/core_ext/string.rb +32 -32
- data/lib/judopay/error.rb +117 -115
- data/lib/judopay/mash.rb +11 -11
- data/lib/judopay/model.rb +134 -134
- data/lib/judopay/models/android_payment.rb +26 -26
- data/lib/judopay/models/android_preauth.rb +8 -8
- data/lib/judopay/models/apple_payment.rb +26 -26
- data/lib/judopay/models/apple_preauth.rb +9 -9
- data/lib/judopay/models/card_address.rb +11 -11
- data/lib/judopay/models/card_payment.rb +33 -33
- data/lib/judopay/models/card_preauth.rb +11 -11
- data/lib/judopay/models/collection.rb +16 -16
- data/lib/judopay/models/encrypt_details.rb +18 -0
- data/lib/judopay/models/inner/pk_payment.rb +17 -17
- data/lib/judopay/models/inner/pk_payment_token.rb +13 -13
- data/lib/judopay/models/inner/transmitted_field.rb +39 -39
- data/lib/judopay/models/inner/wallet.rb +30 -30
- data/lib/judopay/models/market/collection.rb +10 -10
- data/lib/judopay/models/market/payment.rb +10 -10
- data/lib/judopay/models/market/preauth.rb +10 -10
- data/lib/judopay/models/market/refund.rb +10 -10
- data/lib/judopay/models/market/transaction.rb +10 -10
- data/lib/judopay/models/one_use_token_payment.rb +29 -0
- data/lib/judopay/models/payment.rb +8 -8
- data/lib/judopay/models/preauth.rb +8 -8
- data/lib/judopay/models/refund.rb +16 -16
- data/lib/judopay/models/register_card.rb +27 -27
- data/lib/judopay/models/save_card.rb +24 -25
- data/lib/judopay/models/token_payment.rb +30 -30
- data/lib/judopay/models/token_preauth.rb +10 -10
- data/lib/judopay/models/transaction.rb +8 -8
- data/lib/judopay/models/void.rb +19 -19
- data/lib/judopay/models/web_payments/payment.rb +28 -28
- data/lib/judopay/models/web_payments/preauth.rb +10 -10
- data/lib/judopay/models/web_payments/transaction.rb +19 -19
- data/lib/judopay/models/web_payments/web_payment_operation.rb +8 -8
- data/lib/judopay/null_logger.rb +9 -11
- data/lib/judopay/request.rb +50 -50
- data/lib/judopay/response.rb +7 -7
- data/lib/judopay/serializer.rb +27 -27
- data/lib/judopay/version.rb +4 -4
- data/spec/factories.rb +227 -208
- data/spec/faraday/response_spec.rb +27 -27
- data/spec/fixtures/card_payments/create.json +21 -21
- data/spec/fixtures/card_payments/create_3dsecure.json +7 -7
- data/spec/fixtures/card_payments/create_bad_request.json +12 -12
- data/spec/fixtures/card_payments/create_declined.json +23 -23
- data/spec/fixtures/card_payments/validate.json +4 -4
- data/spec/fixtures/token_payments/create.json +21 -21
- data/spec/fixtures/transactions/all.json +237 -237
- data/spec/fixtures/transactions/android_payment.json +26 -26
- data/spec/fixtures/transactions/apple_payment.json +26 -26
- data/spec/fixtures/transactions/find.json +22 -22
- data/spec/fixtures/transactions/find_not_found.json +4 -4
- data/spec/fixtures/transactions/register_card.json +28 -28
- data/spec/fixtures/transactions/save_card.json +27 -27
- data/spec/fixtures/transactions/void.json +26 -26
- data/spec/fixtures/web_payments/payments/create.json +3 -3
- data/spec/fixtures/web_payments/payments/find.json +38 -38
- data/spec/judopay/android_payment_spec.rb +74 -74
- data/spec/judopay/apple_payment_spec.rb +80 -80
- data/spec/judopay/card_address_spec.rb +10 -10
- data/spec/judopay/card_payment_spec.rb +51 -63
- data/spec/judopay/card_preauth_spec.rb +35 -35
- data/spec/judopay/collection_spec.rb +26 -26
- data/spec/judopay/core_ext/hash_spec.rb +24 -24
- data/spec/judopay/core_ext/string_spec.rb +16 -16
- data/spec/judopay/error_spec.rb +70 -70
- data/spec/judopay/judopay_spec.rb +19 -19
- data/spec/judopay/market/collection_spec.rb +26 -26
- data/spec/judopay/market/payment_spec.rb +14 -14
- data/spec/judopay/market/preauth_spec.rb +14 -14
- data/spec/judopay/market/refund_spec.rb +26 -26
- data/spec/judopay/market/transaction_spec.rb +14 -14
- data/spec/judopay/payment_spec.rb +14 -14
- data/spec/judopay/preauth_spec.rb +14 -14
- data/spec/judopay/refund_spec.rb +26 -26
- data/spec/judopay/register_card_spec.rb +24 -24
- data/spec/judopay/save_card_spec.rb +23 -23
- data/spec/judopay/token_payment_spec.rb +22 -22
- data/spec/judopay/token_preauth_spec.rb +22 -22
- data/spec/judopay/transaction_spec.rb +51 -51
- data/spec/judopay/void_spec.rb +24 -24
- data/spec/judopay/web_payments/payment_spec.rb +16 -16
- data/spec/judopay/web_payments/preauth_spec.rb +16 -16
- data/spec/judopay/web_payments/transaction_spec.rb +15 -15
- data/spec/spec_helper.rb +41 -41
- data/test/additions_payment_test.rb +30 -0
- data/test/authentication_test.rb +23 -23
- data/test/base/integration_base.rb +20 -20
- data/test/base/payments_tests.rb +47 -47
- data/test/base/token_payment_tests.rb +98 -98
- data/test/card_details_test.rb +21 -21
- data/test/configuration_test.rb +35 -35
- data/test/helper/assertion_helper.rb +29 -29
- data/test/payment_test.rb +10 -10
- data/test/preauth_test.rb +10 -10
- data/test/register_card_test.rb +42 -42
- data/test/save_card_test.rb +23 -0
- data/test/token_payment_test.rb +10 -10
- data/test/token_preauth_test.rb +10 -10
- data/test/void_test.rb +45 -45
- metadata +18 -12
data/test/card_details_test.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class CardDetailsTest < IntegrationBase
|
4
|
-
def test_payment_with_missing_card_number
|
5
|
-
payment = build(:card_payment, :card_number => nil)
|
6
|
-
|
7
|
-
assert_raise(Judopay::ValidationError.new("Missing required fields\nField errors:\ncard_number: can't be blank")) { payment.create }
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_payment_with_missing_cv2
|
11
|
-
payment = build(:card_payment, :cv2 => nil)
|
12
|
-
|
13
|
-
assert_raise(Judopay::ValidationError.new("Missing required fields\nField errors:\ncv2: can't be blank")) { payment.create }
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_payment_with_missing_expiry_date
|
17
|
-
payment = build(:card_payment, :expiry_date => nil)
|
18
|
-
|
19
|
-
assert_raise(Judopay::ValidationError.new("Missing required fields\nField errors:\nexpiry_date: can't be blank")) { payment.create }
|
20
|
-
end
|
21
|
-
end
|
1
|
+
require_relative 'base/integration_base'
|
2
|
+
|
3
|
+
class CardDetailsTest < IntegrationBase
|
4
|
+
def test_payment_with_missing_card_number
|
5
|
+
payment = build(:card_payment, :card_number => nil)
|
6
|
+
|
7
|
+
assert_raise(Judopay::ValidationError.new("Missing required fields\nField errors:\ncard_number: can't be blank")) { payment.create }
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_payment_with_missing_cv2
|
11
|
+
payment = build(:card_payment, :cv2 => nil)
|
12
|
+
|
13
|
+
assert_raise(Judopay::ValidationError.new("Missing required fields\nField errors:\ncv2: can't be blank")) { payment.create }
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_payment_with_missing_expiry_date
|
17
|
+
payment = build(:card_payment, :expiry_date => nil)
|
18
|
+
|
19
|
+
assert_raise(Judopay::ValidationError.new("Missing required fields\nField errors:\nexpiry_date: can't be blank")) { payment.create }
|
20
|
+
end
|
21
|
+
end
|
data/test/configuration_test.rb
CHANGED
@@ -1,35 +1,35 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require_relative '../lib/judopay'
|
3
|
-
require_relative '../lib/judopay/error'
|
4
|
-
|
5
|
-
class ConfigurationTest < Test::Unit::TestCase
|
6
|
-
# Fixture information.
|
7
|
-
def setup
|
8
|
-
@data = [
|
9
|
-
['', 'MYTOKEN', 'MYSECRET'],
|
10
|
-
[nil, 'MYTOKEN', 'MYSECRET'],
|
11
|
-
['MYJUDOID', '', 'MYSECRET'],
|
12
|
-
['MYJUDOID', nil, 'MYSECRET'],
|
13
|
-
['MYJUDOID', 'MYTOKEN', ''],
|
14
|
-
['MYJUDOID', 'MYTOKEN', nil]
|
15
|
-
]
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_invalid_configuration
|
19
|
-
@data.each do |params|
|
20
|
-
config = Judopay::Configuration.new
|
21
|
-
config.judo_id, config.api_token, config.api_secret = params
|
22
|
-
|
23
|
-
assert_raise(Judopay::ValidationError.new('SDK configuration variables missing')) { config.validate }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_valid_configuration
|
28
|
-
config = Judopay::Configuration.new
|
29
|
-
config.judo_id = 'MYJUDOID'
|
30
|
-
config.api_token = 'MYTOKEN'
|
31
|
-
config.api_secret = 'MYSECRET'
|
32
|
-
|
33
|
-
assert_true(config.validate)
|
34
|
-
end
|
35
|
-
end
|
1
|
+
require 'test/unit'
|
2
|
+
require_relative '../lib/judopay'
|
3
|
+
require_relative '../lib/judopay/error'
|
4
|
+
|
5
|
+
class ConfigurationTest < Test::Unit::TestCase
|
6
|
+
# Fixture information.
|
7
|
+
def setup
|
8
|
+
@data = [
|
9
|
+
['', 'MYTOKEN', 'MYSECRET'],
|
10
|
+
[nil, 'MYTOKEN', 'MYSECRET'],
|
11
|
+
['MYJUDOID', '', 'MYSECRET'],
|
12
|
+
['MYJUDOID', nil, 'MYSECRET'],
|
13
|
+
['MYJUDOID', 'MYTOKEN', ''],
|
14
|
+
['MYJUDOID', 'MYTOKEN', nil]
|
15
|
+
]
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_invalid_configuration
|
19
|
+
@data.each do |params|
|
20
|
+
config = Judopay::Configuration.new
|
21
|
+
config.judo_id, config.api_token, config.api_secret = params
|
22
|
+
|
23
|
+
assert_raise(Judopay::ValidationError.new('SDK configuration variables missing')) { config.validate }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_valid_configuration
|
28
|
+
config = Judopay::Configuration.new
|
29
|
+
config.judo_id = 'MYJUDOID'
|
30
|
+
config.api_token = 'MYTOKEN'
|
31
|
+
config.api_secret = 'MYSECRET'
|
32
|
+
|
33
|
+
assert_true(config.validate)
|
34
|
+
end
|
35
|
+
end
|
@@ -1,29 +1,29 @@
|
|
1
|
-
require 'judopay/error'
|
2
|
-
require 'test/unit/assertions'
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
def api_exception_with_errors(errors_cnt_expected, error_code, status_code = 400, error_category = 2)
|
9
|
-
exception = assert_raise(Judopay::APIError) { yield }
|
10
|
-
assert_equal(errors_cnt_expected, exception.field_errors.count)
|
11
|
-
assert_equal(error_code, exception.error_code)
|
12
|
-
assert_equal(status_code, exception.status_code)
|
13
|
-
assert_equal(error_category, exception.category)
|
14
|
-
end
|
15
|
-
|
16
|
-
def assert_successful_payment(response)
|
17
|
-
assert_not_nil(response)
|
18
|
-
assert_equal('Success', response['result'])
|
19
|
-
assert_operator(0, :<, response['receiptId'].to_i)
|
20
|
-
end
|
21
|
-
|
22
|
-
def assert_declined_payment(response)
|
23
|
-
assert_not_nil(response)
|
24
|
-
assert_equal('Declined', response['result'])
|
25
|
-
assert_operator(0, :<, response['receiptId'].to_i)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
1
|
+
require 'judopay/error'
|
2
|
+
require 'test/unit/assertions'
|
3
|
+
|
4
|
+
module TestHelpers
|
5
|
+
class AssertionHelper
|
6
|
+
class << self
|
7
|
+
include Test::Unit::Assertions
|
8
|
+
def api_exception_with_errors(errors_cnt_expected, error_code, status_code = 400, error_category = 2)
|
9
|
+
exception = assert_raise(Judopay::APIError) { yield }
|
10
|
+
assert_equal(errors_cnt_expected, exception.field_errors.count)
|
11
|
+
assert_equal(error_code, exception.error_code)
|
12
|
+
assert_equal(status_code, exception.status_code)
|
13
|
+
assert_equal(error_category, exception.category)
|
14
|
+
end
|
15
|
+
|
16
|
+
def assert_successful_payment(response)
|
17
|
+
assert_not_nil(response)
|
18
|
+
assert_equal('Success', response['result'])
|
19
|
+
assert_operator(0, :<, response['receiptId'].to_i)
|
20
|
+
end
|
21
|
+
|
22
|
+
def assert_declined_payment(response)
|
23
|
+
assert_not_nil(response)
|
24
|
+
assert_equal('Declined', response['result'])
|
25
|
+
assert_operator(0, :<, response['receiptId'].to_i)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/test/payment_test.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
class PaymentTest < IntegrationBase
|
5
|
-
include PaymentTests
|
6
|
-
|
7
|
-
def get_model(params = {})
|
8
|
-
build(:card_payment, params)
|
9
|
-
end
|
10
|
-
end
|
1
|
+
require_relative 'base/payments_tests'
|
2
|
+
require_relative 'base/integration_base'
|
3
|
+
|
4
|
+
class PaymentTest < IntegrationBase
|
5
|
+
include PaymentTests
|
6
|
+
|
7
|
+
def get_model(params = {})
|
8
|
+
build(:card_payment, params)
|
9
|
+
end
|
10
|
+
end
|
data/test/preauth_test.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
class PreauthTest < IntegrationBase
|
5
|
-
include PaymentTests
|
6
|
-
|
7
|
-
def get_model(params = {})
|
8
|
-
build(:card_preauth, params)
|
9
|
-
end
|
10
|
-
end
|
1
|
+
require_relative 'base/payments_tests'
|
2
|
+
require_relative 'base/integration_base'
|
3
|
+
|
4
|
+
class PreauthTest < IntegrationBase
|
5
|
+
include PaymentTests
|
6
|
+
|
7
|
+
def get_model(params = {})
|
8
|
+
build(:card_preauth, params)
|
9
|
+
end
|
10
|
+
end
|
data/test/register_card_test.rb
CHANGED
@@ -1,42 +1,42 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
class RegisterCardTest < IntegrationBase
|
5
|
-
include PaymentTests
|
6
|
-
|
7
|
-
def get_model(params = {})
|
8
|
-
build(:register_card, params)
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_payment_with_unknown_currency
|
12
|
-
TestHelpers::AssertionHelper.api_exception_with_errors(0, 72, 409, 3) { get_model(:currency => 'ZZZ').create }
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_payment_changed_amount
|
16
|
-
result = get_model(:amount => 100_500).create
|
17
|
-
|
18
|
-
TestHelpers::AssertionHelper.assert_successful_payment(result)
|
19
|
-
assert_equal('1.01', result['amount'])
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_payment_without_currency
|
23
|
-
result = get_model(:currency => nil).create
|
24
|
-
|
25
|
-
TestHelpers::AssertionHelper.assert_successful_payment(result)
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_payment_with_negative_amount
|
29
|
-
# Unneeded test
|
30
|
-
assert_true(true)
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_payment_with_zero_amount
|
34
|
-
# Unneeded test
|
35
|
-
assert_true(true)
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_duplicate_payment
|
39
|
-
# Unneeded test
|
40
|
-
assert_true(true)
|
41
|
-
end
|
42
|
-
end
|
1
|
+
require_relative 'base/payments_tests'
|
2
|
+
require_relative 'base/integration_base'
|
3
|
+
|
4
|
+
class RegisterCardTest < IntegrationBase
|
5
|
+
include PaymentTests
|
6
|
+
|
7
|
+
def get_model(params = {})
|
8
|
+
build(:register_card, params)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_payment_with_unknown_currency
|
12
|
+
TestHelpers::AssertionHelper.api_exception_with_errors(0, 72, 409, 3) { get_model(:currency => 'ZZZ').create }
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_payment_changed_amount
|
16
|
+
result = get_model(:amount => 100_500).create
|
17
|
+
|
18
|
+
TestHelpers::AssertionHelper.assert_successful_payment(result)
|
19
|
+
assert_equal('1.01', result['amount'])
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_payment_without_currency
|
23
|
+
result = get_model(:currency => nil).create
|
24
|
+
|
25
|
+
TestHelpers::AssertionHelper.assert_successful_payment(result)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_payment_with_negative_amount
|
29
|
+
# Unneeded test
|
30
|
+
assert_true(true)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_payment_with_zero_amount
|
34
|
+
# Unneeded test
|
35
|
+
assert_true(true)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_duplicate_payment
|
39
|
+
# Unneeded test
|
40
|
+
assert_true(true)
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative 'base/integration_base'
|
2
|
+
|
3
|
+
class SaveCardTests < IntegrationBase
|
4
|
+
def get_model(params = {})
|
5
|
+
build(:save_card, params)
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_valid_payment
|
9
|
+
result = get_model.create
|
10
|
+
TestHelpers::AssertionHelper.assert_successful_payment(result)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_payment_without_reference
|
14
|
+
assert_raise(Judopay::ValidationError.new("Missing required fields\nField errors:\nyour_consumer_reference: can't be blank")) do
|
15
|
+
get_model(:your_consumer_reference => nil).create
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_save_card_with_no_cv2
|
20
|
+
result = get_model(:cv2 => '').create
|
21
|
+
TestHelpers::AssertionHelper.assert_successful_payment(result)
|
22
|
+
end
|
23
|
+
end
|
data/test/token_payment_test.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
class TokenPaymentTest < IntegrationBase
|
5
|
-
include TokenPaymentTests
|
6
|
-
|
7
|
-
def get_model(params = {})
|
8
|
-
build(:token_payment, { :consumer_token => @consumer_token, :card_token => @card_token }.merge(params))
|
9
|
-
end
|
10
|
-
end
|
1
|
+
require_relative 'base/token_payment_tests'
|
2
|
+
require_relative 'base/integration_base'
|
3
|
+
|
4
|
+
class TokenPaymentTest < IntegrationBase
|
5
|
+
include TokenPaymentTests
|
6
|
+
|
7
|
+
def get_model(params = {})
|
8
|
+
build(:token_payment, { :consumer_token => @consumer_token, :card_token => @card_token }.merge(params))
|
9
|
+
end
|
10
|
+
end
|
data/test/token_preauth_test.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
class TokenPaymentTest < IntegrationBase
|
5
|
-
include TokenPaymentTests
|
6
|
-
|
7
|
-
def get_model(params = {})
|
8
|
-
build(:token_preauth, { :consumer_token => @consumer_token, :card_token => @card_token }.merge(params))
|
9
|
-
end
|
10
|
-
end
|
1
|
+
require_relative 'base/token_payment_tests'
|
2
|
+
require_relative 'base/integration_base'
|
3
|
+
|
4
|
+
class TokenPaymentTest < IntegrationBase
|
5
|
+
include TokenPaymentTests
|
6
|
+
|
7
|
+
def get_model(params = {})
|
8
|
+
build(:token_preauth, { :consumer_token => @consumer_token, :card_token => @card_token }.merge(params))
|
9
|
+
end
|
10
|
+
end
|
data/test/void_test.rb
CHANGED
@@ -1,45 +1,45 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class VoidTest < IntegrationBase
|
4
|
-
def test_valid_preauth_void
|
5
|
-
receipt = make_payment
|
6
|
-
void = build(:void, :receipt_id => receipt).create
|
7
|
-
|
8
|
-
TestHelpers::AssertionHelper.assert_successful_payment(void)
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_declined_payment_void
|
12
|
-
receipt = make_payment(false)
|
13
|
-
TestHelpers::AssertionHelper.api_exception_with_errors(0, 50, 404) { build(:void, :receipt_id => receipt).create }
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_wrong_receipt_id
|
17
|
-
TestHelpers::AssertionHelper.api_exception_with_errors(1, 1) { build(:void).create }
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_double_void
|
21
|
-
receipt = make_payment
|
22
|
-
void = build(:void, :receipt_id => receipt)
|
23
|
-
|
24
|
-
response = void.create
|
25
|
-
|
26
|
-
TestHelpers::AssertionHelper.assert_successful_payment(response)
|
27
|
-
void.your_payment_reference = SecureRandom.hex(18) + Time.now.to_i.to_s
|
28
|
-
TestHelpers::AssertionHelper.api_exception_with_errors(0, 51) { void.create }
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_void_with_invalid_amount
|
32
|
-
TestHelpers::AssertionHelper.api_exception_with_errors(0, 53, 404) do
|
33
|
-
build(:void, :receipt_id => make_payment, :amount => 100).create
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
protected
|
38
|
-
|
39
|
-
def make_payment(preauth = true)
|
40
|
-
payment = build(preauth ? :card_preauth : :card_payment).create
|
41
|
-
TestHelpers::AssertionHelper.assert_successful_payment(payment)
|
42
|
-
|
43
|
-
payment['receiptId']
|
44
|
-
end
|
45
|
-
end
|
1
|
+
require_relative 'base/integration_base'
|
2
|
+
|
3
|
+
class VoidTest < IntegrationBase
|
4
|
+
def test_valid_preauth_void
|
5
|
+
receipt = make_payment
|
6
|
+
void = build(:void, :receipt_id => receipt).create
|
7
|
+
|
8
|
+
TestHelpers::AssertionHelper.assert_successful_payment(void)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_declined_payment_void
|
12
|
+
receipt = make_payment(false)
|
13
|
+
TestHelpers::AssertionHelper.api_exception_with_errors(0, 50, 404) { build(:void, :receipt_id => receipt).create }
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_wrong_receipt_id
|
17
|
+
TestHelpers::AssertionHelper.api_exception_with_errors(1, 1) { build(:void).create }
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_double_void
|
21
|
+
receipt = make_payment
|
22
|
+
void = build(:void, :receipt_id => receipt)
|
23
|
+
|
24
|
+
response = void.create
|
25
|
+
|
26
|
+
TestHelpers::AssertionHelper.assert_successful_payment(response)
|
27
|
+
void.your_payment_reference = SecureRandom.hex(18) + Time.now.to_i.to_s
|
28
|
+
TestHelpers::AssertionHelper.api_exception_with_errors(0, 51) { void.create }
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_void_with_invalid_amount
|
32
|
+
TestHelpers::AssertionHelper.api_exception_with_errors(0, 53, 404) do
|
33
|
+
build(:void, :receipt_id => make_payment, :amount => 100).create
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
|
39
|
+
def make_payment(preauth = true)
|
40
|
+
payment = build(preauth ? :card_preauth : :card_payment).create
|
41
|
+
TestHelpers::AssertionHelper.assert_successful_payment(payment)
|
42
|
+
|
43
|
+
payment['receiptId']
|
44
|
+
end
|
45
|
+
end
|