solidus_afterpay 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +9 -0
  3. data/Gemfile +6 -3
  4. data/README.md +3 -0
  5. data/app/controllers/solidus_afterpay/callbacks_controller.rb +5 -1
  6. data/app/controllers/solidus_afterpay/express_callbacks_controller.rb +5 -1
  7. data/app/models/solidus_afterpay/order_component_builder.rb +1 -1
  8. data/bin/sandbox +1 -1
  9. data/lib/solidus_afterpay/configuration.rb +9 -2
  10. data/lib/solidus_afterpay/engine.rb +1 -1
  11. data/lib/solidus_afterpay/testing_support/factories.rb +1 -1
  12. data/lib/solidus_afterpay/version.rb +1 -1
  13. data/solidus_afterpay.gemspec +4 -4
  14. metadata +11 -99
  15. data/spec/fixtures/vcr_casettes/create_checkout/invalid.yml +0 -65
  16. data/spec/fixtures/vcr_casettes/create_checkout/valid.yml +0 -64
  17. data/spec/fixtures/vcr_casettes/credit/invalid.yml +0 -61
  18. data/spec/fixtures/vcr_casettes/credit/valid.yml +0 -63
  19. data/spec/fixtures/vcr_casettes/deferred/authorize/declined_payment.yml +0 -120
  20. data/spec/fixtures/vcr_casettes/deferred/authorize/invalid.yml +0 -61
  21. data/spec/fixtures/vcr_casettes/deferred/authorize/valid.yml +0 -120
  22. data/spec/fixtures/vcr_casettes/deferred/capture/invalid.yml +0 -61
  23. data/spec/fixtures/vcr_casettes/deferred/capture/valid.yml +0 -140
  24. data/spec/fixtures/vcr_casettes/deferred/void/invalid.yml +0 -61
  25. data/spec/fixtures/vcr_casettes/deferred/void/valid.yml +0 -137
  26. data/spec/fixtures/vcr_casettes/find_order/invalid.yml +0 -64
  27. data/spec/fixtures/vcr_casettes/find_order/valid.yml +0 -120
  28. data/spec/fixtures/vcr_casettes/find_payment/invalid.yml +0 -61
  29. data/spec/fixtures/vcr_casettes/find_payment/valid.yml +0 -140
  30. data/spec/fixtures/vcr_casettes/immediate/capture/declined_payment.yml +0 -120
  31. data/spec/fixtures/vcr_casettes/immediate/capture/invalid.yml +0 -61
  32. data/spec/fixtures/vcr_casettes/immediate/capture/valid.yml +0 -134
  33. data/spec/fixtures/vcr_casettes/retrieve_configuration/valid.yml +0 -67
  34. data/spec/helpers/solidus_afterpay/afterpay_helper_spec.rb +0 -39
  35. data/spec/models/solidus_afterpay/gateway_spec.rb +0 -492
  36. data/spec/models/solidus_afterpay/order_component_builder_spec.rb +0 -198
  37. data/spec/models/solidus_afterpay/payment_method_spec.rb +0 -207
  38. data/spec/models/solidus_afterpay/payment_source_spec.rb +0 -61
  39. data/spec/models/solidus_afterpay/user_agent_generator_spec.rb +0 -22
  40. data/spec/models/spree/order_spec.rb +0 -158
  41. data/spec/presenters/solidus_afterpay/order_presenter_spec.rb +0 -34
  42. data/spec/presenters/solidus_afterpay/shipping_rate_presenter_spec.rb +0 -28
  43. data/spec/requests/solidus_afterpay/callbacks_controller_spec.rb +0 -127
  44. data/spec/requests/solidus_afterpay/checkouts_controller_spec.rb +0 -258
  45. data/spec/requests/solidus_afterpay/express_callbacks_controller_spec.rb +0 -167
  46. data/spec/services/solidus_afterpay/base_service_spec.rb +0 -13
  47. data/spec/services/solidus_afterpay/shipping_rate_builder_service_spec.rb +0 -34
  48. data/spec/services/solidus_afterpay/update_order_addresses_service_spec.rb +0 -82
  49. data/spec/services/solidus_afterpay/update_order_attributes_service_spec.rb +0 -58
  50. data/spec/spec_helper.rb +0 -31
  51. data/spec/support/auth.rb +0 -15
  52. data/spec/support/cache.rb +0 -5
  53. data/spec/support/preferences.rb +0 -33
  54. data/spec/support/solidus.rb +0 -1
  55. data/spec/support/vcr.rb +0 -18
  56. data/spec/views/solidus_afterpay/express_checkout_button_spec.rb +0 -33
  57. data/spec/views/spree/shared/afterpay_messaging_spec.rb +0 -44
@@ -1,61 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: https://global-api-sandbox.afterpay.com/v2/payments/capture
6
- body:
7
- encoding: UTF-8
8
- string: '{"token":"INVALID_TOKEN","merchantReference":null,"amount":null}'
9
- headers:
10
- User-Agent:
11
- - SolidusAfterpay/0.0.1 (Solidus/3.0.1; Ruby/2.6.6; Merchant/100101481) https://
12
- Authorization:
13
- - Basic <ENCODED_AUTH_HEADER>
14
- Content-Type:
15
- - application/json
16
- Accept-Encoding:
17
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
- Accept:
19
- - "*/*"
20
- response:
21
- status:
22
- code: 402
23
- message: Payment Required
24
- headers:
25
- Date:
26
- - Wed, 25 Aug 2021 14:55:10 GMT
27
- Content-Type:
28
- - application/json
29
- Content-Length:
30
- - '163'
31
- Connection:
32
- - keep-alive
33
- Http-Correlation-Id:
34
- - 2m54dxammo5yivs22xpqy5ymp4
35
- X-Envoy-Upstream-Service-Time:
36
- - '65'
37
- Cf-Cache-Status:
38
- - DYNAMIC
39
- Expect-Ct:
40
- - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
41
- Set-Cookie:
42
- - __cf_bm=59dde99429147353c566297400188a205dd1c569-1629903310-1800-AW+vk29NN4QPXNzSzYsYy0du6wT4ILfy1NY9yfxHlmnG/9bR/OuBxCflDZ2b/f2kBF4GjBQ3d9y4Tov4NdIy990scvazqSnXwt/2X2iaTMBt;
43
- path=/; expires=Wed, 25-Aug-21 15:25:10 GMT; domain=.afterpay.com; HttpOnly;
44
- Secure; SameSite=None
45
- Strict-Transport-Security:
46
- - max-age=31536000; includeSubDomains; preload
47
- Server:
48
- - cloudflare
49
- Cf-Ray:
50
- - 6845a8e67fc5cd42-FCO
51
- body:
52
- encoding: UTF-8
53
- string: |-
54
- {
55
- "errorCode" : "invalid_token",
56
- "errorId" : "da76c8c79d41e92b",
57
- "message" : "Cannot complete payment, expired or invalid token.",
58
- "httpStatusCode" : 402
59
- }
60
- recorded_at: Wed, 25 Aug 2021 14:55:10 GMT
61
- recorded_with: VCR 6.0.0
@@ -1,134 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: https://global-api-sandbox.afterpay.com/v2/payments/capture
6
- body:
7
- encoding: UTF-8
8
- string: '{"token":"002.nt7e0ioqj00fh0ua1nbqcj6vcn9obtfsglqvrj9ijpo3edfc","merchantReference":null,"amount":null}'
9
- headers:
10
- User-Agent:
11
- - SolidusAfterpay/0.0.1 (Solidus/3.0.1; Ruby/2.6.6; Merchant/100101481) https://
12
- Authorization:
13
- - Basic <ENCODED_AUTH_HEADER>
14
- Content-Type:
15
- - application/json
16
- Accept-Encoding:
17
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
- Accept:
19
- - "*/*"
20
- response:
21
- status:
22
- code: 201
23
- message: Created
24
- headers:
25
- Date:
26
- - Wed, 25 Aug 2021 14:57:00 GMT
27
- Content-Type:
28
- - application/json
29
- Content-Length:
30
- - '1853'
31
- Connection:
32
- - keep-alive
33
- Http-Correlation-Id:
34
- - aybxyh56w3cheadll4m2tdy7q4
35
- X-Envoy-Upstream-Service-Time:
36
- - '52'
37
- Cf-Cache-Status:
38
- - DYNAMIC
39
- Expect-Ct:
40
- - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
41
- Set-Cookie:
42
- - __cf_bm=559bbd7450eb18d65d238a3f883de3d462989653-1629903420-1800-AZAsHum/8AJvXaC7SsSFuucq7UTebHQq8yI3EfbLOvY3g5R5nTPNo4NpNe4AJsWcz0yS5nit62GxjFvF2gp2C0JXbMys7O8SzRIgMSaMo0Lz;
43
- path=/; expires=Wed, 25-Aug-21 15:27:00 GMT; domain=.afterpay.com; HttpOnly;
44
- Secure; SameSite=None
45
- Strict-Transport-Security:
46
- - max-age=31536000; includeSubDomains; preload
47
- Server:
48
- - cloudflare
49
- Cf-Ray:
50
- - 6845ab96ea29cd2e-FCO
51
- body:
52
- encoding: UTF-8
53
- string: |-
54
- {
55
- "id" : "100101768366",
56
- "token" : "002.nt7e0ioqj00fh0ua1nbqcj6vcn9obtfsglqvrj9ijpo3edfc",
57
- "status" : "APPROVED",
58
- "created" : "2021-08-24T15:30:14.497Z",
59
- "originalAmount" : {
60
- "amount" : "22.04",
61
- "currency" : "USD"
62
- },
63
- "openToCaptureAmount" : {
64
- "amount" : "0.00",
65
- "currency" : "USD"
66
- },
67
- "paymentState" : "CAPTURED",
68
- "merchantReference" : "R903458715",
69
- "refunds" : [ {
70
- "amount" : {
71
- "amount" : "0.10",
72
- "currency" : "USD"
73
- },
74
- "refundId" : "1933891",
75
- "refundedAt" : "2021-08-25T10:09:30.819Z"
76
- }, {
77
- "amount" : {
78
- "amount" : "10.00",
79
- "currency" : "USD"
80
- },
81
- "refundId" : "1934419",
82
- "refundedAt" : "2021-08-25T14:56:33.753Z"
83
- } ],
84
- "orderDetails" : {
85
- "consumer" : {
86
- "phoneNumber" : "",
87
- "givenNames" : "Christian",
88
- "surname" : "Rimondi",
89
- "email" : "admin@example.com"
90
- },
91
- "billing" : {
92
- "name" : "Christian Rimondi",
93
- "line1" : "1313 Broadway",
94
- "line2" : "",
95
- "area1" : "New York",
96
- "region" : "NY",
97
- "postcode" : "10001",
98
- "phoneNumber" : "12524264421"
99
- },
100
- "shipping" : {
101
- "name" : "Christian Rimondi",
102
- "line1" : "1313 Broadway",
103
- "line2" : "",
104
- "area1" : "New York",
105
- "region" : "NY",
106
- "postcode" : "10001",
107
- "phoneNumber" : "12524264421"
108
- },
109
- "courier" : { },
110
- "items" : [ {
111
- "name" : "Ruby Tote",
112
- "sku" : "RUB-TOT01",
113
- "quantity" : 1,
114
- "price" : {
115
- "amount" : "15.99",
116
- "currency" : "USD"
117
- }
118
- } ],
119
- "discounts" : [ ]
120
- },
121
- "events" : [ {
122
- "id" : "1xBCPLdc9Opx4SQY8PeMXDtemsV",
123
- "created" : "2021-08-24T15:31:09.859Z",
124
- "expires" : null,
125
- "type" : "CAPTURED",
126
- "amount" : {
127
- "amount" : "22.04",
128
- "currency" : "USD"
129
- },
130
- "paymentEventMerchantReference" : null
131
- } ]
132
- }
133
- recorded_at: Wed, 25 Aug 2021 14:57:00 GMT
134
- recorded_with: VCR 6.0.0
@@ -1,67 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://global-api-sandbox.afterpay.com/v2/configuration
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- User-Agent:
11
- - SolidusAfterpay/0.0.1 (Solidus/3.0.1; Ruby/2.6.6; Merchant/100101481) https://
12
- Authorization:
13
- - Basic <ENCODED_AUTH_HEADER>
14
- Accept-Encoding:
15
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
- Accept:
17
- - "*/*"
18
- response:
19
- status:
20
- code: 200
21
- message: OK
22
- headers:
23
- Date:
24
- - Wed, 25 Aug 2021 14:56:02 GMT
25
- Content-Type:
26
- - application/json
27
- Content-Length:
28
- - '151'
29
- Connection:
30
- - keep-alive
31
- Cache-Control:
32
- - private, no-transform, max-age=1800
33
- Http-Correlation-Id:
34
- - u73bnoiwo265mfjp7rdrdzfsxu
35
- Vary:
36
- - Accept-Encoding
37
- X-Envoy-Upstream-Service-Time:
38
- - '10'
39
- Cf-Cache-Status:
40
- - DYNAMIC
41
- Expect-Ct:
42
- - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
43
- Set-Cookie:
44
- - __cf_bm=ebd26f3256f7c877137bf42087fa5550fed5965e-1629903362-1800-AcvTlx8l0pTK7CNPb9AuSNR0Gno8NZxAq/ln/lsb1QfRDTKngcaw3pe7umDu3S2LL583bb0jFHJGa/Lbzh3XP31WX5N+vTDZeMa33NSOwYtV;
45
- path=/; expires=Wed, 25-Aug-21 15:26:02 GMT; domain=.afterpay.com; HttpOnly;
46
- Secure; SameSite=None
47
- Strict-Transport-Security:
48
- - max-age=31536000; includeSubDomains; preload
49
- Server:
50
- - cloudflare
51
- Cf-Ray:
52
- - 6845aa2e5871cd32-FCO
53
- body:
54
- encoding: UTF-8
55
- string: |-
56
- {
57
- "minimumAmount" : {
58
- "amount" : "1.00",
59
- "currency" : "USD"
60
- },
61
- "maximumAmount" : {
62
- "amount" : "1000.00",
63
- "currency" : "USD"
64
- }
65
- }
66
- recorded_at: Wed, 25 Aug 2021 14:56:02 GMT
67
- recorded_with: VCR 6.0.0
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe SolidusAfterpay::AfterpayHelper, type: :helper do
4
- describe '#include_afterpay_js' do
5
- subject { helper.include_afterpay_js(test_mode: test_mode) }
6
-
7
- context 'when test_mode is false' do
8
- let(:test_mode) { false }
9
-
10
- it 'includes the production javascript' do
11
- is_expected
12
- .to eq(
13
- <<-SCRIPT.squish
14
- <script src="https://portal.afterpay.com/afterpay-async.js"
15
- async="async"
16
- defer="defer"
17
- onload="initAfterpay()"></script>
18
- SCRIPT
19
- )
20
- end
21
- end
22
-
23
- context 'when test_mode is true' do
24
- let(:test_mode) { true }
25
-
26
- it 'includes the sandbox javascript' do
27
- is_expected
28
- .to eq(
29
- <<-SCRIPT.squish
30
- <script src="https://portal.sandbox.afterpay.com/afterpay-async.js"
31
- async="async"
32
- defer="defer"
33
- onload="initAfterpay()"></script>
34
- SCRIPT
35
- )
36
- end
37
- end
38
- end
39
- end