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
@@ -1,80 +1,80 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'json'
|
3
|
-
require_relative '../../lib/judopay/models/apple_payment'
|
4
|
-
|
5
|
-
describe Judopay::ApplePayment do
|
6
|
-
it 'should create a new payment given pk_payment object' do
|
7
|
-
stub_post('/transactions/payments').
|
8
|
-
to_return(:status => 200,
|
9
|
-
:body => lambda { |_request| fixture('transactions/apple_payment.json') })
|
10
|
-
|
11
|
-
payment = build(:apple_payment)
|
12
|
-
response = payment.create
|
13
|
-
|
14
|
-
expect(response).to be_a(Hash)
|
15
|
-
expect(response.result).to eq('Success')
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should return a bad request exception if basic validation fails' do
|
19
|
-
expect(lambda do
|
20
|
-
Judopay::ApplePayment.new.create
|
21
|
-
end).to raise_error(Judopay::ValidationError)
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should use the configured Judo ID if one isn\'t provided in the payment request' do
|
25
|
-
stub_post('/transactions/payments').
|
26
|
-
to_return(:status => 200,
|
27
|
-
:body => lambda { |_request| fixture('transactions/apple_payment.json') })
|
28
|
-
|
29
|
-
Judopay.configure do |config|
|
30
|
-
config.judo_id = '123-456'
|
31
|
-
end
|
32
|
-
|
33
|
-
payment = build(:apple_payment, :judo_id => nil)
|
34
|
-
payment.create
|
35
|
-
|
36
|
-
expect(payment.valid?).to eq(true)
|
37
|
-
expect(payment.judo_id).to eq('123-456')
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'properly coerces pk_payment field from_json' do
|
41
|
-
json_string = '{"pkPayment":{"token":{"paymentInstrumentName":"Visa XXXX","paymentNetwork":"Visa","paymentData"'\
|
42
|
-
':{"version":"EC_v1","data":"SomeBase64encodedData","signature":"SomeBase64encodedData","header":{"ephemeralPublicKey"'\
|
43
|
-
':"someKey","publicKeyHash":"someKey","transactionId":"someId"}}},"billingAddress":1,"shippingAddress":2}}'
|
44
|
-
pk_payment = Judopay::PkPayment.new(
|
45
|
-
:token => Judopay::PkPaymentToken.new(
|
46
|
-
:payment_instrument_name => 'Visa XXXX',
|
47
|
-
:payment_network => 'Visa',
|
48
|
-
:payment_data => {
|
49
|
-
'version' => 'EC_v1',
|
50
|
-
'data' => 'SomeBase64encodedData',
|
51
|
-
'signature' => 'SomeBase64encodedData',
|
52
|
-
'header' => {
|
53
|
-
'ephemeral_public_key' => 'someKey',
|
54
|
-
'public_key_hash' => 'someKey',
|
55
|
-
'transaction_id' => 'someId'
|
56
|
-
}
|
57
|
-
}
|
58
|
-
),
|
59
|
-
:billing_address => '1',
|
60
|
-
:shipping_address => '2'
|
61
|
-
)
|
62
|
-
|
63
|
-
payment = build(:apple_payment, :pk_payment => json_string)
|
64
|
-
expect(payment.pk_payment).to be == pk_payment
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'should raise an error when bad pk_payment passed' do
|
68
|
-
expect(lambda do
|
69
|
-
Judopay::ApplePayment.new(:pk_payment => '{"someInvalidJson}}')
|
70
|
-
end).to raise_error(Judopay::ValidationError, format(Judopay::PkPayment::WRONG_JSON_ERROR_MESSAGE, 'Judopay::PkPayment'))
|
71
|
-
|
72
|
-
expect(lambda do
|
73
|
-
Judopay::ApplePayment.new(:pk_payment => 1)
|
74
|
-
end).to raise_error(Judopay::ValidationError, format(Judopay::PkPayment::WRONG_OBJECT_ERROR_MESSAGE, 'Judopay::PkPayment'))
|
75
|
-
|
76
|
-
expect(lambda do
|
77
|
-
build(:apple_payment, :pk_payment => '{"valid_json":"Without token field"}').create
|
78
|
-
end).to raise_error(Judopay::ValidationError)
|
79
|
-
end
|
80
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'json'
|
3
|
+
require_relative '../../lib/judopay/models/apple_payment'
|
4
|
+
|
5
|
+
describe Judopay::ApplePayment do
|
6
|
+
it 'should create a new payment given pk_payment object' do
|
7
|
+
stub_post('/transactions/payments').
|
8
|
+
to_return(:status => 200,
|
9
|
+
:body => lambda { |_request| fixture('transactions/apple_payment.json') })
|
10
|
+
|
11
|
+
payment = build(:apple_payment)
|
12
|
+
response = payment.create
|
13
|
+
|
14
|
+
expect(response).to be_a(Hash)
|
15
|
+
expect(response.result).to eq('Success')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should return a bad request exception if basic validation fails' do
|
19
|
+
expect(lambda do
|
20
|
+
Judopay::ApplePayment.new.create
|
21
|
+
end).to raise_error(Judopay::ValidationError)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should use the configured Judo ID if one isn\'t provided in the payment request' do
|
25
|
+
stub_post('/transactions/payments').
|
26
|
+
to_return(:status => 200,
|
27
|
+
:body => lambda { |_request| fixture('transactions/apple_payment.json') })
|
28
|
+
|
29
|
+
Judopay.configure do |config|
|
30
|
+
config.judo_id = '123-456'
|
31
|
+
end
|
32
|
+
|
33
|
+
payment = build(:apple_payment, :judo_id => nil)
|
34
|
+
payment.create
|
35
|
+
|
36
|
+
expect(payment.valid?).to eq(true)
|
37
|
+
expect(payment.judo_id).to eq('123-456')
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'properly coerces pk_payment field from_json' do
|
41
|
+
json_string = '{"pkPayment":{"token":{"paymentInstrumentName":"Visa XXXX","paymentNetwork":"Visa","paymentData"'\
|
42
|
+
':{"version":"EC_v1","data":"SomeBase64encodedData","signature":"SomeBase64encodedData","header":{"ephemeralPublicKey"'\
|
43
|
+
':"someKey","publicKeyHash":"someKey","transactionId":"someId"}}},"billingAddress":1,"shippingAddress":2}}'
|
44
|
+
pk_payment = Judopay::PkPayment.new(
|
45
|
+
:token => Judopay::PkPaymentToken.new(
|
46
|
+
:payment_instrument_name => 'Visa XXXX',
|
47
|
+
:payment_network => 'Visa',
|
48
|
+
:payment_data => {
|
49
|
+
'version' => 'EC_v1',
|
50
|
+
'data' => 'SomeBase64encodedData',
|
51
|
+
'signature' => 'SomeBase64encodedData',
|
52
|
+
'header' => {
|
53
|
+
'ephemeral_public_key' => 'someKey',
|
54
|
+
'public_key_hash' => 'someKey',
|
55
|
+
'transaction_id' => 'someId'
|
56
|
+
}
|
57
|
+
}
|
58
|
+
),
|
59
|
+
:billing_address => '1',
|
60
|
+
:shipping_address => '2'
|
61
|
+
)
|
62
|
+
|
63
|
+
payment = build(:apple_payment, :pk_payment => json_string)
|
64
|
+
expect(payment.pk_payment).to be == pk_payment
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should raise an error when bad pk_payment passed' do
|
68
|
+
expect(lambda do
|
69
|
+
Judopay::ApplePayment.new(:pk_payment => '{"someInvalidJson}}')
|
70
|
+
end).to raise_error(Judopay::ValidationError, format(Judopay::PkPayment::WRONG_JSON_ERROR_MESSAGE, :foo => 'Judopay::PkPayment'))
|
71
|
+
|
72
|
+
expect(lambda do
|
73
|
+
Judopay::ApplePayment.new(:pk_payment => 1)
|
74
|
+
end).to raise_error(Judopay::ValidationError, format(Judopay::PkPayment::WRONG_OBJECT_ERROR_MESSAGE, :foo => 'Judopay::PkPayment'))
|
75
|
+
|
76
|
+
expect(lambda do
|
77
|
+
build(:apple_payment, :pk_payment => '{"valid_json":"Without token field"}').create
|
78
|
+
end).to raise_error(Judopay::ValidationError)
|
79
|
+
end
|
80
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require_relative '../../lib/judopay/models/card_address'
|
3
|
-
|
4
|
-
describe Judopay::CardAddress do
|
5
|
-
it "should not allow querying of the API if a resource path isn't set on the model" do
|
6
|
-
expect(lambda do
|
7
|
-
Judopay::CardAddress.all
|
8
|
-
end).to raise_error(Judopay::ValidationError)
|
9
|
-
end
|
10
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../../lib/judopay/models/card_address'
|
3
|
+
|
4
|
+
describe Judopay::CardAddress do
|
5
|
+
it "should not allow querying of the API if a resource path isn't set on the model" do
|
6
|
+
expect(lambda do
|
7
|
+
Judopay::CardAddress.all
|
8
|
+
end).to raise_error(Judopay::ValidationError)
|
9
|
+
end
|
10
|
+
end
|
@@ -1,63 +1,51 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require_relative '../../lib/judopay/models/card_payment'
|
3
|
-
|
4
|
-
describe Judopay::CardPayment do
|
5
|
-
it 'should create a new payment given valid card details' do
|
6
|
-
stub_post('/transactions/payments').
|
7
|
-
to_return(:status => 200,
|
8
|
-
:body => lambda { |_request| fixture('card_payments/create.json') })
|
9
|
-
|
10
|
-
payment = build(:card_payment)
|
11
|
-
response = payment.create
|
12
|
-
|
13
|
-
expect(response).to be_a(Hash)
|
14
|
-
expect(response.result).to eq('Success')
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should not create a new payment if the card is declined' do
|
18
|
-
stub_post('/transactions/payments').
|
19
|
-
to_return(:status => 200,
|
20
|
-
:body => lambda { |_request| fixture('card_payments/create_declined.json') })
|
21
|
-
|
22
|
-
payment = build(:card_payment)
|
23
|
-
payment.card_number = '4221690000004963' # Always declined
|
24
|
-
response = payment.create
|
25
|
-
|
26
|
-
expect(response).to be_a(Hash)
|
27
|
-
expect(response.result).to eq('Declined')
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'should return a bad request exception if basic validation fails' do
|
31
|
-
expect(lambda do
|
32
|
-
Judopay::CardPayment.new.create
|
33
|
-
end).to raise_error(Judopay::ValidationError)
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should use the configured Judo ID if one isn't provided in the payment request" do
|
37
|
-
stub_post('/transactions/payments').
|
38
|
-
to_return(:status => 200,
|
39
|
-
:body => lambda { |_request| fixture('card_payments/create.json') })
|
40
|
-
|
41
|
-
Judopay.configure do |config|
|
42
|
-
config.judo_id = '123-456'
|
43
|
-
end
|
44
|
-
|
45
|
-
payment = build(:card_payment, :judo_id => nil)
|
46
|
-
payment.create
|
47
|
-
|
48
|
-
expect(payment.valid?).to eq(true)
|
49
|
-
expect(payment.judo_id).to eq('123-456')
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'should validate a new payment given valid card details' do
|
53
|
-
stub_post('/transactions/payments/validate').
|
54
|
-
to_return(:status => 200,
|
55
|
-
:body => lambda { |_request| fixture('card_payments/validate.json') })
|
56
|
-
|
57
|
-
payment = build(:card_payment)
|
58
|
-
response = payment.validate
|
59
|
-
|
60
|
-
expect(response).to be_a(Hash)
|
61
|
-
expect(response.error_message).to include('good to go') # API could give a more helpful response here
|
62
|
-
end
|
63
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../../lib/judopay/models/card_payment'
|
3
|
+
|
4
|
+
describe Judopay::CardPayment do
|
5
|
+
it 'should create a new payment given valid card details' do
|
6
|
+
stub_post('/transactions/payments').
|
7
|
+
to_return(:status => 200,
|
8
|
+
:body => lambda { |_request| fixture('card_payments/create.json') })
|
9
|
+
|
10
|
+
payment = build(:card_payment)
|
11
|
+
response = payment.create
|
12
|
+
|
13
|
+
expect(response).to be_a(Hash)
|
14
|
+
expect(response.result).to eq('Success')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should not create a new payment if the card is declined' do
|
18
|
+
stub_post('/transactions/payments').
|
19
|
+
to_return(:status => 200,
|
20
|
+
:body => lambda { |_request| fixture('card_payments/create_declined.json') })
|
21
|
+
|
22
|
+
payment = build(:card_payment)
|
23
|
+
payment.card_number = '4221690000004963' # Always declined
|
24
|
+
response = payment.create
|
25
|
+
|
26
|
+
expect(response).to be_a(Hash)
|
27
|
+
expect(response.result).to eq('Declined')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should return a bad request exception if basic validation fails' do
|
31
|
+
expect(lambda do
|
32
|
+
Judopay::CardPayment.new.create
|
33
|
+
end).to raise_error(Judopay::ValidationError)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should use the configured Judo ID if one isn't provided in the payment request" do
|
37
|
+
stub_post('/transactions/payments').
|
38
|
+
to_return(:status => 200,
|
39
|
+
:body => lambda { |_request| fixture('card_payments/create.json') })
|
40
|
+
|
41
|
+
Judopay.configure do |config|
|
42
|
+
config.judo_id = '123-456'
|
43
|
+
end
|
44
|
+
|
45
|
+
payment = build(:card_payment, :judo_id => nil)
|
46
|
+
payment.create
|
47
|
+
|
48
|
+
expect(payment.valid?).to eq(true)
|
49
|
+
expect(payment.judo_id).to eq('123-456')
|
50
|
+
end
|
51
|
+
end
|
@@ -1,35 +1,35 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require_relative '../../lib/judopay/models/card_preauth'
|
3
|
-
|
4
|
-
describe Judopay::CardPreauth do
|
5
|
-
it 'should create a new preauth given valid card details' do
|
6
|
-
stub_post('/transactions/preauths').
|
7
|
-
to_return(:status => 200,
|
8
|
-
:body => lambda { |_request| fixture('card_payments/create.json') })
|
9
|
-
|
10
|
-
payment = build(:card_preauth)
|
11
|
-
response = payment.create
|
12
|
-
|
13
|
-
expect(response).to be_a(Hash)
|
14
|
-
expect(response.result).to eq('Success')
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should not create a new preauth if the card is declined' do
|
18
|
-
stub_post('/transactions/preauths').
|
19
|
-
to_return(:status => 200,
|
20
|
-
:body => lambda { |_request| fixture('card_payments/create_declined.json') })
|
21
|
-
|
22
|
-
payment = build(:card_payment)
|
23
|
-
payment.card_number = '4221690000004963' # Always declined
|
24
|
-
response = payment.create
|
25
|
-
|
26
|
-
expect(response).to be_a(Hash)
|
27
|
-
expect(response.result).to eq('Declined')
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'should return a bad request exception if basic validation fails' do
|
31
|
-
expect(lambda do
|
32
|
-
Judopay::CardPreauth.new.create
|
33
|
-
end).to raise_error(Judopay::ValidationError)
|
34
|
-
end
|
35
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../../lib/judopay/models/card_preauth'
|
3
|
+
|
4
|
+
describe Judopay::CardPreauth do
|
5
|
+
it 'should create a new preauth given valid card details' do
|
6
|
+
stub_post('/transactions/preauths').
|
7
|
+
to_return(:status => 200,
|
8
|
+
:body => lambda { |_request| fixture('card_payments/create.json') })
|
9
|
+
|
10
|
+
payment = build(:card_preauth)
|
11
|
+
response = payment.create
|
12
|
+
|
13
|
+
expect(response).to be_a(Hash)
|
14
|
+
expect(response.result).to eq('Success')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should not create a new preauth if the card is declined' do
|
18
|
+
stub_post('/transactions/preauths').
|
19
|
+
to_return(:status => 200,
|
20
|
+
:body => lambda { |_request| fixture('card_payments/create_declined.json') })
|
21
|
+
|
22
|
+
payment = build(:card_payment)
|
23
|
+
payment.card_number = '4221690000004963' # Always declined
|
24
|
+
response = payment.create
|
25
|
+
|
26
|
+
expect(response).to be_a(Hash)
|
27
|
+
expect(response.result).to eq('Declined')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should return a bad request exception if basic validation fails' do
|
31
|
+
expect(lambda do
|
32
|
+
Judopay::CardPreauth.new.create
|
33
|
+
end).to raise_error(Judopay::ValidationError)
|
34
|
+
end
|
35
|
+
end
|
@@ -1,26 +1,26 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require_relative '../../lib/judopay/models/collection'
|
3
|
-
|
4
|
-
describe Judopay::Collection do
|
5
|
-
it 'should list all transactions' do
|
6
|
-
stub_get('/transactions/collections').
|
7
|
-
to_return(:status => 200,
|
8
|
-
:body => lambda { |_request| fixture('transactions/all.json') })
|
9
|
-
|
10
|
-
transactions = Judopay::Collection.all
|
11
|
-
expect(transactions).to be_a(Hash)
|
12
|
-
expect(transactions.results[0].amount).to eq(1.01)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should create a new collection given a valid payment reference' do
|
16
|
-
stub_post('/transactions/collections').
|
17
|
-
to_return(:status => 200,
|
18
|
-
:body => lambda { |_request| fixture('card_payments/create.json') })
|
19
|
-
|
20
|
-
collection = build(:collection)
|
21
|
-
response = collection.create
|
22
|
-
|
23
|
-
expect(response).to be_a(Hash)
|
24
|
-
expect(response.result).to eq('Success')
|
25
|
-
end
|
26
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../../lib/judopay/models/collection'
|
3
|
+
|
4
|
+
describe Judopay::Collection do
|
5
|
+
it 'should list all transactions' do
|
6
|
+
stub_get('/transactions/collections').
|
7
|
+
to_return(:status => 200,
|
8
|
+
:body => lambda { |_request| fixture('transactions/all.json') })
|
9
|
+
|
10
|
+
transactions = Judopay::Collection.all
|
11
|
+
expect(transactions).to be_a(Hash)
|
12
|
+
expect(transactions.results[0].amount).to eq(1.01)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should create a new collection given a valid payment reference' do
|
16
|
+
stub_post('/transactions/collections').
|
17
|
+
to_return(:status => 200,
|
18
|
+
:body => lambda { |_request| fixture('card_payments/create.json') })
|
19
|
+
|
20
|
+
collection = build(:collection)
|
21
|
+
response = collection.create
|
22
|
+
|
23
|
+
expect(response).to be_a(Hash)
|
24
|
+
expect(response.result).to eq('Success')
|
25
|
+
end
|
26
|
+
end
|
@@ -1,24 +1,24 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require_relative '../../../lib/judopay/core_ext/hash'
|
3
|
-
|
4
|
-
describe Hash do
|
5
|
-
it 'should convert hash keys to camel case' do
|
6
|
-
original = {
|
7
|
-
'under_score' => 123,
|
8
|
-
'more_words_please' => 'value'
|
9
|
-
}
|
10
|
-
expected_result = {
|
11
|
-
'underScore' => 123,
|
12
|
-
'moreWordsPlease' => 'value'
|
13
|
-
}
|
14
|
-
expect(original.camel_case_keys!).to eq(expected_result)
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should convert a hash to a valid query string' do
|
18
|
-
original = {
|
19
|
-
'under_score' => 123,
|
20
|
-
'more_words_please' => 'value'
|
21
|
-
}
|
22
|
-
expect(original.to_query_string).to eq('more_words_please=value&under_score=123')
|
23
|
-
end
|
24
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../../../lib/judopay/core_ext/hash'
|
3
|
+
|
4
|
+
describe Hash do
|
5
|
+
it 'should convert hash keys to camel case' do
|
6
|
+
original = {
|
7
|
+
'under_score' => 123,
|
8
|
+
'more_words_please' => 'value'
|
9
|
+
}
|
10
|
+
expected_result = {
|
11
|
+
'underScore' => 123,
|
12
|
+
'moreWordsPlease' => 'value'
|
13
|
+
}
|
14
|
+
expect(original.camel_case_keys!).to eq(expected_result)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should convert a hash to a valid query string' do
|
18
|
+
original = {
|
19
|
+
'under_score' => 123,
|
20
|
+
'more_words_please' => 'value'
|
21
|
+
}
|
22
|
+
expect(original.to_query_string).to eq('more_words_please=value&under_score=123')
|
23
|
+
end
|
24
|
+
end
|