@intercartx/booster-core 0.0.1-beta.3 → 0.0.1-beta.30
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 +379 -1
- package/dist/api/config/index.d.ts +2 -0
- package/dist/api/config/index.js +7 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/order/index.d.ts +1 -0
- package/dist/api/order/index.js +1 -0
- package/dist/api/order/quick.d.ts +12 -0
- package/dist/api/order/quick.js +4 -0
- package/dist/api/order/types.d.ts +4 -0
- package/dist/api/order/types.js +5 -0
- package/dist/api/types.d.ts +18 -14
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/models/business/CustomInfo.js +1 -1
- package/dist/models/business/ErrorTip.d.ts +9 -0
- package/dist/models/business/ErrorTip.js +27 -0
- package/dist/models/business/FullScreeenLoading.js +3 -0
- package/dist/models/business/OrderSummary.d.ts +4 -2
- package/dist/models/business/OrderSummary.js +67 -6
- package/dist/models/business/PaypalModal.d.ts +1 -0
- package/dist/models/business/PaypalModal.js +34 -3
- package/dist/models/business/address/Address.js +2 -0
- package/dist/models/business/address/AddressSuggestion.js +2 -2
- package/dist/models/business/address/MultiRegions.d.ts +1 -0
- package/dist/models/business/address/MultiRegions.js +5 -0
- package/dist/models/business/fees/ShippingMethods.js +2 -0
- package/dist/models/business/fees/Tips.d.ts +1 -0
- package/dist/models/business/fees/Tips.js +7 -1
- package/dist/models/business/index.d.ts +1 -0
- package/dist/models/business/index.js +1 -0
- package/dist/models/business/pay-button/ACHPaymentHandler.js +5 -4
- package/dist/models/business/pay-button/PPPaymentHandler.js +7 -2
- package/dist/models/business/pay-button/PayButton.d.ts +1 -0
- package/dist/models/business/pay-button/PayButton.js +55 -1
- package/dist/models/business/pay-button/cc-handler/DefaultCCPaymentHandler.d.ts +1 -0
- package/dist/models/business/pay-button/cc-handler/DefaultCCPaymentHandler.js +78 -4
- package/dist/models/business/pay-button/cc-handler/FxpCCPaymentHandler.js +3 -3
- package/dist/models/business/pay-button/cc-handler/StripeCCPaymentHandler.d.ts +2 -0
- package/dist/models/business/pay-button/cc-handler/StripeCCPaymentHandler.js +100 -42
- package/dist/models/business/payment/CCPayment.js +15 -10
- package/dist/models/business/payment/FxpCCPayment.js +15 -10
- package/dist/models/business/payment/StripeCCPayment.d.ts +1 -0
- package/dist/models/business/payment/StripeCCPayment.js +20 -11
- package/dist/report-event.d.ts +2 -0
- package/dist/report-event.js +12 -0
- package/dist/styles/address.css +1 -1
- package/dist/styles/button.css +7 -1
- package/dist/styles/checkout-page.css +1 -1
- package/dist/styles/custom-info.css +1 -1
- package/dist/styles/error-tip.css +1 -0
- package/dist/styles/fee.css +1 -1
- package/dist/styles/fxp-payment.css +1 -1
- package/dist/styles/global.css +1 -1
- package/dist/styles/input.css +1 -1
- package/dist/styles/loading.css +1 -1
- package/dist/styles/order-summary.css +1 -1
- package/dist/styles/payment.css +1 -1
- package/dist/styles/paypal-modal.css +1 -1
- package/dist/styles/phone-input.css +1 -1
- package/dist/styles/select-list.css +1 -1
- package/dist/styles/select.css +1 -1
- package/dist/styles/stripe-payment.css +1 -1
- package/dist/styles/theme.css +1 -1
- package/dist/types.d.ts +4 -2
- package/dist/types.js +2 -0
- package/dist/validate/phone.js +14 -5
- package/package.json +34 -11
package/README.md
CHANGED
|
@@ -1,2 +1,380 @@
|
|
|
1
|
+
# @intercartx/booster-core
|
|
1
2
|
|
|
2
|
-
|
|
3
|
+
核心功能库,提供结账系统的业务逻辑、数据模型、验证工具、API 接口和样式文件。这是一个框架无关的核心包,为上层 UI 组件库提供基础能力。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @intercartx/booster-core
|
|
9
|
+
# 或
|
|
10
|
+
pnpm add @intercartx/booster-core
|
|
11
|
+
# 或
|
|
12
|
+
yarn add @intercartx/booster-core
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 功能特性
|
|
16
|
+
|
|
17
|
+
### 🎯 核心功能
|
|
18
|
+
|
|
19
|
+
- **业务模型 (Models)**: 提供完整的结账业务逻辑模型
|
|
20
|
+
- 地址管理 (Address)
|
|
21
|
+
- 支付处理 (Payment)
|
|
22
|
+
- 订单摘要 (OrderSummary)
|
|
23
|
+
- 费用管理 (Fees Manager)
|
|
24
|
+
- 小费管理 (Tips)
|
|
25
|
+
- 运费管理 (Shipping Methods)
|
|
26
|
+
- 自定义信息 (Custom Info)
|
|
27
|
+
- 购买按钮 (Buy Now)
|
|
28
|
+
- PayPal 模态框 (PayPal Modal)
|
|
29
|
+
- 电话输入 (Phone)
|
|
30
|
+
|
|
31
|
+
- **数据验证 (Validation)**: 提供完整的表单验证功能
|
|
32
|
+
- 邮箱验证
|
|
33
|
+
- 电话验证
|
|
34
|
+
- 必填字段验证
|
|
35
|
+
- 国家/地区验证
|
|
36
|
+
- 邮政编码验证(支持多个国家)
|
|
37
|
+
- 州/省验证
|
|
38
|
+
|
|
39
|
+
- **工具函数 (Utils)**: 提供常用工具函数
|
|
40
|
+
- 货币格式化
|
|
41
|
+
- 电话号码处理
|
|
42
|
+
- Google Places API 集成
|
|
43
|
+
- 加密工具
|
|
44
|
+
- 防抖函数
|
|
45
|
+
- 重试机制
|
|
46
|
+
- 浏览器信息检测
|
|
47
|
+
- 追踪工具 (Tracksity)
|
|
48
|
+
|
|
49
|
+
- **API 接口**: 提供与后端交互的 API
|
|
50
|
+
- 配置获取
|
|
51
|
+
- 订单处理
|
|
52
|
+
- 支付处理(信用卡、ACH、PayPal)
|
|
53
|
+
- 订单确认
|
|
54
|
+
|
|
55
|
+
- **样式文件**: 提供完整的样式系统
|
|
56
|
+
- 全局样式
|
|
57
|
+
- 组件样式
|
|
58
|
+
- 主题配置
|
|
59
|
+
- 响应式设计
|
|
60
|
+
|
|
61
|
+
## 使用方式
|
|
62
|
+
|
|
63
|
+
### 基础导入
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import {
|
|
67
|
+
setGlobalConfig,
|
|
68
|
+
getGlobalConfig,
|
|
69
|
+
globalState,
|
|
70
|
+
CheckoutConfig
|
|
71
|
+
} from '@intercartx/booster-core'
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 配置管理
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { setGlobalConfig, CheckoutConfig } from '@intercartx/booster-core'
|
|
78
|
+
|
|
79
|
+
const config: CheckoutConfig = {
|
|
80
|
+
token: 'your-token',
|
|
81
|
+
googleApiKey: 'your-google-api-key',
|
|
82
|
+
website: {
|
|
83
|
+
name: 'Your Website',
|
|
84
|
+
setting: {
|
|
85
|
+
trackings: {}
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
currency: 'USD',
|
|
89
|
+
language: 'en',
|
|
90
|
+
region: 'US',
|
|
91
|
+
feeSetting: {
|
|
92
|
+
tip: true,
|
|
93
|
+
coupon: true,
|
|
94
|
+
shipping: true
|
|
95
|
+
},
|
|
96
|
+
processorData: {
|
|
97
|
+
productInfo: {
|
|
98
|
+
// 产品信息
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
paymentMethods: {
|
|
102
|
+
// 支付方式配置
|
|
103
|
+
},
|
|
104
|
+
publicKey: 'your-public-key'
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
setGlobalConfig(config)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 使用验证函数
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import {
|
|
114
|
+
validateEmail,
|
|
115
|
+
validatePhone,
|
|
116
|
+
validateRequired,
|
|
117
|
+
validateCountry
|
|
118
|
+
} from '@intercartx/booster-core'
|
|
119
|
+
|
|
120
|
+
// 验证邮箱
|
|
121
|
+
const isValidEmail = validateEmail('user@example.com')
|
|
122
|
+
|
|
123
|
+
// 验证电话
|
|
124
|
+
const isValidPhone = validatePhone('+1234567890', 'US')
|
|
125
|
+
|
|
126
|
+
// 验证必填字段
|
|
127
|
+
const isValid = validateRequired('value')
|
|
128
|
+
|
|
129
|
+
// 验证国家
|
|
130
|
+
const isValidCountry = validateCountry('US')
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### 使用工具函数
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
import {
|
|
137
|
+
formatCurrency,
|
|
138
|
+
formatPhoneNumber,
|
|
139
|
+
debounce
|
|
140
|
+
} from '@intercartx/booster-core'
|
|
141
|
+
|
|
142
|
+
// 格式化货币
|
|
143
|
+
const formatted = formatCurrency(1000, 'USD') // $10.00
|
|
144
|
+
|
|
145
|
+
// 格式化电话号码
|
|
146
|
+
const phone = formatPhoneNumber('1234567890', 'US')
|
|
147
|
+
|
|
148
|
+
// 防抖函数
|
|
149
|
+
const debouncedFn = debounce(() => {
|
|
150
|
+
console.log('Debounced!')
|
|
151
|
+
}, 300)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 使用 API
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
import { apiGetConfig, apiProcessor } from '@intercartx/booster-core/api'
|
|
158
|
+
|
|
159
|
+
// 获取配置
|
|
160
|
+
const config = await apiGetConfig('your-token')
|
|
161
|
+
|
|
162
|
+
// 处理订单
|
|
163
|
+
const result = await apiProcessor({
|
|
164
|
+
website: 'Your Website',
|
|
165
|
+
region: 'US',
|
|
166
|
+
processorData: {
|
|
167
|
+
productInfo: {
|
|
168
|
+
// 产品信息
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
})
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### 使用样式
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
// 导入全局样式
|
|
178
|
+
import '@intercartx/booster-core/styles/global.css'
|
|
179
|
+
|
|
180
|
+
// 导入特定组件样式
|
|
181
|
+
import '@intercartx/booster-core/styles/button.css'
|
|
182
|
+
import '@intercartx/booster-core/styles/input.css'
|
|
183
|
+
import '@intercartx/booster-core/styles/payment.css'
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### 使用业务模型
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
import {
|
|
190
|
+
AddressModel,
|
|
191
|
+
PaymentModel,
|
|
192
|
+
OrderSummaryModel,
|
|
193
|
+
TipsModel,
|
|
194
|
+
ShippingMethodsModel
|
|
195
|
+
} from '@intercartx/booster-core'
|
|
196
|
+
|
|
197
|
+
// 创建地址模型实例
|
|
198
|
+
const addressModel = new AddressModel({
|
|
199
|
+
// 地址配置
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
// 创建支付模型实例
|
|
203
|
+
const paymentModel = new PaymentModel({
|
|
204
|
+
// 支付配置
|
|
205
|
+
})
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## API 参考
|
|
209
|
+
|
|
210
|
+
### 主要导出
|
|
211
|
+
|
|
212
|
+
#### 配置管理
|
|
213
|
+
- `setGlobalConfig(config: CheckoutConfig)`: 设置全局配置
|
|
214
|
+
- `getGlobalConfig(): CheckoutConfig`: 获取全局配置
|
|
215
|
+
- `globalState`: 全局状态对象
|
|
216
|
+
|
|
217
|
+
#### 验证函数
|
|
218
|
+
- `validateEmail(email: string): boolean`
|
|
219
|
+
- `validatePhone(phone: string, country?: string): boolean`
|
|
220
|
+
- `validateRequired(value: any): boolean`
|
|
221
|
+
- `validateCountry(country: string): boolean`
|
|
222
|
+
- `validateUSZipCode(zipCode: string): boolean`
|
|
223
|
+
- `validateUSStateCode(stateCode: string): boolean`
|
|
224
|
+
- `validateCAPostcode(postcode: string): boolean`
|
|
225
|
+
- `validateCAProvince(province: string): boolean`
|
|
226
|
+
- `validateGBPostcode(postcode: string): boolean`
|
|
227
|
+
- `validateAUPostcode(postcode: string): boolean`
|
|
228
|
+
- `validateAUStateOrTerritory(state: string): boolean`
|
|
229
|
+
- `validateNZPostalCode(postcode: string): boolean`
|
|
230
|
+
- `validateNZRegion(region: string): boolean`
|
|
231
|
+
|
|
232
|
+
#### 工具函数
|
|
233
|
+
- `formatCurrency(amount: number, currency: string): string`
|
|
234
|
+
- `formatPhoneNumber(phone: string, country: string): string`
|
|
235
|
+
- `debounce<T extends (...args: any[]) => any>(fn: T, delay: number): T`
|
|
236
|
+
- `retry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>`
|
|
237
|
+
- `encrypt(data: string, key: string): string`
|
|
238
|
+
- `getBrowserInfo(): BrowserInfo`
|
|
239
|
+
|
|
240
|
+
#### API 函数
|
|
241
|
+
- `apiGetConfig(token: string): Promise<CheckoutConfig>`
|
|
242
|
+
- `apiProcessor(data: ProcessorData): Promise<ProcessorResult>`
|
|
243
|
+
- `apiPreOrder(data: PreOrderData): Promise<PreOrderResult>`
|
|
244
|
+
- `apiOrderConfirm(data: OrderConfirmData): Promise<OrderConfirmResult>`
|
|
245
|
+
- `apiCCPayment(data: CCPaymentData): Promise<CCPaymentResult>`
|
|
246
|
+
- `apiACHPayment(data: ACHPaymentData): Promise<ACHPaymentResult>`
|
|
247
|
+
- `apiPPPayment(data: PPPaymentData): Promise<PPPaymentResult>`
|
|
248
|
+
|
|
249
|
+
#### 业务模型
|
|
250
|
+
- `AddressModel`: 地址管理模型
|
|
251
|
+
- `AddressSuggestModel`: 地址建议模型
|
|
252
|
+
- `MultiRegionsModel`: 多地区模型
|
|
253
|
+
- `PaymentModel`: 支付模型
|
|
254
|
+
- `CCPaymentModel`: 信用卡支付模型
|
|
255
|
+
- `ACHPaymentModel`: ACH 支付模型
|
|
256
|
+
- `PPPaymentModel`: PayPal 支付模型
|
|
257
|
+
- `StripePaymentModel`: Stripe 支付模型
|
|
258
|
+
- `FxpPaymentModel`: FXP 支付模型
|
|
259
|
+
- `OrderSummaryModel`: 订单摘要模型
|
|
260
|
+
- `TipsModel`: 小费模型
|
|
261
|
+
- `ShippingMethodsModel`: 运费方法模型
|
|
262
|
+
- `CustomInfoModel`: 自定义信息模型
|
|
263
|
+
- `BuyNowModel`: 购买按钮模型
|
|
264
|
+
- `PaypalModalModel`: PayPal 模态框模型
|
|
265
|
+
- `PhoneModel`: 电话输入模型
|
|
266
|
+
- `PayButtonModel`: 支付按钮模型
|
|
267
|
+
|
|
268
|
+
## 类型定义
|
|
269
|
+
|
|
270
|
+
### CheckoutConfig
|
|
271
|
+
|
|
272
|
+
```typescript
|
|
273
|
+
interface CheckoutConfig {
|
|
274
|
+
token: string
|
|
275
|
+
googleApiKey?: string
|
|
276
|
+
website: {
|
|
277
|
+
name: string
|
|
278
|
+
setting: {
|
|
279
|
+
trackings: any
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
currency: string
|
|
283
|
+
language: string
|
|
284
|
+
region: string
|
|
285
|
+
feeSetting: {
|
|
286
|
+
tip: boolean
|
|
287
|
+
coupon: boolean
|
|
288
|
+
shipping: boolean
|
|
289
|
+
}
|
|
290
|
+
processorData: {
|
|
291
|
+
productInfo: OrderProduct
|
|
292
|
+
}
|
|
293
|
+
paymentMethods: PaymentConfig
|
|
294
|
+
publicKey: string
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### PaymentConfig
|
|
299
|
+
|
|
300
|
+
```typescript
|
|
301
|
+
interface PaymentConfig {
|
|
302
|
+
CC?: ccPaymentConfig
|
|
303
|
+
PP?: ppPaymentConfig
|
|
304
|
+
ACH?: achPaymentConfig
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
## 样式系统
|
|
309
|
+
|
|
310
|
+
本包提供了完整的样式系统,包括:
|
|
311
|
+
|
|
312
|
+
- **全局样式**: `styles/global.css`
|
|
313
|
+
- **组件样式**:
|
|
314
|
+
- `styles/button.css`
|
|
315
|
+
- `styles/input.css`
|
|
316
|
+
- `styles/select.css`
|
|
317
|
+
- `styles/payment.css`
|
|
318
|
+
- `styles/address.css`
|
|
319
|
+
- `styles/order-summary.css`
|
|
320
|
+
- `styles/custom-info.css`
|
|
321
|
+
- `styles/paypal-modal.css`
|
|
322
|
+
- `styles/phone-input.css`
|
|
323
|
+
- `styles/fee.css`
|
|
324
|
+
- `styles/loading.css`
|
|
325
|
+
- `styles/checkout-page.css`
|
|
326
|
+
- `styles/stripe-payment.css`
|
|
327
|
+
- `styles/fxp-payment.css`
|
|
328
|
+
- `styles/select-list.css`
|
|
329
|
+
- `styles/theme.css`
|
|
330
|
+
|
|
331
|
+
## 依赖项
|
|
332
|
+
|
|
333
|
+
### 核心依赖
|
|
334
|
+
- `@stripe/stripe-js`: Stripe 支付集成
|
|
335
|
+
- `currency-symbol-map`: 货币符号映射
|
|
336
|
+
- `decimal.js`: 精确的十进制运算
|
|
337
|
+
- `libphonenumber-js`: 电话号码处理
|
|
338
|
+
- `node-forge`: 加密工具
|
|
339
|
+
- `payment`: 支付处理
|
|
340
|
+
- `uuid`: UUID 生成
|
|
341
|
+
- `zod`: 数据验证
|
|
342
|
+
|
|
343
|
+
### 开发依赖
|
|
344
|
+
- `typescript`: TypeScript 支持
|
|
345
|
+
- `sass`: SCSS 编译
|
|
346
|
+
- `tailwindcss`: Tailwind CSS
|
|
347
|
+
- `postcss`: PostCSS 处理
|
|
348
|
+
- `autoprefixer`: CSS 自动前缀
|
|
349
|
+
|
|
350
|
+
## 构建
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
# 构建 TypeScript
|
|
354
|
+
pnpm run build:ts
|
|
355
|
+
|
|
356
|
+
# 构建 SCSS
|
|
357
|
+
pnpm run build:scss
|
|
358
|
+
|
|
359
|
+
# 构建样式文件
|
|
360
|
+
pnpm run build:styles
|
|
361
|
+
|
|
362
|
+
# 完整构建
|
|
363
|
+
pnpm run build
|
|
364
|
+
|
|
365
|
+
# 开发模式(监听 SCSS 变化)
|
|
366
|
+
pnpm run dev
|
|
367
|
+
|
|
368
|
+
# 类型检查
|
|
369
|
+
pnpm run typecheck
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
## 许可证
|
|
373
|
+
|
|
374
|
+
GPL-3.0-only
|
|
375
|
+
|
|
376
|
+
## 相关包
|
|
377
|
+
|
|
378
|
+
- `@intercartx/booster-react`: React 组件库
|
|
379
|
+
- `@intercartx/booster-solid`: SolidJS 组件库
|
|
380
|
+
- `@intercartx/booster-elements`: Web Components 库
|
package/dist/api/config/index.js
CHANGED
|
@@ -6,6 +6,9 @@ export async function apiProcessor(data) {
|
|
|
6
6
|
return post(`/processor`, data);
|
|
7
7
|
}
|
|
8
8
|
export function getApiURL() {
|
|
9
|
+
if (prefixApi) {
|
|
10
|
+
return `${prefixApi}/v3`;
|
|
11
|
+
}
|
|
9
12
|
if (process.env.NODE_ENV === 'development') {
|
|
10
13
|
return '/api/v3';
|
|
11
14
|
}
|
|
@@ -15,3 +18,7 @@ export function getApiURL() {
|
|
|
15
18
|
}
|
|
16
19
|
return `${location.protocol}//${location.host}/v3`;
|
|
17
20
|
}
|
|
21
|
+
let prefixApi = null;
|
|
22
|
+
export function setPrefixApi(prefix) {
|
|
23
|
+
prefixApi = prefix;
|
|
24
|
+
}
|
package/dist/api/index.d.ts
CHANGED
package/dist/api/index.js
CHANGED
package/dist/api/order/index.js
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { OrderProduct } from "../types";
|
|
2
|
+
export interface QuickOrderRequest {
|
|
3
|
+
products: OrderProduct;
|
|
4
|
+
confirmUrl: string;
|
|
5
|
+
}
|
|
6
|
+
export interface QuickOrderResponse {
|
|
7
|
+
sourceToken: string;
|
|
8
|
+
newToken: string;
|
|
9
|
+
newOrderId: string;
|
|
10
|
+
newTradeId: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function apiCreateQuickOrder(token: string, body: QuickOrderRequest): Promise<QuickOrderResponse>;
|
|
@@ -64,3 +64,7 @@ export interface SubmissionRequest extends PreSubmissionRequest {
|
|
|
64
64
|
action?: string;
|
|
65
65
|
subAction?: PaymentSubAction;
|
|
66
66
|
}
|
|
67
|
+
export declare enum ResponseErrorCode {
|
|
68
|
+
CREDIT_CARD_FAILED = 2002,// 卡号支付失败,sdk 可以根据此错误码自动请求 paypal 支付
|
|
69
|
+
ORDER_ALREADY_HAS_TRADE = 4004
|
|
70
|
+
}
|
package/dist/api/order/types.js
CHANGED
|
@@ -31,3 +31,8 @@ export var OrderStatusPaid;
|
|
|
31
31
|
OrderStatusPaid[OrderStatusPaid["Unpaid"] = 0] = "Unpaid";
|
|
32
32
|
OrderStatusPaid[OrderStatusPaid["Paid"] = 1] = "Paid";
|
|
33
33
|
})(OrderStatusPaid || (OrderStatusPaid = {}));
|
|
34
|
+
export var ResponseErrorCode;
|
|
35
|
+
(function (ResponseErrorCode) {
|
|
36
|
+
ResponseErrorCode[ResponseErrorCode["CREDIT_CARD_FAILED"] = 2002] = "CREDIT_CARD_FAILED";
|
|
37
|
+
ResponseErrorCode[ResponseErrorCode["ORDER_ALREADY_HAS_TRADE"] = 4004] = "ORDER_ALREADY_HAS_TRADE"; // 订单已关联交易,返回数据可能有 {message: string, data?: {action?: {url?: string, secret?: string}}}1. 当 data?.action?.url 存在时,跳转 url 进行对应操作2. 当 data?.action?.secret 存在时,使用 secret 进行 3ds3. 没有 data 则直接访问确认订单/订阅接口
|
|
38
|
+
})(ResponseErrorCode || (ResponseErrorCode = {}));
|
package/dist/api/types.d.ts
CHANGED
|
@@ -15,19 +15,7 @@ interface ShippingMethod {
|
|
|
15
15
|
price: number | string;
|
|
16
16
|
currency: string;
|
|
17
17
|
}
|
|
18
|
-
interface
|
|
19
|
-
display: {
|
|
20
|
-
title: string;
|
|
21
|
-
subTitle: string;
|
|
22
|
-
image: string;
|
|
23
|
-
quantity: number;
|
|
24
|
-
price: number | string;
|
|
25
|
-
originPrice: number | string;
|
|
26
|
-
discount: number;
|
|
27
|
-
sku?: string;
|
|
28
|
-
}[];
|
|
29
|
-
}
|
|
30
|
-
interface OneTimeOrderProduct extends BaseOrderProduct {
|
|
18
|
+
interface OneTimeOrderProduct {
|
|
31
19
|
purchase: {
|
|
32
20
|
cart: {
|
|
33
21
|
quantity: number;
|
|
@@ -40,8 +28,9 @@ interface OneTimeOrderProduct extends BaseOrderProduct {
|
|
|
40
28
|
}[];
|
|
41
29
|
coupon?: string[];
|
|
42
30
|
};
|
|
31
|
+
display: Display[];
|
|
43
32
|
}
|
|
44
|
-
interface SubscriptionOrderProduct
|
|
33
|
+
interface SubscriptionOrderProduct {
|
|
45
34
|
subscription: {
|
|
46
35
|
pricePlan: {
|
|
47
36
|
products: {
|
|
@@ -55,6 +44,21 @@ interface SubscriptionOrderProduct extends BaseOrderProduct {
|
|
|
55
44
|
}[];
|
|
56
45
|
planId?: string;
|
|
57
46
|
};
|
|
47
|
+
displays: {
|
|
48
|
+
display: Display[];
|
|
49
|
+
interval: number;
|
|
50
|
+
}[];
|
|
51
|
+
}
|
|
52
|
+
interface Display {
|
|
53
|
+
title: string;
|
|
54
|
+
subTitle: string;
|
|
55
|
+
image: string;
|
|
56
|
+
quantity: number;
|
|
57
|
+
price: number | string;
|
|
58
|
+
originPrice: number | string;
|
|
59
|
+
discount: number;
|
|
60
|
+
productId?: string;
|
|
61
|
+
[key: string]: any;
|
|
58
62
|
}
|
|
59
63
|
type OrderProduct = OneTimeOrderProduct | SubscriptionOrderProduct;
|
|
60
64
|
interface BrowserInfo {
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -49,7 +49,7 @@ export class CustomInfoModel extends BusinessModel {
|
|
|
49
49
|
inputMode: 'numeric',
|
|
50
50
|
maxLength: 16,
|
|
51
51
|
...props.phone,
|
|
52
|
-
validateFn: validatePhone,
|
|
52
|
+
validateFn: (e, m) => validatePhone(`${this.phone.prefix}${e}`, m),
|
|
53
53
|
validateMessages: validateMessages.phone,
|
|
54
54
|
region: 'US'
|
|
55
55
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CheckoutEvents } from "../../types";
|
|
2
|
+
import { BaseModel } from "../Base";
|
|
3
|
+
import { globalState } from "../GlobalState";
|
|
4
|
+
export class ErrorTipModel extends BaseModel {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
this.isShow = false;
|
|
8
|
+
this.message = '';
|
|
9
|
+
this.reactiveKeys = ['isShow', 'message'];
|
|
10
|
+
globalState.on(CheckoutEvents.ERROR_TIP_SHOW, (message) => {
|
|
11
|
+
if (message) {
|
|
12
|
+
this.showErrorTip(message);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
this.hideErrorTip();
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
showErrorTip(message) {
|
|
20
|
+
this.isShow = true;
|
|
21
|
+
this.message = message;
|
|
22
|
+
}
|
|
23
|
+
hideErrorTip() {
|
|
24
|
+
this.isShow = false;
|
|
25
|
+
this.message = '';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseModel } from "../Base";
|
|
2
|
+
import { globalState } from "../GlobalState";
|
|
2
3
|
class FullScreenLoadingModel extends BaseModel {
|
|
3
4
|
constructor() {
|
|
4
5
|
super(...arguments);
|
|
@@ -9,10 +10,12 @@ class FullScreenLoadingModel extends BaseModel {
|
|
|
9
10
|
showLoading(msg) {
|
|
10
11
|
this.isShow = true;
|
|
11
12
|
this.message = msg || 'Processing...';
|
|
13
|
+
globalState.emit('purchaseing', { isShow: this.isShow, message: this.message });
|
|
12
14
|
}
|
|
13
15
|
hideLoading() {
|
|
14
16
|
this.isShow = false;
|
|
15
17
|
this.message = '';
|
|
18
|
+
globalState.emit('purchaseing', { isShow: this.isShow, message: this.message });
|
|
16
19
|
}
|
|
17
20
|
}
|
|
18
21
|
export const globalLoading = new FullScreenLoadingModel();
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OneTimeOrderProduct, SubscriptionOrderProduct } from "../../api/types";
|
|
2
2
|
import { FeeCalculateResponse } from "../../api/utils/types";
|
|
3
3
|
import { BusinessModel } from "./Business";
|
|
4
4
|
export declare class OrderSummaryModel extends BusinessModel {
|
|
5
|
-
displayProductList:
|
|
5
|
+
displayProductList: OneTimeOrderProduct['display'] | SubscriptionOrderProduct['displays'][0]['display'];
|
|
6
|
+
isSubscription: boolean;
|
|
6
7
|
isOpen: boolean;
|
|
7
8
|
fees: FeeCalculateResponse['feeDetail'];
|
|
8
9
|
reactiveKeys: string[];
|
|
@@ -12,4 +13,5 @@ export declare class OrderSummaryModel extends BusinessModel {
|
|
|
12
13
|
get total(): string;
|
|
13
14
|
get isLoading(): boolean;
|
|
14
15
|
toggleOpen(): void;
|
|
16
|
+
getSubscriptionPlanTexts(): string[];
|
|
15
17
|
}
|