@leaflow/sdk 0.0.0-dev.200.g306375c → 0.0.0-dev.204.g3e92709

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.
@@ -43,6 +43,8 @@ export type UpdateBillingAccountResult = operations["update-billing-account"]["r
43
43
  export type UpdateBillingAccountBody = NonNullable<operations["update-billing-account"]["requestBody"]>["content"]["application/json"];
44
44
  /** The success response body of `GET /account/v1/billing-accounts/{accountId}/balance`. */
45
45
  export type GetAccountBalanceResult = operations["get-account-balance"]["responses"][200]["content"]["application/json"];
46
+ /** The success response body of `GET /account/v1/billing-accounts/{accountId}/payment-options`. */
47
+ export type ListPaymentOptionsResult = operations["list-payment-options"]["responses"][200]["content"]["application/json"];
46
48
  /** The success response body of `GET /account/v1/projects`. */
47
49
  export type ListBillingAccountProjectsResult = operations["list-billing-account-projects"]["responses"][200]["content"]["application/json"];
48
50
  /** The query parameters of `GET /account/v1/projects`. */
@@ -61,6 +63,8 @@ export type CreateTopUpResult = operations["create-top-up"]["responses"][201]["c
61
63
  export type CreateTopUpBody = NonNullable<operations["create-top-up"]["requestBody"]>["content"]["application/json"];
62
64
  /** The success response body of `GET /account/v1/top-ups/{topUpId}`. */
63
65
  export type GetTopUpResult = operations["get-top-up"]["responses"][200]["content"]["application/json"];
66
+ /** The success response body of `POST /account/v1/top-ups/{topUpId}/cancel`. */
67
+ export type CancelTopUpResult = operations["cancel-top-up"]["responses"][200]["content"]["application/json"];
64
68
  /** The success response body of `GET /account/v1/payment-methods`. */
65
69
  export type ListPaymentMethodsResult = operations["list-payment-methods"]["responses"][200]["content"]["application/json"];
66
70
  /** The success response body of `POST /account/v1/payment-methods/setup`. */
@@ -296,6 +296,31 @@ export interface paths {
296
296
  patch?: never;
297
297
  trace?: never;
298
298
  };
299
+ "/account/v1/billing-accounts/{accountId}/payment-options": {
300
+ parameters: {
301
+ query?: never;
302
+ header?: never;
303
+ path: {
304
+ accountId: components["parameters"]["AccountId"];
305
+ };
306
+ cookie?: never;
307
+ };
308
+ /**
309
+ * List payment options
310
+ * @description Lists the payment gateways and methods that currently accept payment in this account's currency, the
311
+ * preferred gateway first. Top-ups and invoice payments must name a gateway and method listed here;
312
+ * others are refused. An empty list means no online payment is available for this account. Not paged: the
313
+ * set is a few rows.
314
+ */
315
+ get: operations["list-payment-options"];
316
+ put?: never;
317
+ post?: never;
318
+ delete?: never;
319
+ options?: never;
320
+ head?: never;
321
+ patch?: never;
322
+ trace?: never;
323
+ };
299
324
  "/account/v1/projects": {
300
325
  parameters: {
301
326
  query?: never;
@@ -370,7 +395,8 @@ export interface paths {
370
395
  };
371
396
  /**
372
397
  * List top ups
373
- * @description Lists only the authenticated user's top-ups. Includes pending and failed attempts; no invoice is created for a top-up.
398
+ * @description Lists only the authenticated user's top-ups. Includes pending, failed and canceled attempts; no invoice is
399
+ * created for a top-up. Items carry no `action`; read a pending top-up with get-top-up to continue its payment.
374
400
  */
375
401
  get: operations["list-top-ups"];
376
402
  put?: never;
@@ -398,7 +424,12 @@ export interface paths {
398
424
  };
399
425
  /**
400
426
  * Get top up
401
- * @description Reads a top-up owned by the authenticated user, including its outcome and the part of it not yet spent. It is not an invoice.
427
+ * @description Reads a top-up owned by the authenticated user, including its outcome and the part of it not yet spent.
428
+ * It is not an invoice.
429
+ *
430
+ * While the top-up is pending, the answer includes the customer's next step as the payment gateway
431
+ * currently reports it, so that a payment interrupted by a closed page can be continued. When the gateway
432
+ * cannot be reached, the top-up is returned without `action`; read it again later.
402
433
  */
403
434
  get: operations["get-top-up"];
404
435
  put?: never;
@@ -409,6 +440,38 @@ export interface paths {
409
440
  patch?: never;
410
441
  trace?: never;
411
442
  };
443
+ "/account/v1/top-ups/{topUpId}/cancel": {
444
+ parameters: {
445
+ query?: never;
446
+ header?: never;
447
+ path: {
448
+ topUpId: string;
449
+ };
450
+ cookie?: never;
451
+ };
452
+ get?: never;
453
+ put?: never;
454
+ /**
455
+ * Cancel top up
456
+ * @description Withdraws a pending top-up owned by the authenticated user at the payment gateway. It becomes
457
+ * `canceled` with `cancellation_reason` `requested_by_customer`, and no money is collected for it. Canceling a
458
+ * top-up that is already canceled returns it unchanged.
459
+ *
460
+ * If the gateway has already collected the payment, nothing is withdrawn and the top-up is returned
461
+ * as `succeeded` with the balance increased. Check `status` in the answer rather than assuming the
462
+ * cancellation took effect.
463
+ *
464
+ * Fails with 409 and BILLING_TOPUP_NOT_CANCELABLE when the top-up has already succeeded or failed,
465
+ * with `status` naming that outcome, and while the gateway is processing the payment and can no
466
+ * longer withdraw it, with `status` set to `pending`; read the top-up again later in that case.
467
+ */
468
+ post: operations["cancel-top-up"];
469
+ delete?: never;
470
+ options?: never;
471
+ head?: never;
472
+ patch?: never;
473
+ trace?: never;
474
+ };
412
475
  "/account/v1/payment-methods": {
413
476
  parameters: {
414
477
  query?: never;
@@ -1396,6 +1459,12 @@ export interface components {
1396
1459
  * credits balance does not imply that due is zero.
1397
1460
  */
1398
1461
  credits: components["schemas"]["Money"];
1462
+ /**
1463
+ * @description balance plus credits, the sum shown as the account's funds. Credits count at their recorded remaining
1464
+ * amount, including restricted grants that only pay for what they allow, so total is an upper bound of what
1465
+ * the account can pay with rather than a withdrawable amount. due is reported separately and is not subtracted.
1466
+ */
1467
+ total: components["schemas"]["Money"];
1399
1468
  /**
1400
1469
  * @description Currently valid, unspent credit grouped by permitted use. Restrictions and
1401
1470
  * validity dates determine which charges a group can cover, so these groups are not a general
@@ -1451,13 +1520,19 @@ export interface components {
1451
1520
  */
1452
1521
  remaining_amount?: components["schemas"]["Money"];
1453
1522
  /**
1454
- * @description `pending` until the payment gateway confirms. The balance increases on `succeeded`.
1523
+ * @description `pending` until the payment gateway reaches a result. The balance increases on `succeeded`.
1455
1524
  *
1456
- * Unknown channel outcomes remain pending. Failed means the channel has confirmed that
1457
- * this attempt did not collect money; a browser redirect is not proof of payment.
1525
+ * `failed` means the gateway declined the payment. `canceled` means the attempt was withdrawn
1526
+ * without collecting money; `cancellation_reason` says why. Unknown gateway outcomes remain
1527
+ * `pending`, and a browser redirect is not proof of payment.
1528
+ *
1529
+ * `failed` and `canceled` are final. If the gateway nevertheless collects payment for such an
1530
+ * attempt, the amount is credited as a separate `succeeded` top-up.
1458
1531
  * @enum {string}
1459
1532
  */
1460
- status: "pending" | "succeeded" | "failed";
1533
+ status: "pending" | "succeeded" | "failed" | "canceled";
1534
+ /** @description Why the top-up was withdrawn. Present with `canceled`. */
1535
+ cancellation_reason?: components["schemas"]["PaymentCancellationReason"];
1461
1536
  /** @description Which payment gateway collected it. */
1462
1537
  payment_gateway?: string;
1463
1538
  /** @description The selected payment method, such as card, wechat_pay or alipay. */
@@ -1472,9 +1547,13 @@ export interface components {
1472
1547
  * the figure that appears on the customer's card or wallet statement.
1473
1548
  */
1474
1549
  presentment_amount?: components["schemas"]["Money"];
1475
- /** @description Why it did not go through. Present with `failed`. */
1550
+ /** @description Why the gateway declined it. Present with `failed`. */
1476
1551
  failure_reason?: string;
1477
- /** @description Present when the original top-up still needs customer interaction. Completing it does not replace confirmation of receipt. */
1552
+ /**
1553
+ * @description The customer's next step while the top-up is `pending` and the gateway still awaits them. Returned
1554
+ * by create-top-up and get-top-up as the gateway currently reports it; absent from list-top-ups and
1555
+ * once the top-up has a result. Completing it does not replace confirmation of receipt.
1556
+ */
1478
1557
  action?: components["schemas"]["PaymentAction"];
1479
1558
  /** Format: date-time */
1480
1559
  created_at: string;
@@ -1528,6 +1607,30 @@ export interface components {
1528
1607
  /** Format: int64 */
1529
1608
  total_count?: number;
1530
1609
  };
1610
+ /**
1611
+ * @description Why a gateway payment was withdrawn. `abandoned` means the customer did not complete it within the time
1612
+ * allowed for payment. `requested_by_customer` means the customer canceled it.
1613
+ * @enum {string}
1614
+ */
1615
+ PaymentCancellationReason: "abandoned" | "requested_by_customer";
1616
+ /** @description A payment gateway that accepts payment in the account's currency, with the methods it accepts. */
1617
+ PaymentOption: {
1618
+ /** @description The value to send as `payment_gateway`. */
1619
+ payment_gateway: string;
1620
+ methods: components["schemas"]["PaymentOptionMethod"][];
1621
+ };
1622
+ PaymentOptionMethod: {
1623
+ /** @description The value to send as `method_type`, such as card, wechat_pay or alipay. */
1624
+ method_type: string;
1625
+ /**
1626
+ * @description Whether a method of this type can be saved with create-payment-method-setup and charged later
1627
+ * without the customer present. Methods that are not reusable are paid anew each time.
1628
+ */
1629
+ reusable: boolean;
1630
+ };
1631
+ PaymentOptionList: {
1632
+ items: components["schemas"]["PaymentOption"][];
1633
+ };
1531
1634
  PaymentMethod: {
1532
1635
  /** Format: uuid */
1533
1636
  id: string;
@@ -1797,10 +1900,18 @@ export interface components {
1797
1900
  credit_grant?: components["schemas"]["ObjectIdentity"];
1798
1901
  /** Format: uuid */
1799
1902
  refund_id?: string;
1800
- /** @enum {string} */
1801
- status?: "pending" | "succeeded" | "failed";
1903
+ /**
1904
+ * @description `failed` means the operation did not succeed; for a gateway payment, that the gateway declined it.
1905
+ * `canceled` means a gateway payment was withdrawn without collecting money; an invoice it was meant
1906
+ * to pay remains open for another payment.
1907
+ * @enum {string}
1908
+ */
1909
+ status?: "pending" | "succeeded" | "failed" | "canceled";
1910
+ /** @description Why the payment was withdrawn. Present with `canceled`. */
1911
+ cancellation_reason?: components["schemas"]["PaymentCancellationReason"];
1802
1912
  payment_gateway?: string;
1803
1913
  method_type?: string;
1914
+ /** @description Why it failed. Present with `failed`. */
1804
1915
  failure_reason?: string;
1805
1916
  /** Format: date-time */
1806
1917
  settled_at?: string;
@@ -3084,6 +3195,29 @@ export interface operations {
3084
3195
  default: components["responses"]["Error"];
3085
3196
  };
3086
3197
  };
3198
+ "list-payment-options": {
3199
+ parameters: {
3200
+ query?: never;
3201
+ header?: never;
3202
+ path: {
3203
+ accountId: components["parameters"]["AccountId"];
3204
+ };
3205
+ cookie?: never;
3206
+ };
3207
+ requestBody?: never;
3208
+ responses: {
3209
+ /** @description OK */
3210
+ 200: {
3211
+ headers: {
3212
+ [name: string]: unknown;
3213
+ };
3214
+ content: {
3215
+ "application/json": components["schemas"]["PaymentOptionList"];
3216
+ };
3217
+ };
3218
+ default: components["responses"]["Error"];
3219
+ };
3220
+ };
3087
3221
  "list-billing-account-projects": {
3088
3222
  parameters: {
3089
3223
  query?: {
@@ -3258,6 +3392,38 @@ export interface operations {
3258
3392
  default: components["responses"]["Error"];
3259
3393
  };
3260
3394
  };
3395
+ "cancel-top-up": {
3396
+ parameters: {
3397
+ query?: never;
3398
+ header?: never;
3399
+ path: {
3400
+ topUpId: string;
3401
+ };
3402
+ cookie?: never;
3403
+ };
3404
+ requestBody?: never;
3405
+ responses: {
3406
+ /** @description The top-up after the request, canceled or succeeded. */
3407
+ 200: {
3408
+ headers: {
3409
+ [name: string]: unknown;
3410
+ };
3411
+ content: {
3412
+ "application/json": components["schemas"]["TopUp"];
3413
+ };
3414
+ };
3415
+ /** @description The top-up already has another outcome or can no longer be withdrawn. */
3416
+ 409: {
3417
+ headers: {
3418
+ [name: string]: unknown;
3419
+ };
3420
+ content: {
3421
+ "application/json": components["schemas"]["Error"];
3422
+ };
3423
+ };
3424
+ default: components["responses"]["Error"];
3425
+ };
3426
+ };
3261
3427
  "list-payment-methods": {
3262
3428
  parameters: {
3263
3429
  query?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leaflow/sdk",
3
- "version": "0.0.0-dev.200.g306375c",
3
+ "version": "0.0.0-dev.204.g3e92709",
4
4
  "description": "Leaflow 平台 API 的 TypeScript SDK",
5
5
  "license": "MIT",
6
6
  "repository": {