@schematichq/schematic-react 1.8.0 → 1.9.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/dist/schematic-react.cjs.js +615 -9
- package/dist/schematic-react.d.ts +327 -10
- package/dist/schematic-react.esm.js +622 -10
- package/package.json +8 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// node_modules/.pnpm/@schematichq+schematic-js@1.
|
|
1
|
+
// node_modules/.pnpm/@schematichq+schematic-js@1.9.0/node_modules/@schematichq/schematic-js/dist/schematic.esm.js
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -1146,7 +1146,7 @@ function contextString(context) {
|
|
|
1146
1146
|
}, {});
|
|
1147
1147
|
return JSON.stringify(sortedContext);
|
|
1148
1148
|
}
|
|
1149
|
-
var version = "1.
|
|
1149
|
+
var version = "1.9.0";
|
|
1150
1150
|
var SINGLETON = {};
|
|
1151
1151
|
var models_exports = {};
|
|
1152
1152
|
__export(models_exports, {
|
|
@@ -1154,6 +1154,11 @@ __export(models_exports, {
|
|
|
1154
1154
|
ApiErrorFromJSONTyped: () => ApiErrorFromJSONTyped,
|
|
1155
1155
|
ApiErrorToJSON: () => ApiErrorToJSON,
|
|
1156
1156
|
ApiErrorToJSONTyped: () => ApiErrorToJSONTyped,
|
|
1157
|
+
BillingProviderType: () => BillingProviderType,
|
|
1158
|
+
BillingProviderTypeFromJSON: () => BillingProviderTypeFromJSON2,
|
|
1159
|
+
BillingProviderTypeFromJSONTyped: () => BillingProviderTypeFromJSONTyped11,
|
|
1160
|
+
BillingProviderTypeToJSON: () => BillingProviderTypeToJSON2,
|
|
1161
|
+
BillingProviderTypeToJSONTyped: () => BillingProviderTypeToJSONTyped11,
|
|
1157
1162
|
CompanyDiscountResponseDataFromJSON: () => CompanyDiscountResponseDataFromJSON,
|
|
1158
1163
|
CompanyDiscountResponseDataFromJSONTyped: () => CompanyDiscountResponseDataFromJSONTyped,
|
|
1159
1164
|
CompanyDiscountResponseDataToJSON: () => CompanyDiscountResponseDataToJSON,
|
|
@@ -1166,10 +1171,30 @@ __export(models_exports, {
|
|
|
1166
1171
|
CompanyInvoicesResponseDataFromJSONTyped: () => CompanyInvoicesResponseDataFromJSONTyped,
|
|
1167
1172
|
CompanyInvoicesResponseDataToJSON: () => CompanyInvoicesResponseDataToJSON,
|
|
1168
1173
|
CompanyInvoicesResponseDataToJSONTyped: () => CompanyInvoicesResponseDataToJSONTyped,
|
|
1174
|
+
CompanyPaymentMethodResponseDataFromJSON: () => CompanyPaymentMethodResponseDataFromJSON,
|
|
1175
|
+
CompanyPaymentMethodResponseDataFromJSONTyped: () => CompanyPaymentMethodResponseDataFromJSONTyped,
|
|
1176
|
+
CompanyPaymentMethodResponseDataToJSON: () => CompanyPaymentMethodResponseDataToJSON,
|
|
1177
|
+
CompanyPaymentMethodResponseDataToJSONTyped: () => CompanyPaymentMethodResponseDataToJSONTyped,
|
|
1178
|
+
CompanyPaymentMethodsResponseDataFromJSON: () => CompanyPaymentMethodsResponseDataFromJSON,
|
|
1179
|
+
CompanyPaymentMethodsResponseDataFromJSONTyped: () => CompanyPaymentMethodsResponseDataFromJSONTyped,
|
|
1180
|
+
CompanyPaymentMethodsResponseDataToJSON: () => CompanyPaymentMethodsResponseDataToJSON,
|
|
1181
|
+
CompanyPaymentMethodsResponseDataToJSONTyped: () => CompanyPaymentMethodsResponseDataToJSONTyped,
|
|
1169
1182
|
CompanyUpcomingInvoiceResponseDataFromJSON: () => CompanyUpcomingInvoiceResponseDataFromJSON,
|
|
1170
1183
|
CompanyUpcomingInvoiceResponseDataFromJSONTyped: () => CompanyUpcomingInvoiceResponseDataFromJSONTyped,
|
|
1171
1184
|
CompanyUpcomingInvoiceResponseDataToJSON: () => CompanyUpcomingInvoiceResponseDataToJSON,
|
|
1172
1185
|
CompanyUpcomingInvoiceResponseDataToJSONTyped: () => CompanyUpcomingInvoiceResponseDataToJSONTyped,
|
|
1186
|
+
CreateSetupIntentResponseFromJSON: () => CreateSetupIntentResponseFromJSON,
|
|
1187
|
+
CreateSetupIntentResponseFromJSONTyped: () => CreateSetupIntentResponseFromJSONTyped,
|
|
1188
|
+
CreateSetupIntentResponseToJSON: () => CreateSetupIntentResponseToJSON,
|
|
1189
|
+
CreateSetupIntentResponseToJSONTyped: () => CreateSetupIntentResponseToJSONTyped,
|
|
1190
|
+
DeletePaymentMethodResponseFromJSON: () => DeletePaymentMethodResponseFromJSON,
|
|
1191
|
+
DeletePaymentMethodResponseFromJSONTyped: () => DeletePaymentMethodResponseFromJSONTyped,
|
|
1192
|
+
DeletePaymentMethodResponseToJSON: () => DeletePaymentMethodResponseToJSON,
|
|
1193
|
+
DeletePaymentMethodResponseToJSONTyped: () => DeletePaymentMethodResponseToJSONTyped,
|
|
1194
|
+
DeleteResponseFromJSON: () => DeleteResponseFromJSON,
|
|
1195
|
+
DeleteResponseFromJSONTyped: () => DeleteResponseFromJSONTyped,
|
|
1196
|
+
DeleteResponseToJSON: () => DeleteResponseToJSON,
|
|
1197
|
+
DeleteResponseToJSONTyped: () => DeleteResponseToJSONTyped,
|
|
1173
1198
|
GetCompanyInvoicesParamsFromJSON: () => GetCompanyInvoicesParamsFromJSON,
|
|
1174
1199
|
GetCompanyInvoicesParamsFromJSONTyped: () => GetCompanyInvoicesParamsFromJSONTyped,
|
|
1175
1200
|
GetCompanyInvoicesParamsToJSON: () => GetCompanyInvoicesParamsToJSON,
|
|
@@ -1178,6 +1203,10 @@ __export(models_exports, {
|
|
|
1178
1203
|
GetCompanyInvoicesResponseFromJSONTyped: () => GetCompanyInvoicesResponseFromJSONTyped,
|
|
1179
1204
|
GetCompanyInvoicesResponseToJSON: () => GetCompanyInvoicesResponseToJSON,
|
|
1180
1205
|
GetCompanyInvoicesResponseToJSONTyped: () => GetCompanyInvoicesResponseToJSONTyped,
|
|
1206
|
+
GetCompanyPaymentMethodsResponseFromJSON: () => GetCompanyPaymentMethodsResponseFromJSON,
|
|
1207
|
+
GetCompanyPaymentMethodsResponseFromJSONTyped: () => GetCompanyPaymentMethodsResponseFromJSONTyped,
|
|
1208
|
+
GetCompanyPaymentMethodsResponseToJSON: () => GetCompanyPaymentMethodsResponseToJSON,
|
|
1209
|
+
GetCompanyPaymentMethodsResponseToJSONTyped: () => GetCompanyPaymentMethodsResponseToJSONTyped,
|
|
1181
1210
|
GetCompanyUpcomingInvoiceResponseFromJSON: () => GetCompanyUpcomingInvoiceResponseFromJSON,
|
|
1182
1211
|
GetCompanyUpcomingInvoiceResponseFromJSONTyped: () => GetCompanyUpcomingInvoiceResponseFromJSONTyped,
|
|
1183
1212
|
GetCompanyUpcomingInvoiceResponseToJSON: () => GetCompanyUpcomingInvoiceResponseToJSON,
|
|
@@ -1187,15 +1216,42 @@ __export(models_exports, {
|
|
|
1187
1216
|
InvoiceStatusFromJSONTyped: () => InvoiceStatusFromJSONTyped,
|
|
1188
1217
|
InvoiceStatusToJSON: () => InvoiceStatusToJSON,
|
|
1189
1218
|
InvoiceStatusToJSONTyped: () => InvoiceStatusToJSONTyped,
|
|
1219
|
+
PaymentMethodResponseDataFromJSON: () => PaymentMethodResponseDataFromJSON,
|
|
1220
|
+
PaymentMethodResponseDataFromJSONTyped: () => PaymentMethodResponseDataFromJSONTyped,
|
|
1221
|
+
PaymentMethodResponseDataToJSON: () => PaymentMethodResponseDataToJSON,
|
|
1222
|
+
PaymentMethodResponseDataToJSONTyped: () => PaymentMethodResponseDataToJSONTyped,
|
|
1223
|
+
SetupIntentResponseDataFromJSON: () => SetupIntentResponseDataFromJSON,
|
|
1224
|
+
SetupIntentResponseDataFromJSONTyped: () => SetupIntentResponseDataFromJSONTyped,
|
|
1225
|
+
SetupIntentResponseDataToJSON: () => SetupIntentResponseDataToJSON,
|
|
1226
|
+
SetupIntentResponseDataToJSONTyped: () => SetupIntentResponseDataToJSONTyped,
|
|
1227
|
+
UpdatePaymentMethodRequestBodyFromJSON: () => UpdatePaymentMethodRequestBodyFromJSON,
|
|
1228
|
+
UpdatePaymentMethodRequestBodyFromJSONTyped: () => UpdatePaymentMethodRequestBodyFromJSONTyped,
|
|
1229
|
+
UpdatePaymentMethodRequestBodyToJSON: () => UpdatePaymentMethodRequestBodyToJSON,
|
|
1230
|
+
UpdatePaymentMethodRequestBodyToJSONTyped: () => UpdatePaymentMethodRequestBodyToJSONTyped,
|
|
1231
|
+
UpdatePaymentMethodResponseFromJSON: () => UpdatePaymentMethodResponseFromJSON,
|
|
1232
|
+
UpdatePaymentMethodResponseFromJSONTyped: () => UpdatePaymentMethodResponseFromJSONTyped,
|
|
1233
|
+
UpdatePaymentMethodResponseToJSON: () => UpdatePaymentMethodResponseToJSON,
|
|
1234
|
+
UpdatePaymentMethodResponseToJSONTyped: () => UpdatePaymentMethodResponseToJSONTyped,
|
|
1190
1235
|
instanceOfApiError: () => instanceOfApiError,
|
|
1236
|
+
instanceOfBillingProviderType: () => instanceOfBillingProviderType,
|
|
1191
1237
|
instanceOfCompanyDiscountResponseData: () => instanceOfCompanyDiscountResponseData,
|
|
1192
1238
|
instanceOfCompanyInvoiceResponseData: () => instanceOfCompanyInvoiceResponseData,
|
|
1193
1239
|
instanceOfCompanyInvoicesResponseData: () => instanceOfCompanyInvoicesResponseData,
|
|
1240
|
+
instanceOfCompanyPaymentMethodResponseData: () => instanceOfCompanyPaymentMethodResponseData,
|
|
1241
|
+
instanceOfCompanyPaymentMethodsResponseData: () => instanceOfCompanyPaymentMethodsResponseData,
|
|
1194
1242
|
instanceOfCompanyUpcomingInvoiceResponseData: () => instanceOfCompanyUpcomingInvoiceResponseData,
|
|
1243
|
+
instanceOfCreateSetupIntentResponse: () => instanceOfCreateSetupIntentResponse,
|
|
1244
|
+
instanceOfDeletePaymentMethodResponse: () => instanceOfDeletePaymentMethodResponse,
|
|
1245
|
+
instanceOfDeleteResponse: () => instanceOfDeleteResponse,
|
|
1195
1246
|
instanceOfGetCompanyInvoicesParams: () => instanceOfGetCompanyInvoicesParams,
|
|
1196
1247
|
instanceOfGetCompanyInvoicesResponse: () => instanceOfGetCompanyInvoicesResponse,
|
|
1248
|
+
instanceOfGetCompanyPaymentMethodsResponse: () => instanceOfGetCompanyPaymentMethodsResponse,
|
|
1197
1249
|
instanceOfGetCompanyUpcomingInvoiceResponse: () => instanceOfGetCompanyUpcomingInvoiceResponse,
|
|
1198
|
-
instanceOfInvoiceStatus: () => instanceOfInvoiceStatus
|
|
1250
|
+
instanceOfInvoiceStatus: () => instanceOfInvoiceStatus,
|
|
1251
|
+
instanceOfPaymentMethodResponseData: () => instanceOfPaymentMethodResponseData,
|
|
1252
|
+
instanceOfSetupIntentResponseData: () => instanceOfSetupIntentResponseData,
|
|
1253
|
+
instanceOfUpdatePaymentMethodRequestBody: () => instanceOfUpdatePaymentMethodRequestBody,
|
|
1254
|
+
instanceOfUpdatePaymentMethodResponse: () => instanceOfUpdatePaymentMethodResponse
|
|
1199
1255
|
});
|
|
1200
1256
|
function instanceOfApiError(value) {
|
|
1201
1257
|
if (!("error" in value) || value["error"] === void 0) return false;
|
|
@@ -1223,6 +1279,34 @@ function ApiErrorToJSONTyped(value, ignoreDiscriminator = false) {
|
|
|
1223
1279
|
error: value["error"]
|
|
1224
1280
|
};
|
|
1225
1281
|
}
|
|
1282
|
+
var BillingProviderType = {
|
|
1283
|
+
Metronome: "metronome",
|
|
1284
|
+
Orb: "orb",
|
|
1285
|
+
Schematic: "schematic",
|
|
1286
|
+
Stripe: "stripe"
|
|
1287
|
+
};
|
|
1288
|
+
function instanceOfBillingProviderType(value) {
|
|
1289
|
+
for (const key in BillingProviderType) {
|
|
1290
|
+
if (Object.prototype.hasOwnProperty.call(BillingProviderType, key)) {
|
|
1291
|
+
if (BillingProviderType[key] === value) {
|
|
1292
|
+
return true;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
return false;
|
|
1297
|
+
}
|
|
1298
|
+
function BillingProviderTypeFromJSON2(json) {
|
|
1299
|
+
return BillingProviderTypeFromJSONTyped11(json, false);
|
|
1300
|
+
}
|
|
1301
|
+
function BillingProviderTypeFromJSONTyped11(json, ignoreDiscriminator) {
|
|
1302
|
+
return json;
|
|
1303
|
+
}
|
|
1304
|
+
function BillingProviderTypeToJSON2(value) {
|
|
1305
|
+
return value;
|
|
1306
|
+
}
|
|
1307
|
+
function BillingProviderTypeToJSONTyped11(value, ignoreDiscriminator) {
|
|
1308
|
+
return value;
|
|
1309
|
+
}
|
|
1226
1310
|
function instanceOfCompanyDiscountResponseData(value) {
|
|
1227
1311
|
if (!("couponName" in value) || value["couponName"] === void 0)
|
|
1228
1312
|
return false;
|
|
@@ -1366,6 +1450,97 @@ function CompanyInvoicesResponseDataToJSONTyped(value, ignoreDiscriminator = fal
|
|
|
1366
1450
|
)
|
|
1367
1451
|
};
|
|
1368
1452
|
}
|
|
1453
|
+
function instanceOfCompanyPaymentMethodResponseData(value) {
|
|
1454
|
+
if (!("canRemove" in value) || value["canRemove"] === void 0) return false;
|
|
1455
|
+
if (!("externalId" in value) || value["externalId"] === void 0)
|
|
1456
|
+
return false;
|
|
1457
|
+
if (!("id" in value) || value["id"] === void 0) return false;
|
|
1458
|
+
if (!("isDefault" in value) || value["isDefault"] === void 0) return false;
|
|
1459
|
+
if (!("type" in value) || value["type"] === void 0) return false;
|
|
1460
|
+
return true;
|
|
1461
|
+
}
|
|
1462
|
+
function CompanyPaymentMethodResponseDataFromJSON(json) {
|
|
1463
|
+
return CompanyPaymentMethodResponseDataFromJSONTyped(json, false);
|
|
1464
|
+
}
|
|
1465
|
+
function CompanyPaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1466
|
+
if (json == null) {
|
|
1467
|
+
return json;
|
|
1468
|
+
}
|
|
1469
|
+
return {
|
|
1470
|
+
accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
|
|
1471
|
+
accountName: json["account_name"] == null ? void 0 : json["account_name"],
|
|
1472
|
+
bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
|
|
1473
|
+
billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
|
|
1474
|
+
billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
|
|
1475
|
+
canRemove: json["can_remove"],
|
|
1476
|
+
cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
|
|
1477
|
+
cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
|
|
1478
|
+
cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
|
|
1479
|
+
cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
|
|
1480
|
+
externalId: json["external_id"],
|
|
1481
|
+
id: json["id"],
|
|
1482
|
+
isDefault: json["is_default"],
|
|
1483
|
+
type: json["type"]
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
function CompanyPaymentMethodResponseDataToJSON(json) {
|
|
1487
|
+
return CompanyPaymentMethodResponseDataToJSONTyped(json, false);
|
|
1488
|
+
}
|
|
1489
|
+
function CompanyPaymentMethodResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1490
|
+
if (value == null) {
|
|
1491
|
+
return value;
|
|
1492
|
+
}
|
|
1493
|
+
return {
|
|
1494
|
+
account_last4: value["accountLast4"],
|
|
1495
|
+
account_name: value["accountName"],
|
|
1496
|
+
bank_name: value["bankName"],
|
|
1497
|
+
billing_email: value["billingEmail"],
|
|
1498
|
+
billing_name: value["billingName"],
|
|
1499
|
+
can_remove: value["canRemove"],
|
|
1500
|
+
card_brand: value["cardBrand"],
|
|
1501
|
+
card_exp_month: value["cardExpMonth"],
|
|
1502
|
+
card_exp_year: value["cardExpYear"],
|
|
1503
|
+
card_last4: value["cardLast4"],
|
|
1504
|
+
external_id: value["externalId"],
|
|
1505
|
+
id: value["id"],
|
|
1506
|
+
is_default: value["isDefault"],
|
|
1507
|
+
type: value["type"]
|
|
1508
|
+
};
|
|
1509
|
+
}
|
|
1510
|
+
function instanceOfCompanyPaymentMethodsResponseData(value) {
|
|
1511
|
+
if (!("count" in value) || value["count"] === void 0) return false;
|
|
1512
|
+
if (!("paymentMethods" in value) || value["paymentMethods"] === void 0)
|
|
1513
|
+
return false;
|
|
1514
|
+
return true;
|
|
1515
|
+
}
|
|
1516
|
+
function CompanyPaymentMethodsResponseDataFromJSON(json) {
|
|
1517
|
+
return CompanyPaymentMethodsResponseDataFromJSONTyped(json, false);
|
|
1518
|
+
}
|
|
1519
|
+
function CompanyPaymentMethodsResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1520
|
+
if (json == null) {
|
|
1521
|
+
return json;
|
|
1522
|
+
}
|
|
1523
|
+
return {
|
|
1524
|
+
count: json["count"],
|
|
1525
|
+
paymentMethods: json["payment_methods"].map(
|
|
1526
|
+
CompanyPaymentMethodResponseDataFromJSON
|
|
1527
|
+
)
|
|
1528
|
+
};
|
|
1529
|
+
}
|
|
1530
|
+
function CompanyPaymentMethodsResponseDataToJSON(json) {
|
|
1531
|
+
return CompanyPaymentMethodsResponseDataToJSONTyped(json, false);
|
|
1532
|
+
}
|
|
1533
|
+
function CompanyPaymentMethodsResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1534
|
+
if (value == null) {
|
|
1535
|
+
return value;
|
|
1536
|
+
}
|
|
1537
|
+
return {
|
|
1538
|
+
count: value["count"],
|
|
1539
|
+
payment_methods: value["paymentMethods"].map(
|
|
1540
|
+
CompanyPaymentMethodResponseDataToJSON
|
|
1541
|
+
)
|
|
1542
|
+
};
|
|
1543
|
+
}
|
|
1369
1544
|
function instanceOfCompanyUpcomingInvoiceResponseData(value) {
|
|
1370
1545
|
if (!("amountDue" in value) || value["amountDue"] === void 0) return false;
|
|
1371
1546
|
if (!("currency" in value) || value["currency"] === void 0) return false;
|
|
@@ -1415,6 +1590,122 @@ function CompanyUpcomingInvoiceResponseDataToJSONTyped(value, ignoreDiscriminato
|
|
|
1415
1590
|
subtotal: value["subtotal"]
|
|
1416
1591
|
};
|
|
1417
1592
|
}
|
|
1593
|
+
function instanceOfSetupIntentResponseData(value) {
|
|
1594
|
+
if (!("schematicPublishableKey" in value) || value["schematicPublishableKey"] === void 0)
|
|
1595
|
+
return false;
|
|
1596
|
+
return true;
|
|
1597
|
+
}
|
|
1598
|
+
function SetupIntentResponseDataFromJSON(json) {
|
|
1599
|
+
return SetupIntentResponseDataFromJSONTyped(json, false);
|
|
1600
|
+
}
|
|
1601
|
+
function SetupIntentResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1602
|
+
if (json == null) {
|
|
1603
|
+
return json;
|
|
1604
|
+
}
|
|
1605
|
+
return {
|
|
1606
|
+
accountId: json["account_id"] == null ? void 0 : json["account_id"],
|
|
1607
|
+
publishableKey: json["publishable_key"] == null ? void 0 : json["publishable_key"],
|
|
1608
|
+
schematicPublishableKey: json["schematic_publishable_key"],
|
|
1609
|
+
setupIntentClientSecret: json["setup_intent_client_secret"] == null ? void 0 : json["setup_intent_client_secret"]
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1612
|
+
function SetupIntentResponseDataToJSON(json) {
|
|
1613
|
+
return SetupIntentResponseDataToJSONTyped(json, false);
|
|
1614
|
+
}
|
|
1615
|
+
function SetupIntentResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1616
|
+
if (value == null) {
|
|
1617
|
+
return value;
|
|
1618
|
+
}
|
|
1619
|
+
return {
|
|
1620
|
+
account_id: value["accountId"],
|
|
1621
|
+
publishable_key: value["publishableKey"],
|
|
1622
|
+
schematic_publishable_key: value["schematicPublishableKey"],
|
|
1623
|
+
setup_intent_client_secret: value["setupIntentClientSecret"]
|
|
1624
|
+
};
|
|
1625
|
+
}
|
|
1626
|
+
function instanceOfCreateSetupIntentResponse(value) {
|
|
1627
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1628
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
1629
|
+
return true;
|
|
1630
|
+
}
|
|
1631
|
+
function CreateSetupIntentResponseFromJSON(json) {
|
|
1632
|
+
return CreateSetupIntentResponseFromJSONTyped(json, false);
|
|
1633
|
+
}
|
|
1634
|
+
function CreateSetupIntentResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1635
|
+
if (json == null) {
|
|
1636
|
+
return json;
|
|
1637
|
+
}
|
|
1638
|
+
return {
|
|
1639
|
+
data: SetupIntentResponseDataFromJSON(json["data"]),
|
|
1640
|
+
params: json["params"]
|
|
1641
|
+
};
|
|
1642
|
+
}
|
|
1643
|
+
function CreateSetupIntentResponseToJSON(json) {
|
|
1644
|
+
return CreateSetupIntentResponseToJSONTyped(json, false);
|
|
1645
|
+
}
|
|
1646
|
+
function CreateSetupIntentResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1647
|
+
if (value == null) {
|
|
1648
|
+
return value;
|
|
1649
|
+
}
|
|
1650
|
+
return {
|
|
1651
|
+
data: SetupIntentResponseDataToJSON(value["data"]),
|
|
1652
|
+
params: value["params"]
|
|
1653
|
+
};
|
|
1654
|
+
}
|
|
1655
|
+
function instanceOfDeleteResponse(value) {
|
|
1656
|
+
return true;
|
|
1657
|
+
}
|
|
1658
|
+
function DeleteResponseFromJSON(json) {
|
|
1659
|
+
return DeleteResponseFromJSONTyped(json, false);
|
|
1660
|
+
}
|
|
1661
|
+
function DeleteResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1662
|
+
if (json == null) {
|
|
1663
|
+
return json;
|
|
1664
|
+
}
|
|
1665
|
+
return {
|
|
1666
|
+
deleted: json["deleted"] == null ? void 0 : json["deleted"]
|
|
1667
|
+
};
|
|
1668
|
+
}
|
|
1669
|
+
function DeleteResponseToJSON(json) {
|
|
1670
|
+
return DeleteResponseToJSONTyped(json, false);
|
|
1671
|
+
}
|
|
1672
|
+
function DeleteResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1673
|
+
if (value == null) {
|
|
1674
|
+
return value;
|
|
1675
|
+
}
|
|
1676
|
+
return {
|
|
1677
|
+
deleted: value["deleted"]
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1680
|
+
function instanceOfDeletePaymentMethodResponse(value) {
|
|
1681
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1682
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
1683
|
+
return true;
|
|
1684
|
+
}
|
|
1685
|
+
function DeletePaymentMethodResponseFromJSON(json) {
|
|
1686
|
+
return DeletePaymentMethodResponseFromJSONTyped(json, false);
|
|
1687
|
+
}
|
|
1688
|
+
function DeletePaymentMethodResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1689
|
+
if (json == null) {
|
|
1690
|
+
return json;
|
|
1691
|
+
}
|
|
1692
|
+
return {
|
|
1693
|
+
data: DeleteResponseFromJSON(json["data"]),
|
|
1694
|
+
params: json["params"]
|
|
1695
|
+
};
|
|
1696
|
+
}
|
|
1697
|
+
function DeletePaymentMethodResponseToJSON(json) {
|
|
1698
|
+
return DeletePaymentMethodResponseToJSONTyped(json, false);
|
|
1699
|
+
}
|
|
1700
|
+
function DeletePaymentMethodResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1701
|
+
if (value == null) {
|
|
1702
|
+
return value;
|
|
1703
|
+
}
|
|
1704
|
+
return {
|
|
1705
|
+
data: DeleteResponseToJSON(value["data"]),
|
|
1706
|
+
params: value["params"]
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
1418
1709
|
function instanceOfGetCompanyInvoicesParams(value) {
|
|
1419
1710
|
return true;
|
|
1420
1711
|
}
|
|
@@ -1473,6 +1764,35 @@ function GetCompanyInvoicesResponseToJSONTyped(value, ignoreDiscriminator = fals
|
|
|
1473
1764
|
params: GetCompanyInvoicesParamsToJSON(value["params"])
|
|
1474
1765
|
};
|
|
1475
1766
|
}
|
|
1767
|
+
function instanceOfGetCompanyPaymentMethodsResponse(value) {
|
|
1768
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1769
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
1770
|
+
return true;
|
|
1771
|
+
}
|
|
1772
|
+
function GetCompanyPaymentMethodsResponseFromJSON(json) {
|
|
1773
|
+
return GetCompanyPaymentMethodsResponseFromJSONTyped(json, false);
|
|
1774
|
+
}
|
|
1775
|
+
function GetCompanyPaymentMethodsResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1776
|
+
if (json == null) {
|
|
1777
|
+
return json;
|
|
1778
|
+
}
|
|
1779
|
+
return {
|
|
1780
|
+
data: CompanyPaymentMethodsResponseDataFromJSON(json["data"]),
|
|
1781
|
+
params: json["params"]
|
|
1782
|
+
};
|
|
1783
|
+
}
|
|
1784
|
+
function GetCompanyPaymentMethodsResponseToJSON(json) {
|
|
1785
|
+
return GetCompanyPaymentMethodsResponseToJSONTyped(json, false);
|
|
1786
|
+
}
|
|
1787
|
+
function GetCompanyPaymentMethodsResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1788
|
+
if (value == null) {
|
|
1789
|
+
return value;
|
|
1790
|
+
}
|
|
1791
|
+
return {
|
|
1792
|
+
data: CompanyPaymentMethodsResponseDataToJSON(value["data"]),
|
|
1793
|
+
params: value["params"]
|
|
1794
|
+
};
|
|
1795
|
+
}
|
|
1476
1796
|
function instanceOfGetCompanyUpcomingInvoiceResponse(value) {
|
|
1477
1797
|
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1478
1798
|
if (!("params" in value) || value["params"] === void 0) return false;
|
|
@@ -1502,6 +1822,134 @@ function GetCompanyUpcomingInvoiceResponseToJSONTyped(value, ignoreDiscriminator
|
|
|
1502
1822
|
params: value["params"]
|
|
1503
1823
|
};
|
|
1504
1824
|
}
|
|
1825
|
+
function instanceOfPaymentMethodResponseData(value) {
|
|
1826
|
+
if (!("createdAt" in value) || value["createdAt"] === void 0) return false;
|
|
1827
|
+
if (!("customerExternalId" in value) || value["customerExternalId"] === void 0)
|
|
1828
|
+
return false;
|
|
1829
|
+
if (!("environmentId" in value) || value["environmentId"] === void 0)
|
|
1830
|
+
return false;
|
|
1831
|
+
if (!("externalId" in value) || value["externalId"] === void 0)
|
|
1832
|
+
return false;
|
|
1833
|
+
if (!("id" in value) || value["id"] === void 0) return false;
|
|
1834
|
+
if (!("paymentMethodType" in value) || value["paymentMethodType"] === void 0)
|
|
1835
|
+
return false;
|
|
1836
|
+
if (!("providerType" in value) || value["providerType"] === void 0)
|
|
1837
|
+
return false;
|
|
1838
|
+
if (!("updatedAt" in value) || value["updatedAt"] === void 0) return false;
|
|
1839
|
+
return true;
|
|
1840
|
+
}
|
|
1841
|
+
function PaymentMethodResponseDataFromJSON(json) {
|
|
1842
|
+
return PaymentMethodResponseDataFromJSONTyped(json, false);
|
|
1843
|
+
}
|
|
1844
|
+
function PaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1845
|
+
if (json == null) {
|
|
1846
|
+
return json;
|
|
1847
|
+
}
|
|
1848
|
+
return {
|
|
1849
|
+
accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
|
|
1850
|
+
accountName: json["account_name"] == null ? void 0 : json["account_name"],
|
|
1851
|
+
bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
|
|
1852
|
+
billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
|
|
1853
|
+
billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
|
|
1854
|
+
cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
|
|
1855
|
+
cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
|
|
1856
|
+
cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
|
|
1857
|
+
cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
|
|
1858
|
+
companyId: json["company_id"] == null ? void 0 : json["company_id"],
|
|
1859
|
+
createdAt: new Date(json["created_at"]),
|
|
1860
|
+
customerExternalId: json["customer_external_id"],
|
|
1861
|
+
environmentId: json["environment_id"],
|
|
1862
|
+
externalId: json["external_id"],
|
|
1863
|
+
id: json["id"],
|
|
1864
|
+
paymentMethodType: json["payment_method_type"],
|
|
1865
|
+
providerType: BillingProviderTypeFromJSON2(json["provider_type"]),
|
|
1866
|
+
updatedAt: new Date(json["updated_at"])
|
|
1867
|
+
};
|
|
1868
|
+
}
|
|
1869
|
+
function PaymentMethodResponseDataToJSON(json) {
|
|
1870
|
+
return PaymentMethodResponseDataToJSONTyped(json, false);
|
|
1871
|
+
}
|
|
1872
|
+
function PaymentMethodResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1873
|
+
if (value == null) {
|
|
1874
|
+
return value;
|
|
1875
|
+
}
|
|
1876
|
+
return {
|
|
1877
|
+
account_last4: value["accountLast4"],
|
|
1878
|
+
account_name: value["accountName"],
|
|
1879
|
+
bank_name: value["bankName"],
|
|
1880
|
+
billing_email: value["billingEmail"],
|
|
1881
|
+
billing_name: value["billingName"],
|
|
1882
|
+
card_brand: value["cardBrand"],
|
|
1883
|
+
card_exp_month: value["cardExpMonth"],
|
|
1884
|
+
card_exp_year: value["cardExpYear"],
|
|
1885
|
+
card_last4: value["cardLast4"],
|
|
1886
|
+
company_id: value["companyId"],
|
|
1887
|
+
created_at: value["createdAt"].toISOString(),
|
|
1888
|
+
customer_external_id: value["customerExternalId"],
|
|
1889
|
+
environment_id: value["environmentId"],
|
|
1890
|
+
external_id: value["externalId"],
|
|
1891
|
+
id: value["id"],
|
|
1892
|
+
payment_method_type: value["paymentMethodType"],
|
|
1893
|
+
provider_type: BillingProviderTypeToJSON2(value["providerType"]),
|
|
1894
|
+
updated_at: value["updatedAt"].toISOString()
|
|
1895
|
+
};
|
|
1896
|
+
}
|
|
1897
|
+
function instanceOfUpdatePaymentMethodRequestBody(value) {
|
|
1898
|
+
if (!("paymentMethodId" in value) || value["paymentMethodId"] === void 0)
|
|
1899
|
+
return false;
|
|
1900
|
+
return true;
|
|
1901
|
+
}
|
|
1902
|
+
function UpdatePaymentMethodRequestBodyFromJSON(json) {
|
|
1903
|
+
return UpdatePaymentMethodRequestBodyFromJSONTyped(json, false);
|
|
1904
|
+
}
|
|
1905
|
+
function UpdatePaymentMethodRequestBodyFromJSONTyped(json, ignoreDiscriminator) {
|
|
1906
|
+
if (json == null) {
|
|
1907
|
+
return json;
|
|
1908
|
+
}
|
|
1909
|
+
return {
|
|
1910
|
+
paymentMethodId: json["payment_method_id"]
|
|
1911
|
+
};
|
|
1912
|
+
}
|
|
1913
|
+
function UpdatePaymentMethodRequestBodyToJSON(json) {
|
|
1914
|
+
return UpdatePaymentMethodRequestBodyToJSONTyped(json, false);
|
|
1915
|
+
}
|
|
1916
|
+
function UpdatePaymentMethodRequestBodyToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1917
|
+
if (value == null) {
|
|
1918
|
+
return value;
|
|
1919
|
+
}
|
|
1920
|
+
return {
|
|
1921
|
+
payment_method_id: value["paymentMethodId"]
|
|
1922
|
+
};
|
|
1923
|
+
}
|
|
1924
|
+
function instanceOfUpdatePaymentMethodResponse(value) {
|
|
1925
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1926
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
1927
|
+
return true;
|
|
1928
|
+
}
|
|
1929
|
+
function UpdatePaymentMethodResponseFromJSON(json) {
|
|
1930
|
+
return UpdatePaymentMethodResponseFromJSONTyped(json, false);
|
|
1931
|
+
}
|
|
1932
|
+
function UpdatePaymentMethodResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1933
|
+
if (json == null) {
|
|
1934
|
+
return json;
|
|
1935
|
+
}
|
|
1936
|
+
return {
|
|
1937
|
+
data: PaymentMethodResponseDataFromJSON(json["data"]),
|
|
1938
|
+
params: json["params"]
|
|
1939
|
+
};
|
|
1940
|
+
}
|
|
1941
|
+
function UpdatePaymentMethodResponseToJSON(json) {
|
|
1942
|
+
return UpdatePaymentMethodResponseToJSONTyped(json, false);
|
|
1943
|
+
}
|
|
1944
|
+
function UpdatePaymentMethodResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1945
|
+
if (value == null) {
|
|
1946
|
+
return value;
|
|
1947
|
+
}
|
|
1948
|
+
return {
|
|
1949
|
+
data: PaymentMethodResponseDataToJSON(value["data"]),
|
|
1950
|
+
params: value["params"]
|
|
1951
|
+
};
|
|
1952
|
+
}
|
|
1505
1953
|
var DEFAULT_INVOICE_QUERY = {};
|
|
1506
1954
|
function normalizeInvoiceQuery(query) {
|
|
1507
1955
|
const { includePending, ...rest } = query;
|
|
@@ -1826,6 +2274,39 @@ var SchematicBillingClient = class {
|
|
|
1826
2274
|
return GetCompanyUpcomingInvoiceResponseFromJSON(body).data;
|
|
1827
2275
|
});
|
|
1828
2276
|
}
|
|
2277
|
+
fetchPaymentMethods() {
|
|
2278
|
+
const path = "/company/payment-methods";
|
|
2279
|
+
return this.session.request(path).then((body) => {
|
|
2280
|
+
if (body === null || typeof body !== "object" || !("data" in body)) {
|
|
2281
|
+
throw new Error(`Malformed response from ${path}`);
|
|
2282
|
+
}
|
|
2283
|
+
const data = body.data;
|
|
2284
|
+
if (data == null || data.payment_methods == null) {
|
|
2285
|
+
return [];
|
|
2286
|
+
}
|
|
2287
|
+
return GetCompanyPaymentMethodsResponseFromJSON(body).data.paymentMethods;
|
|
2288
|
+
});
|
|
2289
|
+
}
|
|
2290
|
+
createSetupIntent() {
|
|
2291
|
+
const path = "/components/setup-intent";
|
|
2292
|
+
return this.session.request(path, { method: "POST" }).then((body) => {
|
|
2293
|
+
if (body === null || typeof body !== "object" || !("data" in body)) {
|
|
2294
|
+
throw new Error(`Malformed response from ${path}`);
|
|
2295
|
+
}
|
|
2296
|
+
return CreateSetupIntentResponseFromJSON(body).data;
|
|
2297
|
+
});
|
|
2298
|
+
}
|
|
2299
|
+
updatePaymentMethod(externalId) {
|
|
2300
|
+
return this.session.request("/checkout/paymentmethod/update", {
|
|
2301
|
+
method: "POST",
|
|
2302
|
+
body: { payment_method_id: externalId }
|
|
2303
|
+
}).then(() => void 0);
|
|
2304
|
+
}
|
|
2305
|
+
deletePaymentMethod(id) {
|
|
2306
|
+
return this.session.request(`/checkout/paymentmethod/${encodeURIComponent(id)}`, {
|
|
2307
|
+
method: "DELETE"
|
|
2308
|
+
}).then(() => void 0);
|
|
2309
|
+
}
|
|
1829
2310
|
};
|
|
1830
2311
|
var anonymousIdKey = "schematicId";
|
|
1831
2312
|
var flagStateCachePrefix = "schematicCache";
|
|
@@ -3946,6 +4427,10 @@ var BillingStore = class {
|
|
|
3946
4427
|
() => this._client.fetchUpcomingInvoice(),
|
|
3947
4428
|
{ readiness }
|
|
3948
4429
|
);
|
|
4430
|
+
this.paymentMethods = new KeyedResource(
|
|
4431
|
+
() => this._client.fetchPaymentMethods(),
|
|
4432
|
+
{ readiness }
|
|
4433
|
+
);
|
|
3949
4434
|
const held = { key: initialData.sessionKey };
|
|
3950
4435
|
if (initialData.invoices !== void 0) {
|
|
3951
4436
|
held.invoices = {
|
|
@@ -3960,7 +4445,10 @@ var BillingStore = class {
|
|
|
3960
4445
|
if (initialData.upcomingInvoice !== void 0) {
|
|
3961
4446
|
held.upcomingInvoice = initialData.upcomingInvoice;
|
|
3962
4447
|
}
|
|
3963
|
-
if (
|
|
4448
|
+
if (initialData.paymentMethods !== void 0) {
|
|
4449
|
+
held.paymentMethods = initialData.paymentMethods;
|
|
4450
|
+
}
|
|
4451
|
+
if (held.invoices !== void 0 || held.upcomingInvoice !== void 0 || held.paymentMethods !== void 0) {
|
|
3964
4452
|
this._held = held;
|
|
3965
4453
|
this._settleSeed(claimFrom(options.session) ?? claimOf(this._client));
|
|
3966
4454
|
}
|
|
@@ -3968,6 +4456,7 @@ var BillingStore = class {
|
|
|
3968
4456
|
_client;
|
|
3969
4457
|
invoices;
|
|
3970
4458
|
upcomingInvoice;
|
|
4459
|
+
paymentMethods;
|
|
3971
4460
|
_pageSize;
|
|
3972
4461
|
_unsubscribe;
|
|
3973
4462
|
_connected = false;
|
|
@@ -4043,6 +4532,9 @@ var BillingStore = class {
|
|
|
4043
4532
|
if (held.upcomingInvoice !== void 0) {
|
|
4044
4533
|
this.upcomingInvoice.seed(SINGLETON, held.upcomingInvoice);
|
|
4045
4534
|
}
|
|
4535
|
+
if (held.paymentMethods !== void 0) {
|
|
4536
|
+
this.paymentMethods.seed(SINGLETON, held.paymentMethods);
|
|
4537
|
+
}
|
|
4046
4538
|
this._seedKey = held.key;
|
|
4047
4539
|
this._seeded = true;
|
|
4048
4540
|
}
|
|
@@ -4104,9 +4596,46 @@ var BillingStore = class {
|
|
|
4104
4596
|
};
|
|
4105
4597
|
});
|
|
4106
4598
|
}
|
|
4599
|
+
/**
|
|
4600
|
+
* Makes the payment method `externalId` the company's default, then
|
|
4601
|
+
* reloads the list so it says so. Rejects with the client's error when
|
|
4602
|
+
* the write fails; a reload that fails afterwards lands on the list's
|
|
4603
|
+
* `error`, since the write itself went through.
|
|
4604
|
+
*/
|
|
4605
|
+
async setDefaultPaymentMethod(externalId) {
|
|
4606
|
+
await this._client.updatePaymentMethod(externalId);
|
|
4607
|
+
await this._reloadPaymentMethods();
|
|
4608
|
+
}
|
|
4609
|
+
/** Removes the payment method `id`, then reloads the list. Rejects as `setDefaultPaymentMethod` does. */
|
|
4610
|
+
async removePaymentMethod(id) {
|
|
4611
|
+
await this._client.deletePaymentMethod(id);
|
|
4612
|
+
await this._reloadPaymentMethods();
|
|
4613
|
+
}
|
|
4614
|
+
/**
|
|
4615
|
+
* Mints a setup intent for adding a payment method. Nothing in the store
|
|
4616
|
+
* changes until the provider confirms it and the host reloads the list,
|
|
4617
|
+
* so this is a pass-through to the client.
|
|
4618
|
+
*/
|
|
4619
|
+
createSetupIntent() {
|
|
4620
|
+
return this._client.createSetupIntent();
|
|
4621
|
+
}
|
|
4107
4622
|
dispose() {
|
|
4108
4623
|
this._unsubscribe?.();
|
|
4109
4624
|
}
|
|
4625
|
+
/**
|
|
4626
|
+
* After a write. A list nobody has read is left alone: it loads fresh
|
|
4627
|
+
* when someone does. One that is loaded, or subscribed and waiting on a
|
|
4628
|
+
* failed load, is fetched again; `refetch` never rejects.
|
|
4629
|
+
*/
|
|
4630
|
+
async _reloadPaymentMethods() {
|
|
4631
|
+
if (!this.paymentMethods.has(SINGLETON)) {
|
|
4632
|
+
return;
|
|
4633
|
+
}
|
|
4634
|
+
const resource = this.paymentMethods.get(SINGLETON);
|
|
4635
|
+
if (resource.snapshot.data !== void 0 || resource.subscriberCount > 0) {
|
|
4636
|
+
await resource.refetch();
|
|
4637
|
+
}
|
|
4638
|
+
}
|
|
4110
4639
|
/**
|
|
4111
4640
|
* Re-reads the window already loaded, in as many requests as the API's
|
|
4112
4641
|
* page cap needs. A window paged past that cap still comes back whole:
|
|
@@ -4146,7 +4675,8 @@ var BillingStore = class {
|
|
|
4146
4675
|
};
|
|
4147
4676
|
var RESOURCE_NAMES = [
|
|
4148
4677
|
"invoices",
|
|
4149
|
-
"upcomingInvoice"
|
|
4678
|
+
"upcomingInvoice",
|
|
4679
|
+
"paymentMethods"
|
|
4150
4680
|
];
|
|
4151
4681
|
|
|
4152
4682
|
// src/billing/context.tsx
|
|
@@ -4196,6 +4726,25 @@ var BillingDataContext = createContext2(
|
|
|
4196
4726
|
);
|
|
4197
4727
|
var MISSING_BILLING_SOURCE_MESSAGE = "Schematic billing hooks need a SchematicProvider with a session, billingClient, or initialData, or a BillingDataProvider.";
|
|
4198
4728
|
var missingSourceError = new Error(MISSING_BILLING_SOURCE_MESSAGE);
|
|
4729
|
+
var BILLING_ACTION_UNAVAILABLE_MESSAGE = (name) => `Schematic billing action ${name} is not available: the provider only reads. Writes need a SchematicProvider with a session or billingClient, or a BillingDataProvider given \`actions\`.`;
|
|
4730
|
+
var ACTION_NAMES = [
|
|
4731
|
+
"setDefaultPaymentMethod",
|
|
4732
|
+
"removePaymentMethod",
|
|
4733
|
+
"createSetupIntent"
|
|
4734
|
+
];
|
|
4735
|
+
function rejectingActions(reason, given = {}) {
|
|
4736
|
+
const actions = {};
|
|
4737
|
+
for (const name of ACTION_NAMES) {
|
|
4738
|
+
actions[name] = given[name] ?? (() => Promise.reject(reason(name)));
|
|
4739
|
+
}
|
|
4740
|
+
return actions;
|
|
4741
|
+
}
|
|
4742
|
+
var unavailableActions = rejectingActions(
|
|
4743
|
+
(name) => new Error(BILLING_ACTION_UNAVAILABLE_MESSAGE(name))
|
|
4744
|
+
);
|
|
4745
|
+
function actionsOf(source) {
|
|
4746
|
+
return source.actions ?? unavailableActions;
|
|
4747
|
+
}
|
|
4199
4748
|
var missingHandle = {
|
|
4200
4749
|
data: void 0,
|
|
4201
4750
|
error: missingSourceError,
|
|
@@ -4209,12 +4758,16 @@ var missingBillingSource = {
|
|
|
4209
4758
|
handle: () => missingHandle,
|
|
4210
4759
|
loadMoreInvoices: () => Promise.resolve(),
|
|
4211
4760
|
invalidateAll: () => {
|
|
4212
|
-
}
|
|
4761
|
+
},
|
|
4762
|
+
// The same error a read reports, so a write outside any provider names
|
|
4763
|
+
// the misconfiguration rather than a source that only reads.
|
|
4764
|
+
actions: rejectingActions(() => missingSourceError)
|
|
4213
4765
|
};
|
|
4214
4766
|
function useBillingDataSource() {
|
|
4215
4767
|
return useContext2(BillingDataContext) ?? missingBillingSource;
|
|
4216
4768
|
}
|
|
4217
4769
|
function BillingDataProvider({
|
|
4770
|
+
actions,
|
|
4218
4771
|
children,
|
|
4219
4772
|
data,
|
|
4220
4773
|
locale,
|
|
@@ -4228,6 +4781,10 @@ function BillingDataProvider({
|
|
|
4228
4781
|
const source = useMemo2(() => {
|
|
4229
4782
|
const handles = /* @__PURE__ */ new Map();
|
|
4230
4783
|
return {
|
|
4784
|
+
actions: rejectingActions(
|
|
4785
|
+
(name) => new Error(BILLING_ACTION_UNAVAILABLE_MESSAGE(name)),
|
|
4786
|
+
actions
|
|
4787
|
+
),
|
|
4231
4788
|
subscribe: () => () => {
|
|
4232
4789
|
},
|
|
4233
4790
|
handle: (name) => {
|
|
@@ -4253,7 +4810,7 @@ function BillingDataProvider({
|
|
|
4253
4810
|
invalidateAll: () => {
|
|
4254
4811
|
}
|
|
4255
4812
|
};
|
|
4256
|
-
}, [data, onLoadMoreInvoices, onRefetch, status]);
|
|
4813
|
+
}, [actions, data, onLoadMoreInvoices, onRefetch, status]);
|
|
4257
4814
|
return /* @__PURE__ */ jsx2(BillingDataContext.Provider, { value: source, children: /* @__PURE__ */ jsx2(
|
|
4258
4815
|
SchematicI18nProvider,
|
|
4259
4816
|
{
|
|
@@ -4267,7 +4824,13 @@ function BillingDataProvider({
|
|
|
4267
4824
|
}
|
|
4268
4825
|
|
|
4269
4826
|
// src/billing/hooks.ts
|
|
4270
|
-
import {
|
|
4827
|
+
import {
|
|
4828
|
+
useCallback,
|
|
4829
|
+
useMemo as useMemo3,
|
|
4830
|
+
useRef,
|
|
4831
|
+
useState,
|
|
4832
|
+
useSyncExternalStore
|
|
4833
|
+
} from "react";
|
|
4271
4834
|
function useStableParams(params) {
|
|
4272
4835
|
const key = hashKey(params);
|
|
4273
4836
|
const ref = useRef({ key, params });
|
|
@@ -4301,6 +4864,48 @@ function useInvoices(query = DEFAULT_INVOICE_QUERY) {
|
|
|
4301
4864
|
function useUpcomingInvoice() {
|
|
4302
4865
|
return useBillingResource("upcomingInvoice", SINGLETON);
|
|
4303
4866
|
}
|
|
4867
|
+
var IDLE = { inflight: 0, error: void 0 };
|
|
4868
|
+
function usePaymentMethods() {
|
|
4869
|
+
const source = useBillingDataSource();
|
|
4870
|
+
const handle = useBillingResource("paymentMethods", SINGLETON);
|
|
4871
|
+
const [mutation, setMutation] = useState(IDLE);
|
|
4872
|
+
const run = useCallback(async (write) => {
|
|
4873
|
+
setMutation((m) => ({ inflight: m.inflight + 1, error: void 0 }));
|
|
4874
|
+
try {
|
|
4875
|
+
await write();
|
|
4876
|
+
} catch (cause) {
|
|
4877
|
+
const error = cause instanceof Error ? cause : new Error(String(cause));
|
|
4878
|
+
setMutation((m) => ({ inflight: m.inflight - 1, error }));
|
|
4879
|
+
throw error;
|
|
4880
|
+
}
|
|
4881
|
+
setMutation((m) => ({ inflight: m.inflight - 1, error: void 0 }));
|
|
4882
|
+
}, []);
|
|
4883
|
+
const setDefault = useCallback(
|
|
4884
|
+
(externalId) => run(() => actionsOf(source).setDefaultPaymentMethod(externalId)),
|
|
4885
|
+
[run, source]
|
|
4886
|
+
);
|
|
4887
|
+
const remove = useCallback(
|
|
4888
|
+
(id) => run(() => actionsOf(source).removePaymentMethod(id)),
|
|
4889
|
+
[run, source]
|
|
4890
|
+
);
|
|
4891
|
+
return useMemo3(
|
|
4892
|
+
() => ({
|
|
4893
|
+
...handle,
|
|
4894
|
+
setDefault,
|
|
4895
|
+
remove,
|
|
4896
|
+
isMutating: mutation.inflight > 0,
|
|
4897
|
+
mutationError: mutation.error
|
|
4898
|
+
}),
|
|
4899
|
+
[handle, mutation, remove, setDefault]
|
|
4900
|
+
);
|
|
4901
|
+
}
|
|
4902
|
+
function useSetupIntent() {
|
|
4903
|
+
const source = useBillingDataSource();
|
|
4904
|
+
return useMemo3(
|
|
4905
|
+
() => ({ create: () => actionsOf(source).createSetupIntent() }),
|
|
4906
|
+
[source]
|
|
4907
|
+
);
|
|
4908
|
+
}
|
|
4304
4909
|
function useInvalidateBillingData() {
|
|
4305
4910
|
return useBillingDataSource().invalidateAll;
|
|
4306
4911
|
}
|
|
@@ -4374,7 +4979,12 @@ function BillingProvider({
|
|
|
4374
4979
|
subscribe: (name, params, listener) => store.resource(name).subscribe(params, listener),
|
|
4375
4980
|
handle,
|
|
4376
4981
|
loadMoreInvoices: (query) => store.loadMoreInvoices(query),
|
|
4377
|
-
invalidateAll: () => store.invalidateAll()
|
|
4982
|
+
invalidateAll: () => store.invalidateAll(),
|
|
4983
|
+
actions: {
|
|
4984
|
+
setDefaultPaymentMethod: (externalId) => store.setDefaultPaymentMethod(externalId),
|
|
4985
|
+
removePaymentMethod: (id) => store.removePaymentMethod(id),
|
|
4986
|
+
createSetupIntent: () => store.createSetupIntent()
|
|
4987
|
+
}
|
|
4378
4988
|
};
|
|
4379
4989
|
}, [store]);
|
|
4380
4990
|
const localized = /* @__PURE__ */ jsx3(
|
|
@@ -4420,7 +5030,7 @@ function staticSource(data) {
|
|
|
4420
5030
|
}
|
|
4421
5031
|
|
|
4422
5032
|
// src/version.ts
|
|
4423
|
-
var version2 = "1.
|
|
5033
|
+
var version2 = "1.9.0";
|
|
4424
5034
|
|
|
4425
5035
|
// src/context/schematic.tsx
|
|
4426
5036
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
@@ -4655,6 +5265,7 @@ export {
|
|
|
4655
5265
|
useBillingDataSource,
|
|
4656
5266
|
useInvalidateBillingData,
|
|
4657
5267
|
useInvoices,
|
|
5268
|
+
usePaymentMethods,
|
|
4658
5269
|
useSchematic,
|
|
4659
5270
|
useSchematicContext,
|
|
4660
5271
|
useSchematicCreditBalance,
|
|
@@ -4667,6 +5278,7 @@ export {
|
|
|
4667
5278
|
useSchematicPlan,
|
|
4668
5279
|
useSchematicStrings,
|
|
4669
5280
|
useSchematicTranslate,
|
|
5281
|
+
useSetupIntent,
|
|
4670
5282
|
useUpcomingInvoice
|
|
4671
5283
|
};
|
|
4672
5284
|
/*! Bundled license information:
|