fat_zebra 3.2.0 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/README.md +2 -2
  4. data/fat_zebra.gemspec +1 -1
  5. data/lib/fat_zebra.rb +1 -1
  6. data/lib/fat_zebra/authenticate.rb +64 -0
  7. data/lib/fat_zebra/version.rb +1 -1
  8. data/spec/cassettes/FatZebra_Authenticate/_authenticate/validations/1_3_4_1.yml +46 -0
  9. data/spec/cassettes/FatZebra_Authenticate/_authenticate/with_challenge_response/1_3_3_1.yml +91 -0
  10. data/spec/cassettes/FatZebra_Authenticate/_authenticate/with_challenge_response/1_3_3_2.yml +91 -0
  11. data/spec/cassettes/FatZebra_Authenticate/_authenticate/with_frictionless_response/1_3_2_1.yml +91 -0
  12. data/spec/cassettes/FatZebra_Authenticate/_authenticate/with_frictionless_response/1_3_2_2.yml +91 -0
  13. data/spec/cassettes/FatZebra_Authenticate/_authenticate/with_invalid_input/1_3_1_1.yml +91 -0
  14. data/spec/cassettes/FatZebra_Authenticate/_authenticate/with_invalid_input/1_3_1_2.yml +87 -0
  15. data/spec/cassettes/FatZebra_Authenticate/_authenticate/with_invalid_input/1_3_1_3.yml +92 -0
  16. data/spec/cassettes/FatZebra_Authenticate/_authenticate/with_invalid_input/1_3_1_4.yml +92 -0
  17. data/spec/cassettes/FatZebra_Authenticate/_decode_session/when_token_is_invalid/returns_error_when_invalid_token.yml +47 -0
  18. data/spec/cassettes/FatZebra_Authenticate/_decode_session/when_token_is_valid/decodes_JWT.yml +87 -0
  19. data/spec/cassettes/FatZebra_Authenticate/_session/returns_JWT_with_given_params.yml +44 -0
  20. data/spec/cassettes/{FatZebra_Authorise/_jwt_token → FatZebra_Authenticate/_session}/returns_JWT_with_no_params.yml +8 -10
  21. data/spec/cassettes/FatZebra_Authenticate/_session/returns_JWT_with_some_params.yml +44 -0
  22. data/spec/cassettes/FatZebra_Authenticate/_session/returns_error_when_amount_is_invalid.yml +44 -0
  23. data/spec/lib/fat_zebra/authenticate_spec.rb +144 -0
  24. data/spec/spec_helper.rb +1 -1
  25. data/spec/support/payloads.rb +36 -31
  26. metadata +21 -15
  27. data/lib/fat_zebra/authorise.rb +0 -49
  28. data/spec/cassettes/FatZebra_Authorise/_authorise/with_challenge_response/1_2_3_1.yml +0 -48
  29. data/spec/cassettes/FatZebra_Authorise/_authorise/with_challenge_response/1_2_3_2.yml +0 -48
  30. data/spec/cassettes/FatZebra_Authorise/_authorise/with_frictionless_response/1_2_2_1.yml +0 -48
  31. data/spec/cassettes/FatZebra_Authorise/_authorise/with_frictionless_response/1_2_2_2.yml +0 -48
  32. data/spec/cassettes/FatZebra_Authorise/_authorise/with_invalid_input/1_2_1_1.yml +0 -50
  33. data/spec/cassettes/FatZebra_Authorise/_jwt_token/returns_JWT_with_given_params.yml +0 -46
  34. data/spec/cassettes/FatZebra_Authorise/_jwt_token/returns_JWT_with_some_params.yml +0 -46
  35. data/spec/lib/fat_zebra/authorise_spec.rb +0 -101
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://gateway.sandbox.fatzebra.com.au/v1.0/authenticate/decode_session?test=true&token=INVALID%20TOKEN
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - application/json
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - gateway.sandbox.fatzebra.com.au
18
+ Authorization:
19
+ - Basic VEVTVDpURVNU
20
+ Content-Type:
21
+ - application/json
22
+ response:
23
+ status:
24
+ code: 422
25
+ message: Unprocessable Entity
26
+ headers:
27
+ Cache-Control:
28
+ - no-store
29
+ Pragma:
30
+ - no-cache
31
+ Content-Type:
32
+ - application/json; charset=utf-8
33
+ X-Request-Version:
34
+ - 1.21.8
35
+ X-Request-Id:
36
+ - 55f43b14bc30599d22bbdad8cdb4ab83
37
+ X-Runtime:
38
+ - '0.023084'
39
+ Transfer-Encoding:
40
+ - chunked
41
+ body:
42
+ encoding: UTF-8
43
+ string: '{"successful":false,"response":null,"errors":"Decoding JWT failed:
44
+ The token is invalid","test":true}'
45
+ http_version:
46
+ recorded_at: Tue, 22 Oct 2019 05:35:42 GMT
47
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,87 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://gateway.sandbox.fatzebra.com.au/v1.0/authenticate/session
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"test":true}'
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - application/json
14
+ User-Agent:
15
+ - Ruby
16
+ Authorization:
17
+ - Basic VEVTVDpURVNU
18
+ Content-Type:
19
+ - application/json
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Cache-Control:
26
+ - no-store
27
+ Pragma:
28
+ - no-cache
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ X-Request-Version:
32
+ - 1.21.8
33
+ X-Request-Id:
34
+ - b25d4b9392a92488ea9fc6c19a25c323
35
+ X-Runtime:
36
+ - '0.027316'
37
+ Transfer-Encoding:
38
+ - chunked
39
+ body:
40
+ encoding: UTF-8
41
+ string: '{"successful":true,"response":{"jwt":"eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NzE3MzY5NDIsImlhdCI6MTU3MTcyMjU0MiwiaXNzIjoiNTgyZTBhMjAzM2ZhZGQxMjYwZjk5MGY2IiwianRpIjoiYThjMWM3MDItNGJiMi00MTAxLWI2NDctMzg4MDhmNzQ2MTY5IiwiT3JnVW5pdElkIjoiNTgyYmU5ZGVkYTUyOTMyYTk0NmM0NWM0IiwiT2JqZWN0aWZ5UGF5bG9hZCI6dHJ1ZSwiUmVmZXJlbmNlSWQiOiI2MGNjNjQ2Yy1lOTk5LTQzZGUtYWNjZC03MmI5NWM4ZGJlMDQifQ.Clghlq4zGBvTZsvLA4vM_GXEznPj_wwkCmsuqv3thMU","reference_id":"60cc646c-e999-43de-accd-72b95c8dbe04"},"errors":null,"test":true}'
42
+ http_version:
43
+ recorded_at: Tue, 22 Oct 2019 05:35:42 GMT
44
+ - request:
45
+ method: get
46
+ uri: https://gateway.sandbox.fatzebra.com.au/v1.0/authenticate/decode_session?test=true&token=eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NzE3MzY5NDIsImlhdCI6MTU3MTcyMjU0MiwiaXNzIjoiNTgyZTBhMjAzM2ZhZGQxMjYwZjk5MGY2IiwianRpIjoiYThjMWM3MDItNGJiMi00MTAxLWI2NDctMzg4MDhmNzQ2MTY5IiwiT3JnVW5pdElkIjoiNTgyYmU5ZGVkYTUyOTMyYTk0NmM0NWM0IiwiT2JqZWN0aWZ5UGF5bG9hZCI6dHJ1ZSwiUmVmZXJlbmNlSWQiOiI2MGNjNjQ2Yy1lOTk5LTQzZGUtYWNjZC03MmI5NWM4ZGJlMDQifQ.Clghlq4zGBvTZsvLA4vM_GXEznPj_wwkCmsuqv3thMU
47
+ body:
48
+ encoding: US-ASCII
49
+ string: ''
50
+ headers:
51
+ Accept-Encoding:
52
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
53
+ Accept:
54
+ - application/json
55
+ User-Agent:
56
+ - Ruby
57
+ Host:
58
+ - gateway.sandbox.fatzebra.com.au
59
+ Authorization:
60
+ - Basic VEVTVDpURVNU
61
+ Content-Type:
62
+ - application/json
63
+ response:
64
+ status:
65
+ code: 200
66
+ message: OK
67
+ headers:
68
+ Cache-Control:
69
+ - no-store
70
+ Pragma:
71
+ - no-cache
72
+ Content-Type:
73
+ - application/json; charset=utf-8
74
+ X-Request-Version:
75
+ - 1.21.8
76
+ X-Request-Id:
77
+ - 95c7bb10d345b47ee5b11aaa7ba5b67d
78
+ X-Runtime:
79
+ - '0.022733'
80
+ Transfer-Encoding:
81
+ - chunked
82
+ body:
83
+ encoding: UTF-8
84
+ string: '{"successful":true,"response":{"payload":{"ObjectifyPayload":true,"ReferenceId":"60cc646c-e999-43de-accd-72b95c8dbe04"}},"errors":null,"test":true}'
85
+ http_version:
86
+ recorded_at: Tue, 22 Oct 2019 05:35:42 GMT
87
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://gateway.sandbox.fatzebra.com.au/v1.0/authenticate/session
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"reference_id":"xxxx-xxxx-xxxx","confirm_url":"https://example.com","order_number":"xxxx-xxxx-xxxx","currency":"AUD","amount":100,"test":true}'
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - application/json
14
+ User-Agent:
15
+ - Ruby
16
+ Authorization:
17
+ - Basic VEVTVDpURVNU
18
+ Content-Type:
19
+ - application/json
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Cache-Control:
26
+ - no-store
27
+ Pragma:
28
+ - no-cache
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ X-Request-Version:
32
+ - 1.21.8
33
+ X-Request-Id:
34
+ - 7b46fc3eb645c1d24027f3c5d71f0fd4
35
+ X-Runtime:
36
+ - '0.411523'
37
+ Transfer-Encoding:
38
+ - chunked
39
+ body:
40
+ encoding: UTF-8
41
+ string: '{"successful":true,"response":{"jwt":"eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NzE3MzY5NDIsImlhdCI6MTU3MTcyMjU0MiwiaXNzIjoiNTgyZTBhMjAzM2ZhZGQxMjYwZjk5MGY2IiwianRpIjoiYjkyZTIxNjUtYmE3NS00ODQ2LTg3MDgtOGMyZjRjOWY5MGIyIiwiT3JnVW5pdElkIjoiNTgyYmU5ZGVkYTUyOTMyYTk0NmM0NWM0IiwiT2JqZWN0aWZ5UGF5bG9hZCI6dHJ1ZSwiQ29uZmlybVVybCI6Imh0dHBzOi8vZXhhbXBsZS5jb20iLCJSZWZlcmVuY2VJZCI6Inh4eHgteHh4eC14eHh4IiwiUGF5bG9hZCI6eyJPcmRlckRldGFpbHMiOnsiT3JkZXJOdW1iZXIiOiJ4eHh4LXh4eHgteHh4eCIsIkN1cnJlbmN5Q29kZSI6IjAzNiIsIkFtb3VudCI6IjEwMCJ9fX0.jHAsaYpedoI1zy179SngTEvdAVmn5cMyK65m4Wc9HPw","reference_id":"xxxx-xxxx-xxxx"},"errors":null,"test":true}'
42
+ http_version:
43
+ recorded_at: Tue, 22 Oct 2019 05:35:42 GMT
44
+ recorded_with: VCR 3.0.3
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  http_interactions:
3
3
  - request:
4
- method: get
5
- uri: https://gateway.sandbox.fatzebra.com.au/v1.0/authorise/jwt_token?test=true
4
+ method: post
5
+ uri: https://gateway.sandbox.fatzebra.com.au/v1.0/authenticate/session
6
6
  body:
7
- encoding: US-ASCII
8
- string: ''
7
+ encoding: UTF-8
8
+ string: '{"test":true}'
9
9
  headers:
10
10
  Accept-Encoding:
11
11
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
@@ -13,8 +13,6 @@ http_interactions:
13
13
  - application/json
14
14
  User-Agent:
15
15
  - Ruby
16
- Host:
17
- - gateway.sandbox.fatzebra.com.au
18
16
  Authorization:
19
17
  - Basic VEVTVDpURVNU
20
18
  Content-Type:
@@ -33,14 +31,14 @@ http_interactions:
33
31
  X-Request-Version:
34
32
  - 1.21.8
35
33
  X-Request-Id:
36
- - 2cb2771998d04b67bf479f83c41cad0e
34
+ - 6345f4aa83efe6a86cda2508096718f6
37
35
  X-Runtime:
38
- - '0.045799'
36
+ - '0.026720'
39
37
  Transfer-Encoding:
40
38
  - chunked
41
39
  body:
42
40
  encoding: UTF-8
43
- string: '{"successful":true,"response":{"jwt":"eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NjczOTkyMDQsImlhdCI6MTU2NzM4NDgwNCwiaXNzIjoiNTgyZTBhMjAzM2ZhZGQxMjYwZjk5MGY2IiwianRpIjoiNmQzZDcxZTktMGE5YS00OTFlLWJkZmQtYjA5YWVlZDU5ZmY5IiwiT3JnVW5pdElkIjoiNTgyYmU5ZGVkYTUyOTMyYTk0NmM0NWM0IiwiT2JqZWN0aWZ5UGF5bG9hZCI6dHJ1ZSwiUmVmZXJlbmNlSWQiOiJlNjQ2MGFhNy05YjhhLTQ2MTQtOTZiOC02YjdhNzAxMmQxMDEifQ.KjC2WU5UUegB1h56jvGZ7XVU-0EuYE0MVepuwG9H-O8","reference_id":"e6460aa7-9b8a-4614-96b8-6b7a7012d101"},"errors":[],"test":true}'
41
+ string: '{"successful":true,"response":{"jwt":"eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NzE3MzY5NDIsImlhdCI6MTU3MTcyMjU0MiwiaXNzIjoiNTgyZTBhMjAzM2ZhZGQxMjYwZjk5MGY2IiwianRpIjoiNWU4YjQ1YzQtYWNjNS00NjM0LTgxZDEtOTUyNzlmMzA0NTc2IiwiT3JnVW5pdElkIjoiNTgyYmU5ZGVkYTUyOTMyYTk0NmM0NWM0IiwiT2JqZWN0aWZ5UGF5bG9hZCI6dHJ1ZSwiUmVmZXJlbmNlSWQiOiI2ZjVlMmY0NC1jMDdhLTRkY2MtOGU1MC1iYTZlZDk2MjI2NzAifQ.1y_D9q827OGFeRFfKdMebP4aiXmd0ATTIKNkZHFWy98","reference_id":"6f5e2f44-c07a-4dcc-8e50-ba6ed9622670"},"errors":null,"test":true}'
44
42
  http_version:
45
- recorded_at: Mon, 02 Sep 2019 00:40:04 GMT
43
+ recorded_at: Tue, 22 Oct 2019 05:35:42 GMT
46
44
  recorded_with: VCR 3.0.3
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://gateway.sandbox.fatzebra.com.au/v1.0/authenticate/session
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"confirm_url":"https://example.com","order_number":"xxxx-xxxx-xxxx","currency":"AUD","amount":100,"test":true}'
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - application/json
14
+ User-Agent:
15
+ - Ruby
16
+ Authorization:
17
+ - Basic VEVTVDpURVNU
18
+ Content-Type:
19
+ - application/json
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Cache-Control:
26
+ - no-store
27
+ Pragma:
28
+ - no-cache
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ X-Request-Version:
32
+ - 1.21.8
33
+ X-Request-Id:
34
+ - 584bf4db9875ffabe6b02cb5edfcba04
35
+ X-Runtime:
36
+ - '0.031480'
37
+ Transfer-Encoding:
38
+ - chunked
39
+ body:
40
+ encoding: UTF-8
41
+ string: '{"successful":true,"response":{"jwt":"eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NzE3MzY5NDIsImlhdCI6MTU3MTcyMjU0MiwiaXNzIjoiNTgyZTBhMjAzM2ZhZGQxMjYwZjk5MGY2IiwianRpIjoiNTFkMDQ5NzUtMDU3Ny00ZTI5LTk0YjMtNzg5MmZjMjM0MDc5IiwiT3JnVW5pdElkIjoiNTgyYmU5ZGVkYTUyOTMyYTk0NmM0NWM0IiwiT2JqZWN0aWZ5UGF5bG9hZCI6dHJ1ZSwiQ29uZmlybVVybCI6Imh0dHBzOi8vZXhhbXBsZS5jb20iLCJSZWZlcmVuY2VJZCI6IjE3YzE4NmJhLWVkNjUtNDhlMC05MjM5LWZiNmFjYTBlNWI2YyIsIlBheWxvYWQiOnsiT3JkZXJEZXRhaWxzIjp7Ik9yZGVyTnVtYmVyIjoieHh4eC14eHh4LXh4eHgiLCJDdXJyZW5jeUNvZGUiOiIwMzYiLCJBbW91bnQiOiIxMDAifX19.JZloBRlb8WwRtQs3AhRvbf5kzHwVhgAwK-Oz3LIyq4s","reference_id":"17c186ba-ed65-48e0-9239-fb6aca0e5b6c"},"errors":null,"test":true}'
42
+ http_version:
43
+ recorded_at: Tue, 22 Oct 2019 05:35:42 GMT
44
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://gateway.sandbox.fatzebra.com.au/v1.0/authenticate/session
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"reference_id":"xxxx-xxxx-xxxx","confirm_url":"https://example.com","order_number":"xxxx-xxxx-xxxx","currency":"AUD","amount":"INVALID","test":true}'
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - application/json
14
+ User-Agent:
15
+ - Ruby
16
+ Authorization:
17
+ - Basic VEVTVDpURVNU
18
+ Content-Type:
19
+ - application/json
20
+ response:
21
+ status:
22
+ code: 422
23
+ message: Unprocessable Entity
24
+ headers:
25
+ Cache-Control:
26
+ - no-store
27
+ Pragma:
28
+ - no-cache
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ X-Request-Version:
32
+ - 1.21.8
33
+ X-Request-Id:
34
+ - 419d283db39c727ebe7c4f2cf473af23
35
+ X-Runtime:
36
+ - '0.025645'
37
+ Transfer-Encoding:
38
+ - chunked
39
+ body:
40
+ encoding: UTF-8
41
+ string: '{"successful":false,"response":null,"errors":"Amount is invalid","test":true}'
42
+ http_version:
43
+ recorded_at: Tue, 22 Oct 2019 05:35:42 GMT
44
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,144 @@
1
+ require 'spec_helper'
2
+
3
+ describe FatZebra::Authenticate do
4
+ describe '.session', :vcr do
5
+ subject(:token) { FatZebra::Authenticate.session(valid_3ds_token_payload) }
6
+
7
+ let(:valid_3ds_token_payload) {{
8
+ reference_id: 'xxxx-xxxx-xxxx',
9
+ confirm_url: 'https://example.com',
10
+ order_number: 'xxxx-xxxx-xxxx',
11
+ currency: 'AUS',
12
+ amount: 100
13
+ }}
14
+
15
+ it 'returns JWT with given params' do
16
+ is_expected.to be_accepted
17
+ expect(token.jwt).to be_truthy
18
+ expect(token.reference_id).to be_truthy
19
+ end
20
+
21
+ it 'returns JWT with some params' do
22
+ valid_3ds_token_payload.delete(:reference_id)
23
+ is_expected.to be_accepted
24
+ expect(token.jwt).to be_truthy
25
+ expect(token.reference_id).to be_truthy
26
+ end
27
+
28
+ it 'returns JWT with no params' do
29
+ valid_3ds_token_payload.clear
30
+ is_expected.to be_accepted
31
+ expect(token.jwt).to be_truthy
32
+ expect(token.reference_id).to be_truthy
33
+ end
34
+
35
+ it 'returns error when amount is invalid' do
36
+ valid_3ds_token_payload[:amount] = 'INVALID'
37
+ is_expected.not_to be_accepted
38
+ expect(token.errors).to match(/Amount is invalid/)
39
+ end
40
+ end
41
+
42
+ describe '.decode_session', :vcr do
43
+ subject(:decoded) { FatZebra::Authenticate.decode_session(token: jwt) }
44
+
45
+ context 'when token is valid' do
46
+ let(:jwt) { FatZebra::Authenticate.session({}).jwt }
47
+
48
+ it 'decodes JWT' do
49
+ is_expected.to be_accepted
50
+ expect(decoded.keys).to include('payload')
51
+ expect(decoded.payload).to be_a(Hash)
52
+ expect(decoded.errors).not_to be_truthy
53
+ end
54
+ end
55
+
56
+ context 'when token is invalid' do
57
+ let(:jwt) { 'INVALID TOKEN' }
58
+
59
+ it 'returns error when invalid token' do
60
+ is_expected.not_to be_accepted
61
+ expect(decoded.errors).to match(/The token is invalid/)
62
+ end
63
+ end
64
+ end
65
+
66
+ describe '.authenticate', :vcr do
67
+ subject(:authenticate) { FatZebra::Authenticate.authenticate(valid_sca_authenticate_payload) }
68
+ let!(:credit_card) { FatZebra::Card.create(valid_credit_card_payload) }
69
+
70
+ context 'with invalid input' do
71
+ it do
72
+ valid_sca_authenticate_payload[:card_token] = 'INVALID'
73
+ is_expected.not_to be_accepted
74
+ expect(authenticate.errors).to match(/Card not found/)
75
+ end
76
+
77
+ it do
78
+ valid_sca_authenticate_payload[:sca] = {}
79
+ is_expected.not_to be_accepted
80
+ expect(authenticate.errors.join).to match(/Invalid input data/)
81
+ end
82
+
83
+ it do
84
+ valid_sca_authenticate_payload[:sca][:currency] = 'INVALID'
85
+ is_expected.not_to be_accepted
86
+ expect(authenticate.errors).to match(/3DS lookup request process failed/)
87
+ end
88
+
89
+ it do
90
+ valid_sca_authenticate_payload[:sca][:amount] = 'INVALID'
91
+ is_expected.not_to be_accepted
92
+ expect(authenticate.errors).to match(/3DS lookup request process failed/)
93
+ end
94
+ end
95
+
96
+ context 'with frictionless response' do
97
+ before do
98
+ valid_credit_card_payload[:card_number] = '4000000000001000'
99
+ end
100
+
101
+ it do
102
+ is_expected.to be_accepted
103
+ expect(authenticate.keys).to include('Enrolled', 'ACSUrl', 'CardBin', 'TransactionId')
104
+ expect(authenticate.errors).not_to be_truthy
105
+ end
106
+
107
+ it do
108
+ expect(authenticate.Enrolled).to be_truthy
109
+ expect(authenticate.CardBin).to be_truthy
110
+ expect(authenticate.ErrorNo).to eq('0')
111
+ expect(authenticate.ErrorDesc).not_to be_truthy
112
+ expect(authenticate.CardBrand).to be_truthy
113
+ expect(authenticate.TransactionId).to be_truthy
114
+ end
115
+ end
116
+
117
+ context 'with challenge response' do
118
+ before do
119
+ valid_credit_card_payload[:card_number] = '4000000000001091'
120
+ end
121
+
122
+ it do
123
+ is_expected.to be_accepted
124
+ expect(authenticate.keys).to include('Enrolled', 'ACSUrl', 'CardBin', 'TransactionId')
125
+ expect(authenticate.errors).not_to be_truthy
126
+ end
127
+
128
+ it do
129
+ expect(authenticate.Enrolled).to be_truthy
130
+ expect(authenticate.CardBin).to be_truthy
131
+ expect(authenticate.ErrorNo).to eq('0')
132
+ expect(authenticate.ErrorDesc).not_to be_truthy
133
+ expect(authenticate.CardBrand).to be_truthy
134
+ expect(authenticate.TransactionId).to be_truthy
135
+ end
136
+ end
137
+
138
+ context 'validations' do
139
+ let(:valid_sca_authenticate_payload) {{}}
140
+
141
+ it { expect{ authenticate }.to raise_error(FatZebra::RequestValidationError) }
142
+ end
143
+ end
144
+ end