@fun-xyz/fiat-contract 0.21.0 → 0.22.0

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 CHANGED
@@ -111,7 +111,7 @@ handoff to a provider other than the response's own, and a handoff that still of
111
111
  `{ provider, acceptances: [{ documentId, version, contentDigest, acceptedAt }] }`, each document at
112
112
  most once; `FiatTermsResponse` is `{ recorded }`, the recorded document ids. A fault is a
113
113
  `FiatTermsErrorBody`: the shared `errorCode`, `errorMsg` and `reqId`, plus `reason` (`STALE_TERMS`,
114
- `IN_PROGRESS`, `INVALID_REQUEST`, `RATE_LIMITED`, `PROVIDER_UNAVAILABLE`) and `recovery`.
114
+ `INVALID_REQUEST`, `RATE_LIMITED`, `PROVIDER_UNAVAILABLE`) and `recovery`.
115
115
 
116
116
  The package publishes every document as a constant, so the client and the backend read the same
117
117
  text. `PROVIDER_CHECKOUT_DOCUMENTS` maps each provider to its current `CHECKOUT` documents.
@@ -126,8 +126,8 @@ three kinds:
126
126
  | `kind` | Carries | A repeat |
127
127
  | --- | --- | --- |
128
128
  | `observe` | `checkout`, and `credentials` (`customerId`, `accessToken`) once the SDK has them | writes nothing new |
129
- | `kyc` | `checkout`, `credentials`, `values` keyed by `KycFieldId` (no form id) | drops values MoonPay no longer asks for; a concurrent one gets `409 IN_PROGRESS` |
130
- | `order` | `orderId`, `transactionId` | returns the claimed order |
129
+ | `kyc` | `checkout`, `credentials`, `values` keyed by `KycFieldId` (no form id) | drops values MoonPay no longer asks for |
130
+ | `order` | `orderId`, `transactionId?`, `quotedAmount` | returns the recorded order |
131
131
 
132
132
  `observe` and `kyc` answer a `MoonPayStepResponse`, which says what the backend needs next:
133
133
 
@@ -140,7 +140,11 @@ three kinds:
140
140
  | `READY` | `orderId`, `quoteInput` | mounts Apple Pay, then sends `order` after the charge |
141
141
  | `REFUSED` | `reason` (`NOT_ELIGIBLE`, `DOCUMENTS_REQUIRED`, `FINAL_REJECTION`, `CUSTOMER_MISMATCH`), `recovery: REQUOTE \| NONE` | exits the provider flow |
142
142
 
143
- `order` runs after the charge and answers a `MoonPayOrderResponse`:
143
+ `order` runs after every charge attempt, a failed one too, and answers a `MoonPayOrderResponse`.
144
+ `transactionId` is optional because a failed charge may have none; without it the backend records the
145
+ failed charges MoonPay lists for `orderId`. `quotedAmount` is the fiat amount the quote showed. A
146
+ failed charge answers `DONE` with the order in `FAILED`, and the client requotes for a new `orderId`.
147
+ After a failed charge with no `transactionId`, the client caps its `PENDING` polls.
144
148
 
145
149
  | `status` | Carries | The client then |
146
150
  | --- | --- | --- |
@@ -151,8 +155,8 @@ three kinds:
151
155
  `MoonPayIntentResponseFor` maps each `kind` to its union, and `MoonPayIntentResponse` is both.
152
156
 
153
157
  A fault is a 4xx or 5xx with a `MoonPayErrorBody`: the shared `errorCode`, `errorMsg` and `reqId`,
154
- plus `reason` (`SESSION_BUDGET_SPENT`, `RATE_LIMITED`, `PROVIDER_UNAVAILABLE`, `IN_PROGRESS`,
155
- `INVALID_REQUEST`) and `recovery`:
158
+ plus `reason` (`SESSION_BUDGET_SPENT`, `RATE_LIMITED`, `PROVIDER_UNAVAILABLE`, `INVALID_REQUEST`)
159
+ and `recovery`:
156
160
  `RETRY` (send the same request again), `REQUOTE`, or `NONE`. A field error is a `KYC`
157
161
  response, not a fault. The zod schemas (`MoonPay*Schema`, `TermsDocumentSchema`, `FiatTerms*Schema`)
158
162
  are exported from the root only.
@@ -41,4 +41,4 @@ export {
41
41
  FUN_KYC_CONSENT_DOCUMENTS,
42
42
  PUBLISHED_TERMS_DOCUMENTS
43
43
  };
44
- //# sourceMappingURL=chunk-N6GHUS2K.mjs.map
44
+ //# sourceMappingURL=chunk-5GRPYE2U.mjs.map
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.21.0";
2
+ var version = "0.22.0";
3
3
 
4
4
  // src/table.ts
5
5
  var TABLE_VERSION = version;
@@ -514,4 +514,4 @@ export {
514
514
  tableEntry,
515
515
  isTerminal
516
516
  };
517
- //# sourceMappingURL=chunk-LBYBZDOW.mjs.map
517
+ //# sourceMappingURL=chunk-7OUDI3JX.mjs.map
@@ -6,4 +6,4 @@ var MOONPAY_ENDPOINTS = {
6
6
  export {
7
7
  MOONPAY_ENDPOINTS
8
8
  };
9
- //# sourceMappingURL=chunk-YOMQWXTD.mjs.map
9
+ //# sourceMappingURL=chunk-SJ7V3YOM.mjs.map
package/dist/index.js CHANGED
@@ -1004,7 +1004,7 @@ var $termsErrorBody = obj({
1004
1004
  errorCode: $nonBlank,
1005
1005
  errorMsg: import_zod.z.string(),
1006
1006
  reqId: import_zod.z.string().optional(),
1007
- reason: import_zod.z.enum(["STALE_TERMS", "IN_PROGRESS", "INVALID_REQUEST", "RATE_LIMITED", "PROVIDER_UNAVAILABLE"]),
1007
+ reason: import_zod.z.enum(["STALE_TERMS", "INVALID_REQUEST", "RATE_LIMITED", "PROVIDER_UNAVAILABLE"]),
1008
1008
  recovery: import_zod.z.enum(["RETRY", "REQUOTE", "NONE"])
1009
1009
  });
1010
1010
  var FiatTermsErrorBodySchema = $termsErrorBody;
@@ -1067,7 +1067,7 @@ var $stepResponse = import_zod.z.union([$providerBoundStepResponse, $blockedStep
1067
1067
  var FiatStepResponseSchema = $stepResponse;
1068
1068
 
1069
1069
  // package.json
1070
- var version = "0.21.0";
1070
+ var version = "0.22.0";
1071
1071
 
1072
1072
  // src/table.ts
1073
1073
  var TABLE_VERSION = version;
@@ -2698,7 +2698,7 @@ var $intentRequest = import_zod2.z.discriminatedUnion("kind", [
2698
2698
  credentials: $credentials,
2699
2699
  values: import_zod2.z.record(KycFieldIdSchema, import_zod2.z.string()).refine((values) => Object.keys(values).length > 0, "values must not be empty")
2700
2700
  }),
2701
- obj2({ kind: import_zod2.z.literal("order"), orderId: $nonEmpty, transactionId: $nonEmpty })
2701
+ obj2({ kind: import_zod2.z.literal("order"), orderId: $nonEmpty, transactionId: $nonEmpty.optional(), quotedAmount: FiatAmountSchema })
2702
2702
  ]);
2703
2703
  var MoonPayIntentRequestSchema = $intentRequest;
2704
2704
  var $quoteInput = obj2({
@@ -2750,13 +2750,7 @@ var MoonPayOrderResponseSchema = $orderResponse;
2750
2750
  var $intentResponse = import_zod2.z.union([$stepResponse2, $orderResponse]);
2751
2751
  var MoonPayIntentResponseSchema = $intentResponse;
2752
2752
  var $faultFields = {
2753
- reason: import_zod2.z.enum([
2754
- "SESSION_BUDGET_SPENT",
2755
- "RATE_LIMITED",
2756
- "PROVIDER_UNAVAILABLE",
2757
- "IN_PROGRESS",
2758
- "INVALID_REQUEST"
2759
- ]),
2753
+ reason: import_zod2.z.enum(["SESSION_BUDGET_SPENT", "RATE_LIMITED", "PROVIDER_UNAVAILABLE", "INVALID_REQUEST"]),
2760
2754
  recovery: import_zod2.z.enum(["RETRY", "REQUOTE", "NONE"])
2761
2755
  };
2762
2756
  var $fault = obj2($faultFields);
package/dist/index.mjs CHANGED
@@ -12,16 +12,16 @@ import {
12
12
  tableEntry,
13
13
  unofferedEndpoints,
14
14
  unreachableStates
15
- } from "./chunk-LBYBZDOW.mjs";
15
+ } from "./chunk-7OUDI3JX.mjs";
16
16
  import {
17
17
  MOONPAY_ENDPOINTS
18
- } from "./chunk-YOMQWXTD.mjs";
18
+ } from "./chunk-SJ7V3YOM.mjs";
19
19
  import {
20
20
  FIAT_TERMS_ENDPOINT,
21
21
  FUN_KYC_CONSENT_DOCUMENTS,
22
22
  PROVIDER_CHECKOUT_DOCUMENTS,
23
23
  PUBLISHED_TERMS_DOCUMENTS
24
- } from "./chunk-N6GHUS2K.mjs";
24
+ } from "./chunk-5GRPYE2U.mjs";
25
25
 
26
26
  // src/codes.ts
27
27
  var US_STATE_CODES = [
@@ -888,7 +888,7 @@ var $termsErrorBody = obj({
888
888
  errorCode: $nonBlank,
889
889
  errorMsg: z.string(),
890
890
  reqId: z.string().optional(),
891
- reason: z.enum(["STALE_TERMS", "IN_PROGRESS", "INVALID_REQUEST", "RATE_LIMITED", "PROVIDER_UNAVAILABLE"]),
891
+ reason: z.enum(["STALE_TERMS", "INVALID_REQUEST", "RATE_LIMITED", "PROVIDER_UNAVAILABLE"]),
892
892
  recovery: z.enum(["RETRY", "REQUOTE", "NONE"])
893
893
  });
894
894
  var FiatTermsErrorBodySchema = $termsErrorBody;
@@ -2038,7 +2038,7 @@ var $intentRequest = z2.discriminatedUnion("kind", [
2038
2038
  credentials: $credentials,
2039
2039
  values: z2.record(KycFieldIdSchema, z2.string()).refine((values) => Object.keys(values).length > 0, "values must not be empty")
2040
2040
  }),
2041
- obj2({ kind: z2.literal("order"), orderId: $nonEmpty, transactionId: $nonEmpty })
2041
+ obj2({ kind: z2.literal("order"), orderId: $nonEmpty, transactionId: $nonEmpty.optional(), quotedAmount: FiatAmountSchema })
2042
2042
  ]);
2043
2043
  var MoonPayIntentRequestSchema = $intentRequest;
2044
2044
  var $quoteInput = obj2({
@@ -2090,13 +2090,7 @@ var MoonPayOrderResponseSchema = $orderResponse;
2090
2090
  var $intentResponse = z2.union([$stepResponse2, $orderResponse]);
2091
2091
  var MoonPayIntentResponseSchema = $intentResponse;
2092
2092
  var $faultFields = {
2093
- reason: z2.enum([
2094
- "SESSION_BUDGET_SPENT",
2095
- "RATE_LIMITED",
2096
- "PROVIDER_UNAVAILABLE",
2097
- "IN_PROGRESS",
2098
- "INVALID_REQUEST"
2099
- ]),
2093
+ reason: z2.enum(["SESSION_BUDGET_SPENT", "RATE_LIMITED", "PROVIDER_UNAVAILABLE", "INVALID_REQUEST"]),
2100
2094
  recovery: z2.enum(["RETRY", "REQUOTE", "NONE"])
2101
2095
  };
2102
2096
  var $fault = obj2($faultFields);
@@ -57,11 +57,16 @@ export type MoonPayIntentRequest =
57
57
  credentials: MoonPaySdkCredentials;
58
58
  values: Partial<Record<KycFieldId, string>>;
59
59
  }
60
- /** After the Apple Pay sheet. `transactionId` is from the Apple Pay completion event. */
60
+ /**
61
+ * After every charge attempt, a failed one too. `transactionId` is from the Apple Pay event when it
62
+ * has one; without it the backend records the failed charges MoonPay lists for `orderId`.
63
+ * `quotedAmount` is the fiat amount the buyer saw on the quote.
64
+ */
61
65
  | {
62
66
  kind: 'order';
63
67
  orderId: string;
64
- transactionId: string;
68
+ transactionId?: string;
69
+ quotedAmount: FiatAmount;
65
70
  };
66
71
  export type MoonPayIntentKind = MoonPayIntentRequest['kind'];
67
72
  /**
@@ -138,14 +143,20 @@ export type MoonPayStepResponse =
138
143
  reason: MoonPayStepRefusal;
139
144
  recovery: 'REQUOTE' | 'NONE';
140
145
  };
141
- /** The answer to `order`, which runs after the charge. */
146
+ /**
147
+ * The answer to `order`, which runs after each charge attempt. A failed charge is recorded too: it
148
+ * answers `DONE` with the order in `FAILED`, and the client requotes for a new `orderId`.
149
+ */
142
150
  export type MoonPayOrderResponse =
143
151
  /** The `GET /fiat/orders/:orderId` response; the shared order screen renders it. */
144
152
  {
145
153
  status: 'DONE';
146
154
  order: FiatStepResponse;
147
155
  }
148
- /** MoonPay does not show the transaction yet. Send the same `order` after the delay. */
156
+ /**
157
+ * MoonPay does not list the transaction yet. Send the same `order` after the delay. After a failed
158
+ * charge with no `transactionId`, the client caps these polls.
159
+ */
149
160
  | {
150
161
  status: 'PENDING';
151
162
  retryAfterMs: number;
@@ -167,10 +178,10 @@ export type MoonPayIntentStatus = MoonPayIntentResponse['status'];
167
178
  export type MoonPayRecovery = 'RETRY' | 'REQUOTE' | 'NONE';
168
179
  /**
169
180
  * `SESSION_BUDGET_SPENT`: the per-login SDK session mint budget (429). `RATE_LIMITED`: the kind's
170
- * request budget (429). `PROVIDER_UNAVAILABLE`: MoonPay or Sumsub is down. `IN_PROGRESS`: a `kyc`
171
- * for this buyer is still running (409). `INVALID_REQUEST`: a bad body (400).
181
+ * request budget (429). `PROVIDER_UNAVAILABLE`: MoonPay or Sumsub is down. `INVALID_REQUEST`: a bad
182
+ * body (400).
172
183
  */
173
- export type MoonPayFaultReason = 'SESSION_BUDGET_SPENT' | 'RATE_LIMITED' | 'PROVIDER_UNAVAILABLE' | 'IN_PROGRESS' | 'INVALID_REQUEST';
184
+ export type MoonPayFaultReason = 'SESSION_BUDGET_SPENT' | 'RATE_LIMITED' | 'PROVIDER_UNAVAILABLE' | 'INVALID_REQUEST';
174
185
  /** The fields a MoonPay fault adds to the shared error body. */
175
186
  export interface MoonPayFault {
176
187
  reason: MoonPayFaultReason;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MOONPAY_ENDPOINTS
3
- } from "../chunk-YOMQWXTD.mjs";
3
+ } from "../chunk-SJ7V3YOM.mjs";
4
4
  export {
5
5
  MOONPAY_ENDPOINTS
6
6
  };
package/dist/table.js CHANGED
@@ -36,7 +36,7 @@ __export(table_exports, {
36
36
  module.exports = __toCommonJS(table_exports);
37
37
 
38
38
  // package.json
39
- var version = "0.21.0";
39
+ var version = "0.22.0";
40
40
 
41
41
  // src/table.ts
42
42
  var TABLE_VERSION = version;
package/dist/table.mjs CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  tableEntry,
12
12
  unofferedEndpoints,
13
13
  unreachableStates
14
- } from "./chunk-LBYBZDOW.mjs";
14
+ } from "./chunk-7OUDI3JX.mjs";
15
15
  export {
16
16
  DOCUMENTED_ENDPOINTS,
17
17
  STATE_KEYS,
package/dist/terms.d.ts CHANGED
@@ -45,11 +45,11 @@ export interface FiatTermsResponse {
45
45
  }
46
46
  /**
47
47
  * `STALE_TERMS`: an unpublished version, a wrong digest, or an `acceptedAt` older than 5 minutes
48
- * (400). `IN_PROGRESS`: the same request is still running (409). `INVALID_REQUEST`: a bad body (400).
48
+ * (400). `INVALID_REQUEST`: a bad body (400).
49
49
  * `RATE_LIMITED`: the per-login terms budget is spent (429). `PROVIDER_UNAVAILABLE`: the KYC service
50
50
  * or a store is down (503); nothing is recorded, so retry.
51
51
  */
52
- export type FiatTermsFaultReason = 'STALE_TERMS' | 'IN_PROGRESS' | 'INVALID_REQUEST' | 'RATE_LIMITED' | 'PROVIDER_UNAVAILABLE';
52
+ export type FiatTermsFaultReason = 'STALE_TERMS' | 'INVALID_REQUEST' | 'RATE_LIMITED' | 'PROVIDER_UNAVAILABLE';
53
53
  /** `RETRY` sends the same request again. `REQUOTE` goes back to `POST /fiat/quote`. `NONE` ends the flow. */
54
54
  export type FiatTermsRecovery = 'RETRY' | 'REQUOTE' | 'NONE';
55
55
  /** The 4xx/5xx body of `POST /fiat/terms`: the shared error body plus `reason` and `recovery`. */
package/dist/terms.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  FUN_KYC_CONSENT_DOCUMENTS,
4
4
  PROVIDER_CHECKOUT_DOCUMENTS,
5
5
  PUBLISHED_TERMS_DOCUMENTS
6
- } from "./chunk-N6GHUS2K.mjs";
6
+ } from "./chunk-5GRPYE2U.mjs";
7
7
  export {
8
8
  FIAT_TERMS_ENDPOINT,
9
9
  FUN_KYC_CONSENT_DOCUMENTS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fun-xyz/fiat-contract",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "Published conformance contract for Fun's headless fiat onramp: FlowState/Transition types, zod schemas, the transition table as data, recorded fixtures, assertion helpers.",
5
5
  "license": "MIT",
6
6
  "repository": {