@seaverse/payment-sdk 0.6.1 → 0.7.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 +14 -15
- package/dist/index.browser.js +14 -38
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +14 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +15 -39
- package/dist/index.js +14 -38
- package/dist/index.js.map +1 -1
- package/dist/style.css +1482 -0
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -497,10 +497,7 @@ class CheckoutAPI {
|
|
|
497
497
|
async createOneTimeCheckout(params) {
|
|
498
498
|
return this.createCheckout({
|
|
499
499
|
product_id: params.productId,
|
|
500
|
-
product_name: params.productName,
|
|
501
|
-
price: params.price,
|
|
502
500
|
purchase_type: 1,
|
|
503
|
-
extra: params.extra,
|
|
504
501
|
redirect_url: params.redirectUrl,
|
|
505
502
|
});
|
|
506
503
|
}
|
|
@@ -510,11 +507,8 @@ class CheckoutAPI {
|
|
|
510
507
|
async createSubscriptionCheckout(params) {
|
|
511
508
|
return this.createCheckout({
|
|
512
509
|
product_id: params.productId,
|
|
513
|
-
product_name: params.productName,
|
|
514
|
-
price: params.price,
|
|
515
510
|
purchase_type: 2,
|
|
516
|
-
|
|
517
|
-
extra: params.extra,
|
|
511
|
+
billing_period: params.billingPeriod,
|
|
518
512
|
redirect_url: params.redirectUrl,
|
|
519
513
|
});
|
|
520
514
|
}
|
|
@@ -563,24 +557,9 @@ class CheckoutAPI {
|
|
|
563
557
|
* 验证请求参数
|
|
564
558
|
*/
|
|
565
559
|
validateRequest(request) {
|
|
566
|
-
// 必须提供
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
if (!hasProductId && !hasManualProduct) {
|
|
570
|
-
throw this.createError('INVALID_PARAMS', '必须提供 productId 或 (productName + price)');
|
|
571
|
-
}
|
|
572
|
-
// 订阅类型必须提供订阅参数
|
|
573
|
-
if (request.purchase_type === 2 && !request.subscription) {
|
|
574
|
-
throw this.createError('INVALID_PARAMS', '订阅类型必须提供 subscription 参数');
|
|
575
|
-
}
|
|
576
|
-
// 验证订阅参数
|
|
577
|
-
if (request.subscription) {
|
|
578
|
-
if (!request.subscription.period) {
|
|
579
|
-
throw this.createError('INVALID_PARAMS', '订阅参数缺少 period');
|
|
580
|
-
}
|
|
581
|
-
if (request.subscription.periodAmount == null) {
|
|
582
|
-
throw this.createError('INVALID_PARAMS', '订阅参数缺少 periodAmount');
|
|
583
|
-
}
|
|
560
|
+
// 必须提供 product_id
|
|
561
|
+
if (!request.product_id) {
|
|
562
|
+
throw this.createError('INVALID_PARAMS', '必须提供 product_id');
|
|
584
563
|
}
|
|
585
564
|
}
|
|
586
565
|
/**
|
|
@@ -769,12 +748,13 @@ class PaymentCheckoutClient {
|
|
|
769
748
|
async checkout(options) {
|
|
770
749
|
await this.ensureReady();
|
|
771
750
|
this.log('发起一次性购买:', options);
|
|
751
|
+
// 验证必需参数
|
|
752
|
+
if (!options.productId) {
|
|
753
|
+
throw this.createError('INVALID_PARAMS', '缺少必需参数: productId');
|
|
754
|
+
}
|
|
772
755
|
// 调用结账 API
|
|
773
756
|
const result = await this.checkoutAPI.createOneTimeCheckout({
|
|
774
757
|
productId: options.productId,
|
|
775
|
-
productName: options.productName,
|
|
776
|
-
price: options.price,
|
|
777
|
-
extra: options.extra,
|
|
778
758
|
redirectUrl: options.redirectUrl,
|
|
779
759
|
});
|
|
780
760
|
// 自动打开支付弹窗
|
|
@@ -806,18 +786,14 @@ class PaymentCheckoutClient {
|
|
|
806
786
|
async subscribe(options) {
|
|
807
787
|
await this.ensureReady();
|
|
808
788
|
this.log('发起订阅购买:', options);
|
|
789
|
+
// 验证必需参数
|
|
790
|
+
if (!options.productId) {
|
|
791
|
+
throw this.createError('INVALID_PARAMS', '缺少必需参数: productId');
|
|
792
|
+
}
|
|
809
793
|
// 调用结账 API
|
|
810
794
|
const result = await this.checkoutAPI.createSubscriptionCheckout({
|
|
811
795
|
productId: options.productId,
|
|
812
|
-
|
|
813
|
-
price: options.price,
|
|
814
|
-
subscription: {
|
|
815
|
-
period: options.period,
|
|
816
|
-
periodAmount: options.periodAmount,
|
|
817
|
-
firstDays: options.firstDays ?? 0,
|
|
818
|
-
billing_period: options.billing_period,
|
|
819
|
-
},
|
|
820
|
-
extra: options.extra,
|
|
796
|
+
billingPeriod: options.billing_period,
|
|
821
797
|
redirectUrl: options.redirectUrl,
|
|
822
798
|
});
|
|
823
799
|
// 自动打开支付弹窗
|
|
@@ -1169,7 +1145,7 @@ function getSDKLocale(locale) {
|
|
|
1169
1145
|
/**
|
|
1170
1146
|
* SDK version
|
|
1171
1147
|
*/
|
|
1172
|
-
const VERSION$2 = '0.
|
|
1148
|
+
const VERSION$2 = '0.7.0';
|
|
1173
1149
|
|
|
1174
1150
|
var __defProp = Object.defineProperty;
|
|
1175
1151
|
var __defProps = Object.defineProperties;
|