@fun-xyz/fiat-contract 0.20.0 → 0.20.2

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
@@ -112,7 +112,7 @@ offers transitions, and a `terms` entry that is not a unique `CHECKOUT` document
112
112
  `{ provider, acceptances: [{ documentId, version, contentDigest, acceptedAt }] }`, each document at
113
113
  most once; `FiatTermsResponse` is `{ recorded }`, the recorded document ids. A fault is a
114
114
  `FiatTermsErrorBody`: the shared `errorCode`, `errorMsg` and `reqId`, plus `reason` (`STALE_TERMS`,
115
- `IN_PROGRESS`, `IDEMPOTENCY_KEY_REUSED`, `INVALID_REQUEST`, `RATE_LIMITED`) and `recovery`.
115
+ `IN_PROGRESS`, `IDEMPOTENCY_KEY_REUSED`, `INVALID_REQUEST`, `RATE_LIMITED`, `PROVIDER_UNAVAILABLE`) and `recovery`.
116
116
 
117
117
  **MoonPay (`./moonpay`).** One route, `MOONPAY_ENDPOINTS.intent`. A `MoonPayIntentRequest` is one of
118
118
  three kinds:
@@ -120,24 +120,33 @@ three kinds:
120
120
  | `kind` | Carries | `Idempotency-Key` |
121
121
  | --- | --- | --- |
122
122
  | `observe` | `checkout`, and `credentials` (`customerId`, `accessToken`) once the SDK has them | ignored |
123
- | `kyc` | `checkout`, `credentials`, `values` keyed by field id (no form id) | required |
123
+ | `kyc` | `checkout`, `credentials`, `values` keyed by `KycFieldId` (no form id) | required |
124
124
  | `order` | `orderId`, `transactionId` | required |
125
125
 
126
- A `MoonPayIntentResponse` says what the backend needs next:
126
+ `observe` and `kyc` answer a `MoonPayStepResponse`, which says what the backend needs next:
127
127
 
128
128
  | `status` | Carries | The client then |
129
129
  | --- | --- | --- |
130
130
  | `TERMS` | `stage`, `documents` (at least one, all at `stage`) | sends `POST /fiat/terms`, then `observe` |
131
131
  | `SDK_AUTH` | `sessionToken`, `quoteInput` | runs the MoonPay connection check, then `observe` with credentials |
132
132
  | `KYC` | `fields`, `fieldErrors?` (each naming a field in `fields`) | shows the shared form, then sends `kyc` |
133
- | `PENDING` | `retryAfterMs` (at most 60 s) | sends the same request again after the delay |
133
+ | `PENDING` | `retryAfterMs` (at most 60 s) | sends `observe` after the delay, never `kyc` again |
134
134
  | `READY` | `orderId`, `quoteInput` | mounts Apple Pay, then sends `order` after the charge |
135
- | `DONE` | `order`, the `GET /fiat/orders/:orderId` response | shows the shared order status |
136
135
  | `REFUSED` | `reason` (`NOT_ELIGIBLE`, `DOCUMENTS_REQUIRED`, `FINAL_REJECTION`, `CUSTOMER_MISMATCH`), `recovery: REQUOTE \| NONE` | exits the provider flow |
137
136
 
137
+ `order` runs after the charge and answers a `MoonPayOrderResponse`:
138
+
139
+ | `status` | Carries | The client then |
140
+ | --- | --- | --- |
141
+ | `DONE` | `order`, the `GET /fiat/orders/:orderId` response | shows the shared order status |
142
+ | `PENDING` | `retryAfterMs` (at most 60 s) | sends the same `order`, with the same key, after the delay |
143
+ | `REFUSED` | `reason` (`CUSTOMER_MISMATCH`, `WALLET_MISMATCH`, `UNRECORDABLE`), `recovery: NONE` | exits the provider flow |
144
+
145
+ `MoonPayIntentResponseFor` maps each `kind` to its union, and `MoonPayIntentResponse` is both.
146
+
138
147
  A fault is a 4xx or 5xx with a `MoonPayErrorBody`: the shared `errorCode`, `errorMsg` and `reqId`,
139
148
  plus `reason` (`SESSION_BUDGET_SPENT`, `RATE_LIMITED`, `PROVIDER_UNAVAILABLE`, `IN_PROGRESS`,
140
- `IDEMPOTENCY_KEY_REUSED`, `INVALID_REQUEST`, `TRANSACTION_MISMATCH`, `WALLET_MISMATCH`) and `recovery`:
149
+ `IDEMPOTENCY_KEY_REUSED`, `INVALID_REQUEST`) and `recovery`:
141
150
  `RETRY` (send the same request, with the same key), `REQUOTE`, or `NONE`. A field error is a `KYC`
142
151
  response, not a fault. The zod schemas (`MoonPay*Schema`, `TermsDocumentSchema`, `FiatTerms*Schema`)
143
152
  are exported from the root only.
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.20.0";
2
+ var version = "0.20.2";
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-TV6IWKTB.mjs.map
517
+ //# sourceMappingURL=chunk-CYT2NARF.mjs.map
@@ -4,4 +4,4 @@ var FIAT_TERMS_ENDPOINT = "POST /fiat/terms";
4
4
  export {
5
5
  FIAT_TERMS_ENDPOINT
6
6
  };
7
- //# sourceMappingURL=chunk-QXJ54JWX.mjs.map
7
+ //# sourceMappingURL=chunk-WRRCWAY2.mjs.map
@@ -6,4 +6,4 @@ var MOONPAY_ENDPOINTS = {
6
6
  export {
7
7
  MOONPAY_ENDPOINTS
8
8
  };
9
- //# sourceMappingURL=chunk-UN3WTIMI.mjs.map
9
+ //# sourceMappingURL=chunk-WW26WEZO.mjs.map
package/dist/index.js CHANGED
@@ -60,6 +60,7 @@ __export(index_exports, {
60
60
  KYCProviderSchema: () => KYCProviderSchema,
61
61
  KYC_ACKNOWLEDGEMENT_FIELD_IDS: () => KYC_ACKNOWLEDGEMENT_FIELD_IDS,
62
62
  KycCaptureStateSchema: () => KycCaptureStateSchema,
63
+ KycFieldIdSchema: () => KycFieldIdSchema,
63
64
  KycInputRequiredStateSchema: () => KycInputRequiredStateSchema,
64
65
  KycNoActionRequiredStateSchema: () => KycNoActionRequiredStateSchema,
65
66
  KycSdkResultReportSchema: () => KycSdkResultReportSchema,
@@ -69,8 +70,10 @@ __export(index_exports, {
69
70
  MoonPayFaultSchema: () => MoonPayFaultSchema,
70
71
  MoonPayIntentRequestSchema: () => MoonPayIntentRequestSchema,
71
72
  MoonPayIntentResponseSchema: () => MoonPayIntentResponseSchema,
73
+ MoonPayOrderResponseSchema: () => MoonPayOrderResponseSchema,
72
74
  MoonPayQuoteInputSchema: () => MoonPayQuoteInputSchema,
73
75
  MoonPaySdkCredentialsSchema: () => MoonPaySdkCredentialsSchema,
76
+ MoonPayStepResponseSchema: () => MoonPayStepResponseSchema,
74
77
  OrderAwaitingConfirmationStateSchema: () => OrderAwaitingConfirmationStateSchema,
75
78
  OrderCreatedStateSchema: () => OrderCreatedStateSchema,
76
79
  OrderRefSchema: () => OrderRefSchema,
@@ -658,6 +661,7 @@ var $kycFieldId = import_zod.z.union([
658
661
  import_zod.z.enum(KYC_ACKNOWLEDGEMENT_FIELD_IDS),
659
662
  $questionnaireKycFieldId
660
663
  ]);
664
+ var KycFieldIdSchema = $kycFieldId;
661
665
  var $clientExecutedDelivery = obj({
662
666
  channel: import_zod.z.literal("CLIENT_EXECUTED"),
663
667
  source: import_zod.z.literal("CURRENT_SESSION_INPUTS"),
@@ -1001,7 +1005,7 @@ var $termsErrorBody = obj({
1001
1005
  errorCode: $nonBlank,
1002
1006
  errorMsg: import_zod.z.string(),
1003
1007
  reqId: import_zod.z.string().optional(),
1004
- reason: import_zod.z.enum(["STALE_TERMS", "IN_PROGRESS", "IDEMPOTENCY_KEY_REUSED", "INVALID_REQUEST", "RATE_LIMITED"]),
1008
+ reason: import_zod.z.enum(["STALE_TERMS", "IN_PROGRESS", "IDEMPOTENCY_KEY_REUSED", "INVALID_REQUEST", "RATE_LIMITED", "PROVIDER_UNAVAILABLE"]),
1005
1009
  recovery: import_zod.z.enum(["RETRY", "REQUOTE", "NONE"])
1006
1010
  });
1007
1011
  var FiatTermsErrorBodySchema = $termsErrorBody;
@@ -1064,7 +1068,7 @@ var $stepResponse = import_zod.z.union([$providerBoundStepResponse, $blockedStep
1064
1068
  var FiatStepResponseSchema = $stepResponse;
1065
1069
 
1066
1070
  // package.json
1067
- var version = "0.20.0";
1071
+ var version = "0.20.2";
1068
1072
 
1069
1073
  // src/table.ts
1070
1074
  var TABLE_VERSION = version;
@@ -2659,7 +2663,7 @@ var $intentRequest = import_zod2.z.discriminatedUnion("kind", [
2659
2663
  kind: import_zod2.z.literal("kyc"),
2660
2664
  checkout: $checkout,
2661
2665
  credentials: $credentials,
2662
- values: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.string()).refine((values) => Object.keys(values).length > 0, "values must not be empty")
2666
+ values: import_zod2.z.record(KycFieldIdSchema, import_zod2.z.string()).refine((values) => Object.keys(values).length > 0, "values must not be empty")
2663
2667
  }),
2664
2668
  obj2({ kind: import_zod2.z.literal("order"), orderId: $nonEmpty, transactionId: $nonEmpty })
2665
2669
  ]);
@@ -2672,18 +2676,19 @@ var $quoteInput = obj2({
2672
2676
  feeBehavior: import_zod2.z.literal("inclusive")
2673
2677
  });
2674
2678
  var MoonPayQuoteInputSchema = $quoteInput;
2675
- var $refusal = import_zod2.z.enum(["NOT_ELIGIBLE", "DOCUMENTS_REQUIRED", "FINAL_REJECTION", "CUSTOMER_MISMATCH"]);
2679
+ var $stepRefusal = import_zod2.z.enum(["NOT_ELIGIBLE", "DOCUMENTS_REQUIRED", "FINAL_REJECTION", "CUSTOMER_MISMATCH"]);
2680
+ var $orderRefusal = import_zod2.z.enum(["CUSTOMER_MISMATCH", "WALLET_MISMATCH", "UNRECORDABLE"]);
2676
2681
  var $fieldError = obj2({ fieldId: $nonEmpty, message: $nonEmpty });
2677
- var $intentStatus = import_zod2.z.discriminatedUnion("status", [
2682
+ var $pending = obj2({ status: import_zod2.z.literal("PENDING"), retryAfterMs: import_zod2.z.number().int().positive().max(6e4) });
2683
+ var $stepStatus = import_zod2.z.discriminatedUnion("status", [
2678
2684
  obj2({ status: import_zod2.z.literal("TERMS"), stage: import_zod2.z.enum(["CHECKOUT", "KYC"]), documents: import_zod2.z.array(TermsDocumentSchema).min(1) }),
2679
2685
  obj2({ status: import_zod2.z.literal("SDK_AUTH"), sessionToken: $nonEmpty, quoteInput: $quoteInput }),
2680
2686
  obj2({ status: import_zod2.z.literal("KYC"), fields: import_zod2.z.array(FormFieldSchema).min(1), fieldErrors: import_zod2.z.array($fieldError).min(1).optional() }),
2681
- obj2({ status: import_zod2.z.literal("PENDING"), retryAfterMs: import_zod2.z.number().int().positive().max(6e4) }),
2687
+ $pending,
2682
2688
  obj2({ status: import_zod2.z.literal("READY"), orderId: $nonEmpty, quoteInput: $quoteInput }),
2683
- obj2({ status: import_zod2.z.literal("DONE"), order: FiatStepResponseSchema }),
2684
- obj2({ status: import_zod2.z.literal("REFUSED"), reason: $refusal, recovery: import_zod2.z.enum(["REQUOTE", "NONE"]) })
2689
+ obj2({ status: import_zod2.z.literal("REFUSED"), reason: $stepRefusal, recovery: import_zod2.z.enum(["REQUOTE", "NONE"]) })
2685
2690
  ]);
2686
- var $intentResponse = $intentStatus.superRefine((response, context) => {
2691
+ var $stepResponse2 = $stepStatus.superRefine((response, context) => {
2687
2692
  if (response.status === "TERMS") {
2688
2693
  if (!hasUniqueIds2(response.documents.map((document) => document.id))) {
2689
2694
  context.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
@@ -2702,6 +2707,14 @@ var $intentResponse = $intentStatus.superRefine((response, context) => {
2702
2707
  }
2703
2708
  }
2704
2709
  });
2710
+ var MoonPayStepResponseSchema = $stepResponse2;
2711
+ var $orderResponse = import_zod2.z.discriminatedUnion("status", [
2712
+ obj2({ status: import_zod2.z.literal("DONE"), order: FiatStepResponseSchema }),
2713
+ $pending,
2714
+ obj2({ status: import_zod2.z.literal("REFUSED"), reason: $orderRefusal, recovery: import_zod2.z.literal("NONE") })
2715
+ ]);
2716
+ var MoonPayOrderResponseSchema = $orderResponse;
2717
+ var $intentResponse = import_zod2.z.union([$stepResponse2, $orderResponse]);
2705
2718
  var MoonPayIntentResponseSchema = $intentResponse;
2706
2719
  var $faultFields = {
2707
2720
  reason: import_zod2.z.enum([
@@ -2710,9 +2723,7 @@ var $faultFields = {
2710
2723
  "PROVIDER_UNAVAILABLE",
2711
2724
  "IN_PROGRESS",
2712
2725
  "IDEMPOTENCY_KEY_REUSED",
2713
- "INVALID_REQUEST",
2714
- "TRANSACTION_MISMATCH",
2715
- "WALLET_MISMATCH"
2726
+ "INVALID_REQUEST"
2716
2727
  ]),
2717
2728
  recovery: import_zod2.z.enum(["RETRY", "REQUOTE", "NONE"])
2718
2729
  };
package/dist/index.mjs CHANGED
@@ -12,13 +12,13 @@ import {
12
12
  tableEntry,
13
13
  unofferedEndpoints,
14
14
  unreachableStates
15
- } from "./chunk-TV6IWKTB.mjs";
15
+ } from "./chunk-CYT2NARF.mjs";
16
16
  import {
17
17
  MOONPAY_ENDPOINTS
18
- } from "./chunk-UN3WTIMI.mjs";
18
+ } from "./chunk-WW26WEZO.mjs";
19
19
  import {
20
20
  FIAT_TERMS_ENDPOINT
21
- } from "./chunk-QXJ54JWX.mjs";
21
+ } from "./chunk-WRRCWAY2.mjs";
22
22
 
23
23
  // src/codes.ts
24
24
  var US_STATE_CODES = [
@@ -545,6 +545,7 @@ var $kycFieldId = z.union([
545
545
  z.enum(KYC_ACKNOWLEDGEMENT_FIELD_IDS),
546
546
  $questionnaireKycFieldId
547
547
  ]);
548
+ var KycFieldIdSchema = $kycFieldId;
548
549
  var $clientExecutedDelivery = obj({
549
550
  channel: z.literal("CLIENT_EXECUTED"),
550
551
  source: z.literal("CURRENT_SESSION_INPUTS"),
@@ -888,7 +889,7 @@ var $termsErrorBody = obj({
888
889
  errorCode: $nonBlank,
889
890
  errorMsg: z.string(),
890
891
  reqId: z.string().optional(),
891
- reason: z.enum(["STALE_TERMS", "IN_PROGRESS", "IDEMPOTENCY_KEY_REUSED", "INVALID_REQUEST", "RATE_LIMITED"]),
892
+ reason: z.enum(["STALE_TERMS", "IN_PROGRESS", "IDEMPOTENCY_KEY_REUSED", "INVALID_REQUEST", "RATE_LIMITED", "PROVIDER_UNAVAILABLE"]),
892
893
  recovery: z.enum(["RETRY", "REQUOTE", "NONE"])
893
894
  });
894
895
  var FiatTermsErrorBodySchema = $termsErrorBody;
@@ -2036,7 +2037,7 @@ var $intentRequest = z2.discriminatedUnion("kind", [
2036
2037
  kind: z2.literal("kyc"),
2037
2038
  checkout: $checkout,
2038
2039
  credentials: $credentials,
2039
- values: z2.record(z2.string(), z2.string()).refine((values) => Object.keys(values).length > 0, "values must not be empty")
2040
+ values: z2.record(KycFieldIdSchema, z2.string()).refine((values) => Object.keys(values).length > 0, "values must not be empty")
2040
2041
  }),
2041
2042
  obj2({ kind: z2.literal("order"), orderId: $nonEmpty, transactionId: $nonEmpty })
2042
2043
  ]);
@@ -2049,18 +2050,19 @@ var $quoteInput = obj2({
2049
2050
  feeBehavior: z2.literal("inclusive")
2050
2051
  });
2051
2052
  var MoonPayQuoteInputSchema = $quoteInput;
2052
- var $refusal = z2.enum(["NOT_ELIGIBLE", "DOCUMENTS_REQUIRED", "FINAL_REJECTION", "CUSTOMER_MISMATCH"]);
2053
+ var $stepRefusal = z2.enum(["NOT_ELIGIBLE", "DOCUMENTS_REQUIRED", "FINAL_REJECTION", "CUSTOMER_MISMATCH"]);
2054
+ var $orderRefusal = z2.enum(["CUSTOMER_MISMATCH", "WALLET_MISMATCH", "UNRECORDABLE"]);
2053
2055
  var $fieldError = obj2({ fieldId: $nonEmpty, message: $nonEmpty });
2054
- var $intentStatus = z2.discriminatedUnion("status", [
2056
+ var $pending = obj2({ status: z2.literal("PENDING"), retryAfterMs: z2.number().int().positive().max(6e4) });
2057
+ var $stepStatus = z2.discriminatedUnion("status", [
2055
2058
  obj2({ status: z2.literal("TERMS"), stage: z2.enum(["CHECKOUT", "KYC"]), documents: z2.array(TermsDocumentSchema).min(1) }),
2056
2059
  obj2({ status: z2.literal("SDK_AUTH"), sessionToken: $nonEmpty, quoteInput: $quoteInput }),
2057
2060
  obj2({ status: z2.literal("KYC"), fields: z2.array(FormFieldSchema).min(1), fieldErrors: z2.array($fieldError).min(1).optional() }),
2058
- obj2({ status: z2.literal("PENDING"), retryAfterMs: z2.number().int().positive().max(6e4) }),
2061
+ $pending,
2059
2062
  obj2({ status: z2.literal("READY"), orderId: $nonEmpty, quoteInput: $quoteInput }),
2060
- obj2({ status: z2.literal("DONE"), order: FiatStepResponseSchema }),
2061
- obj2({ status: z2.literal("REFUSED"), reason: $refusal, recovery: z2.enum(["REQUOTE", "NONE"]) })
2063
+ obj2({ status: z2.literal("REFUSED"), reason: $stepRefusal, recovery: z2.enum(["REQUOTE", "NONE"]) })
2062
2064
  ]);
2063
- var $intentResponse = $intentStatus.superRefine((response, context) => {
2065
+ var $stepResponse2 = $stepStatus.superRefine((response, context) => {
2064
2066
  if (response.status === "TERMS") {
2065
2067
  if (!hasUniqueIds2(response.documents.map((document) => document.id))) {
2066
2068
  context.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
@@ -2079,6 +2081,14 @@ var $intentResponse = $intentStatus.superRefine((response, context) => {
2079
2081
  }
2080
2082
  }
2081
2083
  });
2084
+ var MoonPayStepResponseSchema = $stepResponse2;
2085
+ var $orderResponse = z2.discriminatedUnion("status", [
2086
+ obj2({ status: z2.literal("DONE"), order: FiatStepResponseSchema }),
2087
+ $pending,
2088
+ obj2({ status: z2.literal("REFUSED"), reason: $orderRefusal, recovery: z2.literal("NONE") })
2089
+ ]);
2090
+ var MoonPayOrderResponseSchema = $orderResponse;
2091
+ var $intentResponse = z2.union([$stepResponse2, $orderResponse]);
2082
2092
  var MoonPayIntentResponseSchema = $intentResponse;
2083
2093
  var $faultFields = {
2084
2094
  reason: z2.enum([
@@ -2087,9 +2097,7 @@ var $faultFields = {
2087
2097
  "PROVIDER_UNAVAILABLE",
2088
2098
  "IN_PROGRESS",
2089
2099
  "IDEMPOTENCY_KEY_REUSED",
2090
- "INVALID_REQUEST",
2091
- "TRANSACTION_MISMATCH",
2092
- "WALLET_MISMATCH"
2100
+ "INVALID_REQUEST"
2093
2101
  ]),
2094
2102
  recovery: z2.enum(["RETRY", "REQUOTE", "NONE"])
2095
2103
  };
@@ -2138,6 +2146,7 @@ export {
2138
2146
  KYCProviderSchema,
2139
2147
  KYC_ACKNOWLEDGEMENT_FIELD_IDS,
2140
2148
  KycCaptureStateSchema,
2149
+ KycFieldIdSchema,
2141
2150
  KycInputRequiredStateSchema,
2142
2151
  KycNoActionRequiredStateSchema,
2143
2152
  KycSdkResultReportSchema,
@@ -2147,8 +2156,10 @@ export {
2147
2156
  MoonPayFaultSchema,
2148
2157
  MoonPayIntentRequestSchema,
2149
2158
  MoonPayIntentResponseSchema,
2159
+ MoonPayOrderResponseSchema,
2150
2160
  MoonPayQuoteInputSchema,
2151
2161
  MoonPaySdkCredentialsSchema,
2162
+ MoonPayStepResponseSchema,
2152
2163
  OrderAwaitingConfirmationStateSchema,
2153
2164
  OrderCreatedStateSchema,
2154
2165
  OrderRefSchema,
@@ -2,7 +2,8 @@
2
2
  * The MoonPay provider-owned flow: one route, `POST /fiat/providers/moonpay/intent`.
3
3
  *
4
4
  * Each request carries evidence or a user action (`kind`), and each response says what the backend
5
- * needs next (`status`). The client repeats until `DONE` or `REFUSED`. Terms and consents go through
5
+ * needs next (`status`). `observe` and `kyc` answer a `MoonPayStepResponse`, and `order` answers a
6
+ * `MoonPayOrderResponse` (`MoonPayIntentResponseFor`). Terms and consents go through
6
7
  * the platform `POST /fiat/terms` (`./terms`). Identity and the deposit wallet always come from the
7
8
  * verified partner assertion, never from a request body.
8
9
  *
@@ -17,7 +18,7 @@
17
18
  */
18
19
  import type { FiatCurrencyCode } from '../codes';
19
20
  import type { TermsDocument, TermsStage } from '../terms';
20
- import type { FiatAmount, FiatStepResponse, FormField } from '../types';
21
+ import type { FiatAmount, FiatStepResponse, FormField, KycFieldId } from '../types';
21
22
  export declare const MOONPAY_ENDPOINTS: {
22
23
  readonly intent: "POST /fiat/providers/moonpay/intent";
23
24
  };
@@ -49,12 +50,12 @@ export type MoonPayIntentRequest =
49
50
  checkout: MoonPayCheckout;
50
51
  credentials?: MoonPaySdkCredentials;
51
52
  }
52
- /** Only after a `KYC` response. `values` is keyed by field id; there is no form id. */
53
+ /** Only after a `KYC` response. `values` is keyed by the ids of that response's fields; there is no form id. */
53
54
  | {
54
55
  kind: 'kyc';
55
56
  checkout: MoonPayCheckout;
56
57
  credentials: MoonPaySdkCredentials;
57
- values: Record<string, string>;
58
+ values: Partial<Record<KycFieldId, string>>;
58
59
  }
59
60
  /** After the Apple Pay sheet. `transactionId` is from the Apple Pay completion event. */
60
61
  | {
@@ -87,13 +88,21 @@ export interface MoonPayQuoteInput {
87
88
  };
88
89
  feeBehavior: 'inclusive';
89
90
  }
90
- export type MoonPayRefusal = 'NOT_ELIGIBLE' | 'DOCUMENTS_REQUIRED' | 'FINAL_REJECTION' | 'CUSTOMER_MISMATCH';
91
+ /** `REQUOTE` for `NOT_ELIGIBLE` and `DOCUMENTS_REQUIRED`, `NONE` for the others. */
92
+ export type MoonPayStepRefusal = 'NOT_ELIGIBLE' | 'DOCUMENTS_REQUIRED' | 'FINAL_REJECTION' | 'CUSTOMER_MISMATCH';
93
+ /**
94
+ * After a charge, always with `recovery: NONE`. `CUSTOMER_MISMATCH`: the transaction's customer is
95
+ * not bound to this buyer. `WALLET_MISMATCH`: the transaction pays another wallet than the
96
+ * assertion's. `UNRECORDABLE`: a charge no retry can record, held for refund review.
97
+ */
98
+ export type MoonPayOrderRefusal = 'CUSTOMER_MISMATCH' | 'WALLET_MISMATCH' | 'UNRECORDABLE';
91
99
  /** A reason on one field of a `KYC` response. `fieldId` names a field in that response. */
92
100
  export interface MoonPayFieldError {
93
101
  fieldId: string;
94
102
  message: string;
95
103
  }
96
- export type MoonPayIntentResponse =
104
+ /** The answer to `observe` and `kyc`. */
105
+ export type MoonPayStepResponse =
97
106
  /** Show `documents` (every one at `stage`), send `POST /fiat/terms`, then `observe`. */
98
107
  {
99
108
  status: 'TERMS';
@@ -112,7 +121,7 @@ export type MoonPayIntentResponse =
112
121
  fields: FormField[];
113
122
  fieldErrors?: MoonPayFieldError[];
114
123
  }
115
- /** Send the same request again after the delay. */
124
+ /** Send `observe` after the delay. Never `kyc` again: its write is done. */
116
125
  | {
117
126
  status: 'PENDING';
118
127
  retryAfterMs: number;
@@ -123,29 +132,46 @@ export type MoonPayIntentResponse =
123
132
  orderId: string;
124
133
  quoteInput: MoonPayQuoteInput;
125
134
  }
126
- /** The `GET /fiat/orders/:orderId` response; the shared order screen renders it. */
135
+ /** Exit the provider flow. `REQUOTE` goes back to `POST /fiat/quote`; `NONE` ends the flow. */
127
136
  | {
137
+ status: 'REFUSED';
138
+ reason: MoonPayStepRefusal;
139
+ recovery: 'REQUOTE' | 'NONE';
140
+ };
141
+ /** The answer to `order`, which runs after the charge. */
142
+ export type MoonPayOrderResponse =
143
+ /** The `GET /fiat/orders/:orderId` response; the shared order screen renders it. */
144
+ {
128
145
  status: 'DONE';
129
146
  order: FiatStepResponse;
130
147
  }
131
- /** Exit the provider flow. `REQUOTE` goes back to `POST /fiat/quote`; `NONE` ends the flow. */
148
+ /** MoonPay does not show the transaction yet. Send the same `order`, with the same key, after the delay. */
149
+ | {
150
+ status: 'PENDING';
151
+ retryAfterMs: number;
152
+ }
153
+ /** Exit the provider flow. A requote after a charge would start a second payment. */
132
154
  | {
133
155
  status: 'REFUSED';
134
- reason: MoonPayRefusal;
135
- recovery: 'REQUOTE' | 'NONE';
156
+ reason: MoonPayOrderRefusal;
157
+ recovery: 'NONE';
158
+ };
159
+ export type MoonPayIntentResponseFor = {
160
+ observe: MoonPayStepResponse;
161
+ kyc: MoonPayStepResponse;
162
+ order: MoonPayOrderResponse;
136
163
  };
164
+ export type MoonPayIntentResponse = MoonPayStepResponse | MoonPayOrderResponse;
137
165
  export type MoonPayIntentStatus = MoonPayIntentResponse['status'];
138
166
  /** `RETRY` sends the same request again, with the same key. `REQUOTE` goes back to `POST /fiat/quote`. `NONE` ends the flow. */
139
167
  export type MoonPayRecovery = 'RETRY' | 'REQUOTE' | 'NONE';
140
168
  /**
141
169
  * `SESSION_BUDGET_SPENT`: the per-login SDK session mint budget (429). `RATE_LIMITED`: the kind's
142
- * request budget (429). `PROVIDER_UNAVAILABLE`: MoonPay or Sumsub is down, or a charge cannot be
143
- * recorded. `IN_PROGRESS`: the same key is still running (409). `IDEMPOTENCY_KEY_REUSED`: the same
144
- * key with a different body (422). `INVALID_REQUEST`: a bad body or a missing key (400).
145
- * `TRANSACTION_MISMATCH`: the transaction is not this buyer's (400). `WALLET_MISMATCH`: the
146
- * transaction pays another wallet.
170
+ * request budget (429). `PROVIDER_UNAVAILABLE`: MoonPay or Sumsub is down. `IN_PROGRESS`: the same
171
+ * key is still running (409). `IDEMPOTENCY_KEY_REUSED`: the same key with a different body (422).
172
+ * `INVALID_REQUEST`: a bad body or a missing key (400).
147
173
  */
148
- export type MoonPayFaultReason = 'SESSION_BUDGET_SPENT' | 'RATE_LIMITED' | 'PROVIDER_UNAVAILABLE' | 'IN_PROGRESS' | 'IDEMPOTENCY_KEY_REUSED' | 'INVALID_REQUEST' | 'TRANSACTION_MISMATCH' | 'WALLET_MISMATCH';
174
+ export type MoonPayFaultReason = 'SESSION_BUDGET_SPENT' | 'RATE_LIMITED' | 'PROVIDER_UNAVAILABLE' | 'IN_PROGRESS' | 'IDEMPOTENCY_KEY_REUSED' | 'INVALID_REQUEST';
149
175
  /** The fields a MoonPay fault adds to the shared error body. */
150
176
  export interface MoonPayFault {
151
177
  reason: MoonPayFaultReason;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MOONPAY_ENDPOINTS
3
- } from "../chunk-UN3WTIMI.mjs";
3
+ } from "../chunk-WW26WEZO.mjs";
4
4
  export {
5
5
  MOONPAY_ENDPOINTS
6
6
  };
@@ -3,11 +3,13 @@
3
3
  * the package root, never from `./moonpay`, so the production entry stays free of zod.
4
4
  */
5
5
  import { z } from 'zod';
6
- import type { MoonPayCheckout, MoonPayErrorBody, MoonPayFault, MoonPayIntentRequest, MoonPayIntentResponse, MoonPayQuoteInput, MoonPaySdkCredentials } from './moonpay';
6
+ import type { MoonPayCheckout, MoonPayErrorBody, MoonPayFault, MoonPayIntentRequest, MoonPayIntentResponse, MoonPayOrderResponse, MoonPayQuoteInput, MoonPaySdkCredentials, MoonPayStepResponse } from './moonpay';
7
7
  export declare const MoonPayCheckoutSchema: z.ZodType<MoonPayCheckout>;
8
8
  export declare const MoonPaySdkCredentialsSchema: z.ZodType<MoonPaySdkCredentials>;
9
9
  export declare const MoonPayIntentRequestSchema: z.ZodType<MoonPayIntentRequest>;
10
10
  export declare const MoonPayQuoteInputSchema: z.ZodType<MoonPayQuoteInput>;
11
+ export declare const MoonPayStepResponseSchema: z.ZodType<MoonPayStepResponse>;
12
+ export declare const MoonPayOrderResponseSchema: z.ZodType<MoonPayOrderResponse>;
11
13
  export declare const MoonPayIntentResponseSchema: z.ZodType<MoonPayIntentResponse>;
12
14
  export declare const MoonPayFaultSchema: z.ZodType<MoonPayFault>;
13
15
  export declare const MoonPayErrorBodySchema: z.ZodType<MoonPayErrorBody>;
package/dist/schemas.d.ts CHANGED
@@ -28,7 +28,7 @@
28
28
  */
29
29
  import { z } from 'zod';
30
30
  import type { UsStateCode } from './codes';
31
- import type { BlockedReason, CryptoAmount, FailureReason, FeeLine, FiatAmount, FiatEndpoint, FiatProvider, FiatStepResponse, FieldSpec, FlowState, FormDescriptor, FormField, FormFieldType, InstructionField, Instructions, Instrument, JsonValue, KYCProvider, OrderRef, OrderStatus, OrderSummary, PollSpec, PreparedPayment, PaymentSurface, Quote, QuoteLimitRange, QuoteLimits, Recovery, Refund, ReportSpec, SelectOption, StatusHistoryEntry, Surface, PreferredIdentityDocument, ClientExecutedDelivery, KycSdkResultReport, SurfaceKind, SurfaceProvider, TermsAcceptance, Transition, TransitionInputs, TransitionParams, Tx } from './types';
31
+ import type { BlockedReason, CryptoAmount, FailureReason, FeeLine, FiatAmount, FiatEndpoint, FiatProvider, FiatStepResponse, FieldSpec, FlowState, FormDescriptor, FormField, FormFieldType, InstructionField, Instructions, Instrument, JsonValue, KYCProvider, OrderRef, OrderStatus, OrderSummary, PollSpec, PreparedPayment, PaymentSurface, Quote, QuoteLimitRange, QuoteLimits, Recovery, Refund, ReportSpec, SelectOption, StatusHistoryEntry, Surface, PreferredIdentityDocument, KycFieldId, ClientExecutedDelivery, KycSdkResultReport, SurfaceKind, SurfaceProvider, TermsAcceptance, Transition, TransitionInputs, TransitionParams, Tx } from './types';
32
32
  import type { FiatTermsErrorBody, FiatTermsRequest, FiatTermsResponse, TermsDocument, TermsDocumentAcceptance } from './terms';
33
33
  export declare const JsonSchema: z.ZodType<JsonValue>;
34
34
  export declare const HTTP_VERBS: readonly ["GET", "POST"];
@@ -58,6 +58,7 @@ export declare const SurfaceKindSchema: z.ZodType<SurfaceKind>;
58
58
  export declare const PreferredIdentityDocumentSchema: z.ZodType<PreferredIdentityDocument>;
59
59
  export declare const STANDARD_KYC_FIELD_IDS: readonly ["LEGAL_FIRST_NAME", "LEGAL_MIDDLE_NAME", "LEGAL_LAST_NAME", "DATE_OF_BIRTH", "COUNTRY_OF_BIRTH", "CITY_OF_BIRTH", "NATIONALITY", "EMAIL_ADDRESS", "EMAIL_OWNERSHIP_VERIFICATION", "PHONE_NUMBER", "PHONE_OWNERSHIP_VERIFICATION", "RESIDENTIAL_ADDRESS_LINE_1", "RESIDENTIAL_ADDRESS_LINE_2", "RESIDENTIAL_ADDRESS_CITY", "RESIDENTIAL_ADDRESS_REGION", "RESIDENTIAL_ADDRESS_POSTAL_CODE", "RESIDENTIAL_ADDRESS_COUNTRY", "TAX_IDENTIFIER", "US_SSN_LAST_FOUR", "TAX_RESIDENCE_COUNTRY", "EMPLOYMENT_STATUS", "OCCUPATION_INDUSTRY", "OCCUPATION_TITLE", "SOURCE_OF_FUNDS_DECLARATION", "SOURCE_OF_INCOME_DECLARATION", "SOURCE_OF_WEALTH_DECLARATION", "PURPOSE_OF_SERVICE", "PURPOSE_OF_TRANSACTION", "CUSTOMER_CATEGORY"];
60
60
  export declare const KYC_ACKNOWLEDGEMENT_FIELD_IDS: readonly ["RISK_ACKNOWLEDGEMENT", "COOLING_OFF_ACKNOWLEDGEMENT", "TERMS_ACCEPTANCE"];
61
+ export declare const KycFieldIdSchema: z.ZodType<KycFieldId>;
61
62
  export declare const ClientExecutedDeliverySchema: z.ZodType<ClientExecutedDelivery>;
62
63
  export declare const SurfaceSchema: z.ZodType<Surface>;
63
64
  export declare const PaymentSurfaceSchema: z.ZodType<PaymentSurface>;
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.20.0";
39
+ var version = "0.20.2";
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-TV6IWKTB.mjs";
14
+ } from "./chunk-CYT2NARF.mjs";
15
15
  export {
16
16
  DOCUMENTED_ENDPOINTS,
17
17
  STATE_KEYS,
package/dist/terms.d.ts CHANGED
@@ -49,8 +49,9 @@ export interface FiatTermsResponse {
49
49
  * fetches the documents again. `IN_PROGRESS`: the same key is still running (409).
50
50
  * `IDEMPOTENCY_KEY_REUSED`: the same key with a different body (422). `INVALID_REQUEST`: a bad body
51
51
  * or a missing key (400). `RATE_LIMITED`: the per-login terms budget is spent (429).
52
+ * `PROVIDER_UNAVAILABLE`: the KYC service or a store is down (503); nothing is recorded, so retry.
52
53
  */
53
- export type FiatTermsFaultReason = 'STALE_TERMS' | 'IN_PROGRESS' | 'IDEMPOTENCY_KEY_REUSED' | 'INVALID_REQUEST' | 'RATE_LIMITED';
54
+ export type FiatTermsFaultReason = 'STALE_TERMS' | 'IN_PROGRESS' | 'IDEMPOTENCY_KEY_REUSED' | 'INVALID_REQUEST' | 'RATE_LIMITED' | 'PROVIDER_UNAVAILABLE';
54
55
  /** `RETRY` sends the same request, with the same key. `REQUOTE` goes back to `POST /fiat/quote`. `NONE` ends the flow. */
55
56
  export type FiatTermsRecovery = 'RETRY' | 'REQUOTE' | 'NONE';
56
57
  /** The 4xx/5xx body of `POST /fiat/terms`: the shared error body plus `reason` and `recovery`. */
package/dist/terms.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  FIAT_TERMS_ENDPOINT
3
- } from "./chunk-QXJ54JWX.mjs";
3
+ } from "./chunk-WRRCWAY2.mjs";
4
4
  export {
5
5
  FIAT_TERMS_ENDPOINT
6
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fun-xyz/fiat-contract",
3
- "version": "0.20.0",
3
+ "version": "0.20.2",
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": {