portage-ucp-bigcommerce 0.1.5 → 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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 608b4a53ae0a7392f15442bba6232678962d390314e7174715ffca940dba6496
|
|
4
|
+
data.tar.gz: f55e4cbc4d56e73bc35c5368c59a8d2f831d2895b9110c03383fff81851384a8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b76a1bd7332fc964e495da185bde5bc6943c7f2f193587fdcb9a5001d18ca01fe4f8284f25931cfe505809bd199c088fb02c48d1e667cf7bfd05bfdcb1b89283
|
|
7
|
+
data.tar.gz: e228f872c5e017b451074dc422b02a601b6b28908e8819211686b7c00508d51b83bd33c851b5ef8eeeb9385adcf8a6cfe7b95d6f5a576671ede013a81fb3c17b
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,16 @@ 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
|
+
|
|
13
|
+
## [0.2.0] - 2026-10-05
|
|
14
|
+
|
|
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.
|
|
16
|
+
|
|
17
|
+
- **Removed `Mapper.money`.** It was a one-line pass-through to `Support::Amounts.money` that nothing in the gem called. It is a public module function, so this is **breaking** for any caller using it directly; minor-level for a pre-1.0 gem.
|
|
18
|
+
|
|
9
19
|
## [0.1.5] - 2026-09-29
|
|
10
20
|
|
|
11
21
|
- Fixes a `NoMethodError` at launch: `exe/portage-ucp-bigcommerce` handed
|
data/exe/portage-ucp-bigcommerce
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
# vars, and — since this gem ships with permissive-nothing defaults (see
|
|
6
6
|
# README's "Security hooks") — wire a real Authenticator/RateLimiter/etc. via
|
|
7
7
|
# a config file loaded with PORTAGE_UCP_CONFIG, the same way `rackup -r` or
|
|
8
|
-
# Sidekiq's `-r` work — see
|
|
8
|
+
# Sidekiq's `-r` work — see a starting point at
|
|
9
|
+
# https://github.com/tomtom87/Portage/blob/main/portage-ucp/examples/portage_ucp.rb.
|
|
9
10
|
# Without one, the server still starts but rejects every mutating call.
|
|
10
11
|
#
|
|
11
12
|
# BIGCOMMERCE_PAYMENT_GATEWAY_ID is optional — only needed to call
|
|
@@ -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
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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"]
|
|
@@ -39,10 +39,6 @@ module Portage
|
|
|
39
39
|
admin_request(Net::HTTP::Get, "v2", path)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
def v2_post(path, body = {})
|
|
43
|
-
admin_request(Net::HTTP::Post, "v2", path, body)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
42
|
def v3_get(path)
|
|
47
43
|
admin_request(Net::HTTP::Get, "v3", path)
|
|
48
44
|
end
|
|
@@ -51,10 +47,6 @@ module Portage
|
|
|
51
47
|
admin_request(Net::HTTP::Post, "v3", path, body)
|
|
52
48
|
end
|
|
53
49
|
|
|
54
|
-
def v3_put(path, body = {})
|
|
55
|
-
admin_request(Net::HTTP::Put, "v3", path, body)
|
|
56
|
-
end
|
|
57
|
-
|
|
58
50
|
def v3_delete(path)
|
|
59
51
|
admin_request(Net::HTTP::Delete, "v3", path)
|
|
60
52
|
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.1
|
|
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-
|
|
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.
|
|
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.
|
|
26
|
+
version: '0.13'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rspec
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|