mantur-components 0.1.12 → 0.1.13-beta.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 +12 -5
- package/dist/api.d.ts +4 -0
- package/dist/header/ManturHeader.d.ts +1 -1
- package/dist/header/components/StripePaymentModal.d.ts +1 -1
- package/dist/header/mock.d.ts +0 -15
- package/dist/index.d.ts +4 -4
- package/dist/mantur-components.js +1198 -964
- package/dist/mantur-components.umd.cjs +3 -3
- package/dist/types.d.ts +5 -0
- package/dist/utils/stripe-payment-window.d.ts +8 -2
- package/dist/utils/url.d.ts +4 -0
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -81,6 +81,7 @@ interface ManturHeaderProps {
|
|
|
81
81
|
onTenantContextChange?: (detail: ManturTenantContextDetail) => void;
|
|
82
82
|
rechargePaymentMethod?: "card" | "alipay" | "wechat_pay";
|
|
83
83
|
stripePublishableKey?: string;
|
|
84
|
+
stripePaymentWindowFeatures?: string;
|
|
84
85
|
}
|
|
85
86
|
```
|
|
86
87
|
|
|
@@ -96,7 +97,9 @@ interface ManturHeaderProps {
|
|
|
96
97
|
|
|
97
98
|
`rechargePaymentMethod`:兼容旧版本的支付方式参数。当前充值创建订单不再主动提交支付方式,支付方式由 Stripe Checkout Session 内部选择。
|
|
98
99
|
|
|
99
|
-
`stripePublishableKey`:Stripe publishable key。订单返回 Checkout Session
|
|
100
|
+
`stripePublishableKey`:Stripe publishable key。订单返回 Checkout Session `clientSecret`(字段名为 `clientSecret`,值以 `cs_` 开头)时,组件库会在自己的支付弹窗中挂载 Stripe Checkout Elements。
|
|
101
|
+
|
|
102
|
+
`stripePaymentWindowFeatures`:兼容旧版本的窗口配置参数。当前支付不再打开新窗口,不读取该参数。
|
|
100
103
|
|
|
101
104
|
### 用户类型
|
|
102
105
|
|
|
@@ -138,6 +141,7 @@ window.__MANTUR_COMPONENTS_STRIPE_PUBLISHABLE_KEY__ = "pk_test_xxx";
|
|
|
138
141
|
|
|
139
142
|
```ts
|
|
140
143
|
import {
|
|
144
|
+
cancelManturRechargeOrder,
|
|
141
145
|
createManturRechargeOrder,
|
|
142
146
|
getManturBillingAccount,
|
|
143
147
|
getManturBillingLedger,
|
|
@@ -145,16 +149,19 @@ import {
|
|
|
145
149
|
getManturPricingChargePoint,
|
|
146
150
|
getManturPricingChargePoints,
|
|
147
151
|
getManturRechargeOrder,
|
|
148
|
-
postManturStripePaymentWindowMessage,
|
|
149
152
|
MANTUR_RECHARGE_ORDER_CREATED_EVENT,
|
|
150
153
|
} from "mantur-components";
|
|
151
154
|
```
|
|
152
155
|
|
|
153
|
-
充值面板打开时会调用 `getManturBillingPackages()` 拉取 `/billing/packages`;点击支付时会调用 `createManturRechargeOrder()` 创建 `/billing/recharge/orders
|
|
156
|
+
充值面板打开时会调用 `getManturBillingPackages()` 拉取 `/billing/packages`;点击支付时会调用 `createManturRechargeOrder()` 创建 `/billing/recharge/orders`,请求体传 `packageId` 或 `customAmount`,并固定传 `uiMode: "elements"`。请求体还会补齐 `app` 和 `redirect`:`app` 取 `window.__MANTUR_APP_NAME__` 或 `VITE_APP_NAME`;本地开发若没有这些配置,会用当前端口兜底识别应用(`:82` creative-agent、`:83` production-agent、`:81` traffic-engine、`:84` distribution-matrix)。`redirect` 与路由拦截器一致,只取当前页面的 `pathname + search + hash`,不拼接协议、域名或开发端口。订单创建成功后会触发浏览器事件 `mantur-recharge-order-created`,`detail` 为后端返回的订单信息。
|
|
157
|
+
|
|
158
|
+
积分明细弹窗打开后会调用 `getManturBillingLedger()` 拉取 `/billing/accounts/me/ledger`,并根据“获得/消耗”、来源和日期范围筛选传递 `directions`、`bizTypes`、`fromTime`、`toTime`,分页总数使用接口返回的 `total`。
|
|
159
|
+
|
|
160
|
+
后端按 Stripe Checkout Elements 要求返回 `clientSecret` 后,`ManturHeader` 会在支付弹窗中挂载 `CheckoutElementsProvider`、`ContactDetailsElement` 和 `PaymentElement`,提交时调用 `checkout.confirm({ redirect: "if_required" })`。后端创建 Checkout Session 时必须使用 `ui_mode="elements"` 或 `ui_mode="custom"`;如果仍创建 `ui_mode="embedded"` 的 Session,Stripe 会拒绝 `initCheckoutElementsSdk`。支付成功后组件库会关闭支付弹窗并刷新积分;用户主动关闭支付弹窗时会先调用 `cancelManturRechargeOrder()` 请求 `/billing/recharge/orders/{orderNo}/cancel`,然后再关闭弹窗。组件库仍兼容旧字段名 `stripeClientSecret`,但优先读取 `clientSecret`。
|
|
154
161
|
|
|
155
|
-
|
|
162
|
+
如果支付方式需要跳出授权,后端的 Stripe return_url 会回到 `front-main` 的 `/pay-callback?app=...&redirect=...`,`pay-callback` 会读取这两个参数并跳回原应用的 `redirect` 路由。
|
|
156
163
|
|
|
157
|
-
|
|
164
|
+
`postManturStripePaymentWindowMessage()`、`resolveManturStripePaymentPageUrl()` 和 `resolveManturRechargePaymentPageUrl()` 对外导出,用于 `front-main` 支付页和其它宿主复用同一套支付窗口消息协议。
|
|
158
165
|
|
|
159
166
|
## 团队上下文同步
|
|
160
167
|
|
package/dist/api.d.ts
CHANGED
|
@@ -19,6 +19,9 @@ export interface ManturCreateRechargeOrderRequest {
|
|
|
19
19
|
packageId?: string;
|
|
20
20
|
customAmount?: number;
|
|
21
21
|
paymentMethod?: ManturPaymentMethod;
|
|
22
|
+
uiMode?: "custom" | "elements" | "embedded";
|
|
23
|
+
app?: string;
|
|
24
|
+
redirect?: string;
|
|
22
25
|
}
|
|
23
26
|
export interface ManturCreateRechargeOrderResponse {
|
|
24
27
|
orderNo?: string;
|
|
@@ -128,6 +131,7 @@ export declare function refreshManturUserPoints(): Promise<ManturUserPoints>;
|
|
|
128
131
|
export declare function getManturBillingPackages(): Promise<ManturBillingPackageDTO[]>;
|
|
129
132
|
export declare function createManturRechargeOrder(requestBody: ManturCreateRechargeOrderRequest): Promise<ManturCreateRechargeOrderResponse | undefined>;
|
|
130
133
|
export declare function getManturRechargeOrder(orderNo: string): Promise<ManturRechargeOrderDTO | undefined>;
|
|
134
|
+
export declare function cancelManturRechargeOrder(orderNo: string): Promise<null | undefined>;
|
|
131
135
|
export declare function getManturPricingChargePoints(): Promise<ManturChargePointWithModelsDTO[]>;
|
|
132
136
|
export declare function getManturPricingChargePoint(chargePointId: string): Promise<ManturChargePointWithModelsDTO | undefined>;
|
|
133
137
|
export declare function getManturBillingAccount(): Promise<ManturBillingAccountDTO | undefined>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ManturHeaderProps } from "../types";
|
|
2
|
-
export declare function ManturHeader({ user, disabled, brandSlot, children, onTenantContextChange, stripePublishableKey,
|
|
2
|
+
export declare function ManturHeader({ user, disabled, brandSlot, children, onTenantContextChange, stripePublishableKey, }: ManturHeaderProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/header/mock.d.ts
CHANGED
|
@@ -19,18 +19,3 @@ export interface CustomRechargePackage {
|
|
|
19
19
|
}
|
|
20
20
|
export type RechargePackage = FixedRechargePackage | CustomRechargePackage;
|
|
21
21
|
export type RechargePackageId = FixedRechargePackage["id"] | CustomRechargePackage["id"];
|
|
22
|
-
export type PointsLedgerType = "all" | "income" | "expense";
|
|
23
|
-
export type PointsLedgerSource = "all" | "recharge" | "gift";
|
|
24
|
-
export type PointsLedgerBadgeKind = "recharge" | "gift" | "deducted" | "expired";
|
|
25
|
-
export interface PointsLedgerRecord {
|
|
26
|
-
id: string;
|
|
27
|
-
type: Exclude<PointsLedgerType, "all">;
|
|
28
|
-
source?: Exclude<PointsLedgerSource, "all">;
|
|
29
|
-
name: string;
|
|
30
|
-
meta: string;
|
|
31
|
-
date: string;
|
|
32
|
-
amount: number;
|
|
33
|
-
badgeKind: PointsLedgerBadgeKind;
|
|
34
|
-
badgeText: string;
|
|
35
|
-
}
|
|
36
|
-
export declare const MOCK_POINTS_LEDGER: PointsLedgerRecord[];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { ManturHeader } from "./header";
|
|
2
|
-
export { createManturRechargeOrder, getManturBillingAccount, getManturBillingLedger, getManturBillingPackages, getManturPricingChargePoint, getManturPricingChargePoints, getManturRechargeOrder, MANTUR_POINTS_REFRESH_EVENT, MANTUR_RECHARGE_ORDER_CREATED_EVENT, MANTUR_TENANT_CONTEXT_CHANGE_EVENT, refreshManturUserPoints, refreshManturTenantContext, } from "./api";
|
|
2
|
+
export { cancelManturRechargeOrder, createManturRechargeOrder, getManturBillingAccount, getManturBillingLedger, getManturBillingPackages, getManturPricingChargePoint, getManturPricingChargePoints, getManturRechargeOrder, MANTUR_POINTS_REFRESH_EVENT, MANTUR_RECHARGE_ORDER_CREATED_EVENT, MANTUR_TENANT_CONTEXT_CHANGE_EVENT, refreshManturUserPoints, refreshManturTenantContext, } from "./api";
|
|
3
3
|
export type { ManturBillingAccountDTO, ManturBillingPackageDTO, ManturChargePointWithModelsDTO, ManturCreateRechargeOrderRequest, ManturCreateRechargeOrderResponse, ManturLedgerEntryDTO, ManturLedgerQuery, ManturModelRuleDTO, ManturPageResult, ManturRechargeOrderDTO, } from "./api";
|
|
4
4
|
export { formatDateByLang } from "./utils/date";
|
|
5
5
|
export type { ManturDateFormatType, ManturDateInput } from "./utils/date";
|
|
6
|
-
export { redirectToManturMain } from "./utils/url";
|
|
6
|
+
export { getManturRechargeRedirectContext, redirectToManturMain } from "./utils/url";
|
|
7
7
|
export type { ManturMainRedirectOptions } from "./utils/url";
|
|
8
|
-
export { isManturStripePaymentWindowMessage, MANTUR_STRIPE_PAYMENT_ROUTE, MANTUR_STRIPE_PAYMENT_WINDOW_MESSAGE_TYPE, postManturStripePaymentWindowMessage, resolveManturStripePaymentPageUrl, } from "./utils/stripe-payment-window";
|
|
9
|
-
export type { ManturStripePaymentWindowAction, ManturStripePaymentWindowMessage, } from "./utils/stripe-payment-window";
|
|
8
|
+
export { isManturStripePaymentWindowMessage, MANTUR_STRIPE_PAYMENT_ROUTE, MANTUR_STRIPE_PAYMENT_WINDOW_MESSAGE_TYPE, postManturStripePaymentWindowMessage, resolveManturRechargePaymentPageUrl, resolveManturStripePaymentPageUrl, } from "./utils/stripe-payment-window";
|
|
9
|
+
export type { ManturStripePaymentPageUrlOptions, ManturStripePaymentWindowAction, ManturStripePaymentWindowMessage, } from "./utils/stripe-payment-window";
|
|
10
10
|
export type { ManturHeaderLabels, ManturHeaderProps, ManturHeaderUser, ManturPaymentMethod, ManturProfileValues, ManturRole, ManturTenant, ManturTenantAuthContext, ManturTenantContextDetail, ManturUserPoints, } from "./types";
|