spree_doordash 0.1.1 → 0.1.2
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 +4 -4
- data/CHANGELOG.md +22 -0
- data/app/models/spree/calculator/shipping/doordash_quote.rb +20 -1
- data/app/services/spree_doordash/quote.rb +18 -2
- data/lib/spree_doordash/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4386dd5c8b44b1fa483213fcfae97c5c21ad8143f92650714fb7cc0f1966e059
|
|
4
|
+
data.tar.gz: 75d2fbda1b0870f14397a77a042b518c6b5972f1e7d8c3fb7f4c38ca182395ea
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b9c8465fcded4299713522d77ddf130c6ad9c8479233644fe9efe41817b90b08f7d6e8dd4edd99d88ee9c2b5b408668315d8f3bb58f2d8be47be708eeb7e34ef
|
|
7
|
+
data.tar.gz: 2ad0971dfd7551ebcb0e6ebac5c0fbe94a4ef7d5c8f6022469ee8c937cd31ded0d17c7c0ea2ed6e6fb94c1426d906a0ccd72b1f3de5b7d38513207a0780f6d64
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented here.
|
|
4
4
|
|
|
5
|
+
## 0.1.2
|
|
6
|
+
|
|
7
|
+
A real bug found live during checkout-validation work: a blank phone on the dropoff address used
|
|
8
|
+
to fall back to a fake placeholder number (`+10000000000`) that DoorDash's API rejected anyway —
|
|
9
|
+
the request was doomed before it was even built, and (same as the E.164 issue fixed in 0.1.1) the
|
|
10
|
+
DoorDash Delivery rate just silently vanished with no error anywhere in the UI.
|
|
11
|
+
|
|
12
|
+
- `SpreeDoordash::Quote#call` now returns early (no API call at all) when the ship address has no
|
|
13
|
+
phone, instead of building a request known to fail. `format_phone`'s placeholder fallback is
|
|
14
|
+
removed entirely.
|
|
15
|
+
- `Spree::Calculator::Shipping::DoordashQuote#compute_package` now pushes a
|
|
16
|
+
`doordash_quote_unavailable` warning onto `Spree::Order#warnings` whenever `SpreeDoordash::Quote`
|
|
17
|
+
returns `nil` — generic to *why* the quote failed (bad/missing phone, an address DoorDash
|
|
18
|
+
genuinely can't serve, DoorDash API down), confirmed live for two different real causes.
|
|
19
|
+
`Spree::Order#warnings` is the same transient mechanism core's own
|
|
20
|
+
`ensure_available_shipping_rates` already uses for the identical class of problem, and flows
|
|
21
|
+
through to the Store API's `cart.warnings` with no new API surface. A storefront reference
|
|
22
|
+
implementation now renders this as a real, non-blocking banner instead of silence — see
|
|
23
|
+
`spree_storefront_web`'s `DeliveryMethodSection.tsx`.
|
|
24
|
+
|
|
25
|
+
Full suite: 90 examples, 0 failures (2 new). Coverage: 94.14% (241/256 lines). Brakeman clean.
|
|
26
|
+
|
|
5
27
|
## 0.1.1
|
|
6
28
|
|
|
7
29
|
Two real production bugs, both invisible to the full spec suite and to every prior "live
|
|
@@ -20,7 +20,26 @@ module Spree
|
|
|
20
20
|
|
|
21
21
|
def compute_package(package)
|
|
22
22
|
result = SpreeDoordash::Quote.call(package.order)
|
|
23
|
-
|
|
23
|
+
if result.nil?
|
|
24
|
+
# A real bug found live: a nil Result here (bad/missing phone, an
|
|
25
|
+
# address DoorDash genuinely can't serve, DoorDash API down —
|
|
26
|
+
# SpreeDoordash::Quote#call collapses all of these to the same
|
|
27
|
+
# "unavailable" nil, deliberately, so this stays generic to *why*)
|
|
28
|
+
# used to just make the rate silently vanish with zero signal
|
|
29
|
+
# anywhere in the UI. Spree::Order#warnings is the same
|
|
30
|
+
# transient, request-scoped mechanism core's own
|
|
31
|
+
# `ensure_available_shipping_rates` already uses for the
|
|
32
|
+
# identical class of problem (a line item that can't ship at
|
|
33
|
+
# all) — it flows through to the Store API's `cart.warnings`
|
|
34
|
+
# with no new API surface needed. The storefront renders its own
|
|
35
|
+
# localized copy for this code; `message` here is English-only,
|
|
36
|
+
# a fallback for any other API consumer, not the UI text itself.
|
|
37
|
+
package.order.warnings |= [{
|
|
38
|
+
code: 'doordash_quote_unavailable',
|
|
39
|
+
message: 'We could not get a DoorDash delivery quote for this address.'
|
|
40
|
+
}]
|
|
41
|
+
return nil
|
|
42
|
+
end
|
|
24
43
|
|
|
25
44
|
result.fee_cents / 100.0
|
|
26
45
|
end
|
|
@@ -17,6 +17,16 @@ module SpreeDoordash
|
|
|
17
17
|
def call(order)
|
|
18
18
|
location_mapping = location_mapping_for(order)
|
|
19
19
|
return nil unless location_mapping && order.ship_address
|
|
20
|
+
# A real bug found live: with no phone on the ship address,
|
|
21
|
+
# `format_phone` used to fall back to a fake placeholder number that
|
|
22
|
+
# DoorDash's API correctly rejects with a 400 — the request was
|
|
23
|
+
# doomed before it was even built. `Spree::Config[:address_requires_phone]`
|
|
24
|
+
# (spree_host) should make this unreachable in the normal storefront
|
|
25
|
+
# checkout flow, but this guard stays as defense in depth for any
|
|
26
|
+
# other path that can create an order (admin, API, migrated data)
|
|
27
|
+
# — same "unavailable, not exceptional" nil-return shape as every
|
|
28
|
+
# other unserviceable case below.
|
|
29
|
+
return nil if order.ship_address.phone.blank?
|
|
20
30
|
|
|
21
31
|
client = SpreeDoordash::Client.for_store(order.store || Spree::Store.default)
|
|
22
32
|
# A random suffix per attempt, not just order.number — confirmed live
|
|
@@ -93,11 +103,17 @@ module SpreeDoordash
|
|
|
93
103
|
# US-only, matching the rest of this demo (every address here is a US
|
|
94
104
|
# address) — strips everything but digits, assumes a bare 10-digit
|
|
95
105
|
# number is domestic and prepends the country code.
|
|
106
|
+
#
|
|
107
|
+
# No blank-phone fallback here (a prior version faked one as
|
|
108
|
+
# "+10000000000" — DoorDash rejected it too, just as uninformatively as
|
|
109
|
+
# a missing one; better to let a genuinely blank pickup phone fail
|
|
110
|
+
# DoorDash's own validation loudly than paper over it with fake data).
|
|
111
|
+
# `call` above already guards the dropoff phone specifically; this
|
|
112
|
+
# method is also reused for the pickup (StockLocation) phone, which is
|
|
113
|
+
# real business data expected to always be set.
|
|
96
114
|
def format_phone(raw)
|
|
97
115
|
digits = raw.to_s.gsub(/\D/, '')
|
|
98
116
|
digits = "1#{digits}" if digits.length == 10
|
|
99
|
-
return '+10000000000' if digits.blank?
|
|
100
|
-
|
|
101
117
|
"+#{digits}"
|
|
102
118
|
end
|
|
103
119
|
|