@colixsystems/widget-sdk 0.321.0 → 0.321.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.
- package/README.md +5 -1
- package/dist/hooks.js +11 -1
- package/dist/index.d.ts +11 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -91,7 +91,11 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
91
91
|
|
|
92
92
|
## Status
|
|
93
93
|
|
|
94
|
-
`v0.321.
|
|
94
|
+
`v0.321.1` — pre-publish. The package surface (types, function names, export paths) is the v1 contract; runtime behaviour for some hooks is stubbed (each hook documents what's wired and what isn't). It is **not yet published to npm**.
|
|
95
|
+
|
|
96
|
+
### What's new in 0.321.1 (contract 1.261.0)
|
|
97
|
+
|
|
98
|
+
**A refused plan purchase now says why.** Buying a plan with `useAccessPlans().purchase` is refused with `ALREADY_OWNED` when the user already holds it, and with `PURCHASE_IN_PROGRESS` when their earlier checkout for it is still open (it goes stale after about 15 minutes). Both were reported as retryable, so a widget that follows the usual pattern (show `err.message` only when `retryable` is `false`) showed a generic "did not go through" with a Try again button. They are now non-retryable, so `err.message` ("You already have this plan.", "A payment for this plan is already in progress.") is what the widget shows. Widgets already built to that pattern change without a rebuild.
|
|
95
99
|
|
|
96
100
|
### What's new in 0.321.0 (contract 1.261.0)
|
|
97
101
|
|
package/dist/hooks.js
CHANGED
|
@@ -7077,8 +7077,11 @@ export function useIdentification(options) {
|
|
|
7077
7077
|
// sc-4650 — the refusals that retrying the SAME charge can never clear: the
|
|
7078
7078
|
// workspace, the widget manifest, or the amount has to change first. Everything
|
|
7079
7079
|
// else (a decline, a provider blip, an unknown failure) is worth another
|
|
7080
|
-
// attempt. A widget reads this through `PaymentError.retryable`.
|
|
7080
|
+
// attempt. A widget reads this through `PaymentError.retryable`. The two plan
|
|
7081
|
+
// refusals are here so a widget shows their reason: an immediate retry cannot
|
|
7082
|
+
// clear them (a plan the user already holds; another open checkout for it).
|
|
7081
7083
|
const NON_RETRYABLE_PAYMENT_CODES = new Set([
|
|
7084
|
+
"ALREADY_OWNED",
|
|
7082
7085
|
"AUTH_REQUIRED",
|
|
7083
7086
|
"AMOUNT_TOO_LARGE",
|
|
7084
7087
|
"BUSINESS_IDENTITY_REQUIRED",
|
|
@@ -7095,6 +7098,7 @@ const NON_RETRYABLE_PAYMENT_CODES = new Set([
|
|
|
7095
7098
|
"PAYMENTS_DISABLED",
|
|
7096
7099
|
"PAYMENTS_SCOPE_NOT_GRANTED",
|
|
7097
7100
|
"PAYMENTS_UNAVAILABLE",
|
|
7101
|
+
"PURCHASE_IN_PROGRESS",
|
|
7098
7102
|
"TRIAL_RESTRICTED",
|
|
7099
7103
|
"UNSUPPORTED_CURRENCY",
|
|
7100
7104
|
"VALIDATION",
|
|
@@ -7124,6 +7128,12 @@ const NON_RETRYABLE_PAYMENT_CODES = new Set([
|
|
|
7124
7128
|
* `order` is not one this user can pay for
|
|
7125
7129
|
* - "ORDER_PAYMENT_IN_PROGRESS" — another checkout for the order is open
|
|
7126
7130
|
* (retryable: it clears when that one ends)
|
|
7131
|
+
* - "ALREADY_OWNED" — `useAccessPlans().purchase` for a plan the
|
|
7132
|
+
* user already holds; show the message
|
|
7133
|
+
* - "PURCHASE_IN_PROGRESS" — `useAccessPlans().purchase` while the
|
|
7134
|
+
* user's earlier checkout for that plan is
|
|
7135
|
+
* still open (it goes stale after about 15
|
|
7136
|
+
* minutes); show the message, not a retry
|
|
7127
7137
|
* - "TRIAL_RESTRICTED" — a trial workspace takes no guest payments
|
|
7128
7138
|
* - "GUEST_CHECKOUT_LIMIT_REACHED" — the shop's guest budget is spent for now
|
|
7129
7139
|
* - "CAPTCHA_FAILED" / "CAPTCHA_UNAVAILABLE" — the guest's security check
|
package/dist/index.d.ts
CHANGED
|
@@ -1722,11 +1722,15 @@ export interface AppSubscriptionApi {
|
|
|
1722
1722
|
export function useAppSubscription(): AppSubscriptionApi;
|
|
1723
1723
|
|
|
1724
1724
|
/**
|
|
1725
|
-
* Rejection thrown by both `usePayments()` callbacks
|
|
1726
|
-
*
|
|
1727
|
-
* `
|
|
1728
|
-
*
|
|
1729
|
-
* "try again" that loops the payer
|
|
1725
|
+
* Rejection thrown by both `usePayments()` callbacks and by
|
|
1726
|
+
* `useAccessPlans().purchase`. `code` is the server's own reason when it sent
|
|
1727
|
+
* one; `message` is its user-safe sentence. Branch on `retryable`: false means
|
|
1728
|
+
* the same charge can never succeed until the workspace, the manifest, or the
|
|
1729
|
+
* amount changes — show the reason, not a "try again" that loops the payer
|
|
1730
|
+
* forever. Two plan refusals are also non-retryable so their reason shows:
|
|
1731
|
+
* `ALREADY_OWNED` (the user holds the plan) and `PURCHASE_IN_PROGRESS` (their
|
|
1732
|
+
* earlier checkout for the plan is still open; it goes stale after about 15
|
|
1733
|
+
* minutes).
|
|
1730
1734
|
*/
|
|
1731
1735
|
export class PaymentError extends Error {
|
|
1732
1736
|
code:
|
|
@@ -1746,6 +1750,8 @@ export class PaymentError extends Error {
|
|
|
1746
1750
|
| "ORDER_NOT_PAYABLE"
|
|
1747
1751
|
| "ORDER_ALREADY_PAID"
|
|
1748
1752
|
| "ORDER_PAYMENT_IN_PROGRESS"
|
|
1753
|
+
| "ALREADY_OWNED"
|
|
1754
|
+
| "PURCHASE_IN_PROGRESS"
|
|
1749
1755
|
| "TRIAL_RESTRICTED"
|
|
1750
1756
|
| "GUEST_CHECKOUT_LIMIT_REACHED"
|
|
1751
1757
|
| "CAPTCHA_FAILED"
|
package/package.json
CHANGED