portage-ucp-bigcommerce 0.2.0 → 0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a71c96dc602da8be5b13f7356611d8172038c49c8b9d42d8d5b2208e9e2213f
4
- data.tar.gz: 0137c7b98d2e2578320aa73608b85acbc5a7f5d826f4ea0e34a6cab9e4e6e5b2
3
+ metadata.gz: 608b4a53ae0a7392f15442bba6232678962d390314e7174715ffca940dba6496
4
+ data.tar.gz: f55e4cbc4d56e73bc35c5368c59a8d2f831d2895b9110c03383fff81851384a8
5
5
  SHA512:
6
- metadata.gz: f8760851e94163dfa43272181da97bd191b137f7315076b1471aed3469b10fa88b840897986b4836d5a5a72da1949b180684b6427beff6c0f99313fca40a8c68
7
- data.tar.gz: 638a13c5fd1441e3ad7d4b42196e4ce7aac87034de7580ecfc33d20dbf780bb9fe6f67f246c7b320e8c42779f96152fc7d06a89ba613ddc9f01170fa2771ef12
6
+ metadata.gz: b76a1bd7332fc964e495da185bde5bc6943c7f2f193587fdcb9a5001d18ca01fe4f8284f25931cfe505809bd199c088fb02c48d1e667cf7bfd05bfdcb1b89283
7
+ data.tar.gz: e228f872c5e017b451074dc422b02a601b6b28908e8819211686b7c00508d51b83bd33c851b5ef8eeeb9385adcf8a6cfe7b95d6f5a576671ede013a81fb3c17b
data/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@ pre-1.0, so APIs may still shift between minor versions.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.2.1] - 2026-10-07
10
+
11
+ - **Fixed: a checkout the shopper paid for in the browser now reads as `completed` from a new process.** Status lived only in the creating process, so `portage orders reconcile` always saw `incomplete`, and once BigCommerce deleted the paid cart, not-found. `#get_checkout` now asks v2 List Orders for an order with this `cart_id` in a paid status (Shipped, Awaiting Fulfillment, Completed and the like; not Awaiting Payment, Pending or Incomplete) and then reports `completed` with the `order` confirmation, rebuilding the checkout from that order if the cart is gone. No order, or a failed lookup, keeps `incomplete`/not-found. Needs `portage-ucp` 0.13.0 for the `CheckoutState` platform hook, so the gem now requires `portage-ucp` `~> 0.13`. Patch-level.
12
+
9
13
  ## [0.2.0] - 2026-10-05
10
14
 
11
15
  - **Removed the unused `Client#v2_post` and `Client#v3_put`.** Nothing in the gem called them. They were public on the client class, so this is **breaking** for any caller using them directly; minor-level for a pre-1.0 gem.
@@ -43,6 +43,16 @@ module Portage
43
43
  # than an empty body, which UCP's reads report as nil.
44
44
  include Portage::Ucp::Support::NotFound
45
45
 
46
+ # Order statuses that mean the shopper placed and paid the order
47
+ # (https://docs.bigcommerce.com/developer/api-reference/rest/admin/management/orders/order-status/get-order-statuses):
48
+ # 2 Shipped, 3 Partially Shipped, 4 Refunded, 8 Awaiting Pickup,
49
+ # 9 Awaiting Shipment, 10 Completed, 11 Awaiting Fulfillment ("payment
50
+ # has been confirmed"), 13 Disputed, 14 Partially Refunded. Left out:
51
+ # 0 Incomplete and 1 Pending (checkout not finished), 7 Awaiting
52
+ # Payment (not confirmed yet), 12 Manual Verification Required, and
53
+ # 5 Cancelled / 6 Declined, which stay pending rather than guess.
54
+ PLACED_ORDER_STATUS_IDS = [2, 3, 4, 8, 9, 10, 11, 13, 14].freeze
55
+
46
56
  def initialize(client:, site_url:, currency:, payment_gateway_id: nil)
47
57
  super()
48
58
  @client = client
@@ -114,11 +124,16 @@ module Portage
114
124
  end
115
125
  end
116
126
 
127
+ # A paid checkout's cart is deleted ("Once the order is paid, the
128
+ # cart is deleted", Create an Order docs), so a not-found here falls
129
+ # back to the order BigCommerce placed from it, if any (see
130
+ # #platform_checkout_order).
117
131
  def get_checkout(checkout_id:)
118
- nil_on_not_found do
119
- node = fetch_checkout_node(checkout_id)
120
- node && Mapper.checkout(node, id: checkout_id, status: checkout_status(checkout_id))
121
- end
132
+ node = nil_on_not_found { fetch_checkout_node(checkout_id) }
133
+ return checkout_from_platform_order(checkout_id) unless node
134
+
135
+ Mapper.checkout(node, id: checkout_id, status: checkout_status(checkout_id),
136
+ order: checkout_order(checkout_id))
122
137
  end
123
138
 
124
139
  # Full replacement, same rationale as #update_cart — BigCommerce's
@@ -158,6 +173,20 @@ module Portage
158
173
 
159
174
  private
160
175
 
176
+ # Support::CheckoutState's platform hook. v2 List Orders filters on
177
+ # `cart_id`, "the cart ID from which this order originated", and the
178
+ # checkout id here *is* the cart id
179
+ # (https://docs.bigcommerce.com/developer/api-reference/rest/admin/management/orders/get-orders).
180
+ # v2 answers an empty list with 204 and no body, which parses as {}.
181
+ def platform_checkout_order(checkout_id)
182
+ orders = @client.v2_get("/orders?cart_id=#{URI.encode_www_form_component(checkout_id)}")
183
+ placed = Array(orders).find { |o| o.is_a?(Hash) && PLACED_ORDER_STATUS_IDS.include?(o["status_id"]) }
184
+ return nil unless placed
185
+
186
+ Mapper.order(placed, products: @client.v2_get("/orders/#{placed['id']}/products"), site_url: @site_url,
187
+ checkout_id: checkout_id)
188
+ end
189
+
161
190
  def fetch_cart_node(cart_id)
162
191
  include_param = "line_items.physical_items.options,line_items.digital_items.options"
163
192
  @client.v3_get("/carts/#{cart_id}?include=#{include_param}")["data"]
@@ -1,7 +1,7 @@
1
1
  module Portage
2
2
  module Ucp
3
3
  module BigCommerce
4
- VERSION = "0.2.0".freeze
4
+ VERSION = "0.2.1".freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: portage-ucp-bigcommerce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Whitbread
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-10-05 00:00:00.000000000 Z
11
+ date: 2026-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: portage-ucp
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.8'
19
+ version: '0.13'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.8'
26
+ version: '0.13'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement