spree_doordash 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +27 -1
- data/app/services/spree_doordash/quote.rb +22 -2
- data/config/initializers/spree.rb +17 -0
- data/lib/spree_doordash/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 11ea8c9082c5f3a17fb5e7ad172eab82c717d17af077bee7d0df14c92a75fba6
|
|
4
|
+
data.tar.gz: 5e435d16a2bef4e610760fb993533cf54f31a81343b1f5ade02f7889f8eb622c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bcee352d7bc9b0a6eeb877d5cd112cf40de922de796739f607058ad92735c787f665641d981d501e3d21af5b82b7e8f4e289b4a96cc6351d659d9f78eed95174
|
|
7
|
+
data.tar.gz: 99e77a1d48d37fe6f1573341a0e93d90f4d7a68690ede1f1ecdfc43c508340ef9b60aec101f9c4b7aea32fca25109dc94e8f13f8712124802f8b4e64e7866295
|
data/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented here.
|
|
4
4
|
|
|
5
|
-
## 0.1.
|
|
5
|
+
## 0.1.1
|
|
6
|
+
|
|
7
|
+
Two real production bugs, both invisible to the full spec suite and to every prior "live
|
|
8
|
+
verification" in this project, both found only by driving a genuine storefront checkout end to
|
|
9
|
+
end instead of calling the services directly:
|
|
10
|
+
|
|
11
|
+
- **DoorDash rejects any phone number that isn't strict E.164.** Every earlier live test in this
|
|
12
|
+
project — including the M1–M5 verifications documented below — happened to type phone numbers
|
|
13
|
+
directly in `+1XXXXXXXXXX` form. The first real checkout, with a number typed the way an address
|
|
14
|
+
form actually produces one (`(202) 555-0199`), got a real `400 Unknown phone number format` from
|
|
15
|
+
DoorDash's `/drive/v2/quotes` endpoint — which silently dropped the DoorDash Delivery shipping
|
|
16
|
+
rate with no error surfaced anywhere in checkout. Fixed by normalizing both `pickup_phone_number`
|
|
17
|
+
and `dropoff_phone_number` to E.164 before every quote request.
|
|
18
|
+
|
|
19
|
+
- **The order-completed subscriber was never actually registered with Spree's event system.**
|
|
20
|
+
`Spree::Subscriber`'s own docstring claims subscribers are "automatically registered during Rails
|
|
21
|
+
initialization" — that's not what `spree_core` 5.6.1 actually does. `Spree::Events.register_subscribers!`
|
|
22
|
+
only iterates an explicit `Spree.subscribers` array, populated via `Spree.subscribers << YourClass`
|
|
23
|
+
in an initializer; there's no automatic scan. This gem never had that initializer line. Every spec
|
|
24
|
+
for `OrderCompletedSubscriber` called `.call` on it directly, which bypasses the registry entirely
|
|
25
|
+
and kept passing regardless — so a real storefront order, placed with DoorDash Delivery selected,
|
|
26
|
+
completed successfully and was never dispatched, with nothing anywhere indicating a problem. Fixed
|
|
27
|
+
by adding the missing `config/initializers/spree.rb`, plus a new spec that asserts
|
|
28
|
+
`Spree.subscribers` actually includes the class — the one test that would have caught this from
|
|
29
|
+
the start.
|
|
30
|
+
|
|
31
|
+
## 0.1.0
|
|
6
32
|
|
|
7
33
|
Initial development. M1 (foundation) — complete and verified against a real DoorDash Sandbox
|
|
8
34
|
endpoint (`bin/rails spree_doordash:verify_connection`, a real accepted quote):
|
|
@@ -73,14 +73,34 @@ module SpreeDoordash
|
|
|
73
73
|
external_delivery_id: external_delivery_id,
|
|
74
74
|
pickup_address: format_address(location_mapping.stock_location),
|
|
75
75
|
pickup_business_name: location_mapping.stock_location.name,
|
|
76
|
-
pickup_phone_number: location_mapping.stock_location.phone
|
|
76
|
+
pickup_phone_number: format_phone(location_mapping.stock_location.phone),
|
|
77
77
|
pickup_instructions: location_mapping.stock_location.pickup_instructions,
|
|
78
78
|
dropoff_address: format_address(order.ship_address),
|
|
79
|
-
dropoff_phone_number: order.ship_address.phone
|
|
79
|
+
dropoff_phone_number: format_phone(order.ship_address.phone),
|
|
80
80
|
order_value: (order.total * 100).to_i
|
|
81
81
|
}
|
|
82
82
|
end
|
|
83
83
|
|
|
84
|
+
# DoorDash wants E.164 (+1XXXXXXXXXX) and rejects anything else outright
|
|
85
|
+
# — confirmed live: a real checkout with a normally-typed US phone number
|
|
86
|
+
# ("(202) 555-0199", exactly what an address form produces) got a real
|
|
87
|
+
# 400 "Unknown phone number format" from DoorDash, silently dropping the
|
|
88
|
+
# DoorDash Delivery rate with no visible error anywhere in the UI. Every
|
|
89
|
+
# earlier live verification in this project used numbers already typed
|
|
90
|
+
# in +1XXXXXXXXXX form by hand, which is why this never surfaced until
|
|
91
|
+
# an actual storefront checkout was driven through normally.
|
|
92
|
+
#
|
|
93
|
+
# US-only, matching the rest of this demo (every address here is a US
|
|
94
|
+
# address) — strips everything but digits, assumes a bare 10-digit
|
|
95
|
+
# number is domestic and prepends the country code.
|
|
96
|
+
def format_phone(raw)
|
|
97
|
+
digits = raw.to_s.gsub(/\D/, '')
|
|
98
|
+
digits = "1#{digits}" if digits.length == 10
|
|
99
|
+
return '+10000000000' if digits.blank?
|
|
100
|
+
|
|
101
|
+
"+#{digits}"
|
|
102
|
+
end
|
|
103
|
+
|
|
84
104
|
# Spree::StockLocation and Spree::Address share the same field shape
|
|
85
105
|
# (address1/address2/city/state/zipcode/country) even though they're
|
|
86
106
|
# unrelated classes — DoorDash wants one flat string, not structured
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Registers this extension's event subscriber with Spree's event system.
|
|
2
|
+
#
|
|
3
|
+
# Spree::Subscriber's own docstring says subscribers are "automatically
|
|
4
|
+
# registered during Rails initialization" — that's not what actually
|
|
5
|
+
# happens in spree_core 5.6.1: Spree::Events.register_subscribers! only
|
|
6
|
+
# ever iterates the explicit Spree.subscribers array (see
|
|
7
|
+
# spree_core/lib/spree/events.rb) — there is no Zeitwerk-descendant scan.
|
|
8
|
+
# Without this file, SpreeDoordash::OrderCompletedSubscriber is a real,
|
|
9
|
+
# loadable class (so specs calling it directly always passed) but is never
|
|
10
|
+
# actually wired to the 'order.completed' event in the running app — found
|
|
11
|
+
# live: a real storefront order completed with DoorDash Delivery selected
|
|
12
|
+
# and never got dispatched, because nothing ever appended this subscriber
|
|
13
|
+
# to Spree.subscribers. Mirrors spree_square's own identical registration
|
|
14
|
+
# in its own config/initializers/spree.rb.
|
|
15
|
+
Rails.application.config.after_initialize do
|
|
16
|
+
Spree.subscribers << SpreeDoordash::OrderCompletedSubscriber
|
|
17
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_doordash
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Amit Solanki
|
|
@@ -136,6 +136,7 @@ files:
|
|
|
136
136
|
- app/views/spree/admin/doordash_delivery_mappings/index.html.erb
|
|
137
137
|
- app/views/spree/admin/doordash_webhook_events/index.html.erb
|
|
138
138
|
- config/brakeman.ignore
|
|
139
|
+
- config/initializers/spree.rb
|
|
139
140
|
- config/initializers/spree_admin_doordash_navigation.rb
|
|
140
141
|
- config/initializers/spree_admin_doordash_tables.rb
|
|
141
142
|
- config/initializers/spree_doordash_calculators.rb
|