@mathrunet/masamune_cloudflare_purchase_stripe 3.2.2 → 3.3.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/CHANGELOG.md +12 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/options.d.ts +1 -1
- package/dist/lib/options.js +7 -7
- package/dist/lib/options.js.map +1 -1
- package/dist/lib/purchase/helpers.js +4 -4
- package/dist/lib/purchase/helpers.js.map +1 -1
- package/dist/lib/purchase/stripe_mapping.d.ts +163 -0
- package/dist/lib/purchase/stripe_mapping.js +141 -0
- package/dist/lib/purchase/stripe_mapping.js.map +1 -0
- package/dist/lib/stripe_client.d.ts +1 -1
- package/dist/lib/stripe_client.js +1 -1
- package/dist/purchase.d.ts +1 -0
- package/dist/purchase.js +1 -0
- package/dist/purchase.js.map +1 -1
- package/dist/workers/stripe.js +68 -68
- package/dist/workers/stripe.js.map +1 -1
- package/dist/workers/stripe_webhook.js +28 -22
- package/dist/workers/stripe_webhook.js.map +1 -1
- package/dist/workers/stripe_webhook_connect.js +2 -2
- package/dist/workers/stripe_webhook_connect.js.map +1 -1
- package/dist/workers/stripe_webhook_secure.js +2 -2
- package/dist/workers/stripe_webhook_secure.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/lib/options.ts +2 -2
- package/src/lib/purchase/helpers.ts +1 -1
- package/src/lib/purchase/stripe_mapping.ts +263 -0
- package/src/lib/stripe_client.ts +1 -1
- package/src/purchase.ts +1 -0
- package/src/workers/stripe.ts +1 -1
- package/src/workers/stripe_webhook.ts +30 -23
- package/src/workers/stripe_webhook_connect.ts +1 -1
- package/src/workers/stripe_webhook_secure.ts +1 -1
- package/test/meter.test.ts +11 -2
- package/test/stripe_mapping.test.ts +184 -0
- package/test/stripe_webhook.test.ts +210 -62
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## 3.3.0 (2026-09-25)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### feat
|
|
5
|
+
|
|
6
|
+
* **purchase_stripe:** upgrade Stripe SDK to v22 and API version 2026-08-26.dahlia ([7ceea35](https://github.com/mathrunet/node_masamune/commit/7ceea354dd0edb1214b64ba002340692c90adee5))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### fix
|
|
10
|
+
|
|
11
|
+
* **purchase_stripe:** restore package versions reverted by the Stripe upgrade ([b8cea4d](https://github.com/mathrunet/node_masamune/commit/b8cea4de412dafeed49eecf8465e31a1c6a036c0))
|
|
12
|
+
|
|
1
13
|
## 3.2.2 (2026-09-25)
|
|
2
14
|
|
|
3
15
|
### dependencies
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export * from "./lib/purchase/interface";
|
|
|
17
17
|
export * from "./lib/purchase/d1_purchase_store";
|
|
18
18
|
export * from "./lib/purchase/helpers";
|
|
19
19
|
export * from "./lib/purchase/sync_payment";
|
|
20
|
+
export * from "./lib/purchase/stripe_mapping";
|
|
20
21
|
export * from "./lib/meter/interface";
|
|
21
22
|
export * from "./lib/meter/stripe_meter_client";
|
|
22
23
|
export * from "./lib/meter/flush_meter";
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ __exportStar(require("./lib/purchase/interface"), exports);
|
|
|
33
33
|
__exportStar(require("./lib/purchase/d1_purchase_store"), exports);
|
|
34
34
|
__exportStar(require("./lib/purchase/helpers"), exports);
|
|
35
35
|
__exportStar(require("./lib/purchase/sync_payment"), exports);
|
|
36
|
+
__exportStar(require("./lib/purchase/stripe_mapping"), exports);
|
|
36
37
|
__exportStar(require("./lib/meter/interface"), exports);
|
|
37
38
|
__exportStar(require("./lib/meter/stripe_meter_client"), exports);
|
|
38
39
|
__exportStar(require("./lib/meter/flush_meter"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,sDAAoC;AACpC,iEAA+C;AAC/C,8CAA4B;AAC5B,gDAA8B;AAC9B,sDAAoC;AACpC,2DAAyC;AACzC,mEAAiD;AACjD,yDAAuC;AACvC,8DAA4C;AAC5C,wDAAsC;AACtC,kEAAgD;AAChD,0DAAwC;AACxC,2DAAyC;AACzC,mEAAiD;AACjD,8DAA4C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,sDAAoC;AACpC,iEAA+C;AAC/C,8CAA4B;AAC5B,gDAA8B;AAC9B,sDAAoC;AACpC,2DAAyC;AACzC,mEAAiD;AACjD,yDAAuC;AACvC,8DAA4C;AAC5C,gEAA8C;AAC9C,wDAAsC;AACtC,kEAAgD;AAChD,0DAAwC;AACxC,2DAAyC;AACzC,mEAAiD;AACjD,8DAA4C"}
|
package/dist/lib/options.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Stripe from "stripe";
|
|
2
2
|
import { Context } from "hono";
|
|
3
|
-
import { WorkersOptions } from "@mathrunet/masamune_cloudflare
|
|
3
|
+
import { WorkersOptions } from "@mathrunet/masamune_cloudflare";
|
|
4
4
|
import { D1StripePurchaseStoreOptions } from "./purchase/d1_purchase_store";
|
|
5
5
|
import { StripePurchaseStore } from "./purchase/interface";
|
|
6
6
|
/**
|
package/dist/lib/options.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.resolveStripeWebhookSecret = resolveStripeWebhookSecret;
|
|
|
7
7
|
exports.resolveStripeWebhookConnectSecret = resolveStripeWebhookConnectSecret;
|
|
8
8
|
exports.resolveStripePurchaseStore = resolveStripePurchaseStore;
|
|
9
9
|
exports.resolveStripeEmailSender = resolveStripeEmailSender;
|
|
10
|
-
const
|
|
10
|
+
const masamune_cloudflare_1 = require("@mathrunet/masamune_cloudflare");
|
|
11
11
|
const d1_purchase_store_1 = require("./purchase/d1_purchase_store");
|
|
12
12
|
const stripe_client_1 = require("./stripe_client");
|
|
13
13
|
/**
|
|
@@ -27,7 +27,7 @@ function resolveStripeClient(context, options, secretKey) {
|
|
|
27
27
|
* オプションと`context.env`からStripeのシークレットキーを解決します。
|
|
28
28
|
*/
|
|
29
29
|
function resolveStripeSecretKey(context, options) {
|
|
30
|
-
return (0,
|
|
30
|
+
return (0, masamune_cloudflare_1.resolveConfig)(context, options.secretKey, "PURCHASE_STRIPE_SECRETKEY") ?? "";
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Resolve the Stripe meter event name from options and `context.env`.
|
|
@@ -35,7 +35,7 @@ function resolveStripeSecretKey(context, options) {
|
|
|
35
35
|
* オプションと`context.env`からStripeのMeterイベント名を解決します。
|
|
36
36
|
*/
|
|
37
37
|
function resolveStripeMeterEventName(context, options) {
|
|
38
|
-
return (0,
|
|
38
|
+
return (0, masamune_cloudflare_1.resolveConfig)(context, options.meterEventName, "PURCHASE_STRIPE_METER_EVENT_NAME");
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Resolve the main webhook signing secret from options and `context.env`.
|
|
@@ -43,7 +43,7 @@ function resolveStripeMeterEventName(context, options) {
|
|
|
43
43
|
* オプションと`context.env`からメインWebhookの署名シークレットを解決します。
|
|
44
44
|
*/
|
|
45
45
|
function resolveStripeWebhookSecret(context, options) {
|
|
46
|
-
return (0,
|
|
46
|
+
return (0, masamune_cloudflare_1.resolveConfig)(context, options.webhookSecret, "PURCHASE_STRIPE_WEBHOOKSECRET") ?? "";
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Resolve the Connect webhook signing secret from options and `context.env`.
|
|
@@ -51,7 +51,7 @@ function resolveStripeWebhookSecret(context, options) {
|
|
|
51
51
|
* オプションと`context.env`からConnect用Webhookの署名シークレットを解決します。
|
|
52
52
|
*/
|
|
53
53
|
function resolveStripeWebhookConnectSecret(context, options) {
|
|
54
|
-
return (0,
|
|
54
|
+
return (0, masamune_cloudflare_1.resolveConfig)(context, options.webhookConnectSecret, "PURCHASE_STRIPE_WEBHOOKCONNECTSECRET") ?? "";
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Resolve the purchase data store from options and `context.env`.
|
|
@@ -84,10 +84,10 @@ function resolveStripeEmailSender(context, options) {
|
|
|
84
84
|
const sendEmail = options.sendEmail;
|
|
85
85
|
return (email) => sendEmail(context, email);
|
|
86
86
|
}
|
|
87
|
-
const provider = (0,
|
|
87
|
+
const provider = (0, masamune_cloudflare_1.resolveConfig)(context, undefined, "PURCHASE_STRIPE_EMAILPROVIDER") ?? "sendgrid";
|
|
88
88
|
switch (provider) {
|
|
89
89
|
case "sendgrid": {
|
|
90
|
-
const apiKey = (0,
|
|
90
|
+
const apiKey = (0, masamune_cloudflare_1.resolveConfig)(context, undefined, "MAIL_SENDGRID_APIKEY");
|
|
91
91
|
if (!apiKey) {
|
|
92
92
|
return null;
|
|
93
93
|
}
|
package/dist/lib/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/lib/options.ts"],"names":[],"mappings":";;AA4JA,kDASC;AAOD,wDAKC;AAOD,kEAKC;AAOD,gEAKC;AAOD,8EAKC;AAOD,gEAcC;AAWD,4DAqBC;AAxQD,
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/lib/options.ts"],"names":[],"mappings":";;AA4JA,kDASC;AAOD,wDAKC;AAOD,kEAKC;AAOD,gEAKC;AAOD,8EAKC;AAOD,gEAcC;AAWD,4DAqBC;AAxQD,wEAA+D;AAG/D,oEAAmG;AAEnG,mDAAqD;AAgJrD;;;;GAIG;AACH,SAAgB,mBAAmB,CAC/B,OAAgB,EAChB,OAAqC,EACrC,SAAiB;IAEjB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;QACvB,OAAO,OAAO,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BAAgB,EAAE;gBACd;oBACI,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;iBAC5B;aACJ;YACD,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE;YAC3B,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,OAAO,EAAE;gBACL;oBACI,IAAI,EAAE,YAAY;oBAClB,KAAK,EAAE,KAAK,CAAC,IAAI;iBACpB;aACJ;SACJ,CAAC;KACL,CAAC,CAAC;IACH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACV,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,yCAAyC,GAAG,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC,CAAC;IACnF,CAAC;AACL,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolveDefaultPayment = resolveDefaultPayment;
|
|
4
4
|
exports.resolveUserEmail = resolveUserEmail;
|
|
5
|
-
const
|
|
5
|
+
const masamune_cloudflare_1 = require("@mathrunet/masamune_cloudflare");
|
|
6
6
|
/**
|
|
7
7
|
* Resolve the default payment method of a user, following the same fallback
|
|
8
8
|
* chain as the Firebase implementation: stored `defaultPayment` -> customer's
|
|
@@ -25,11 +25,11 @@ async function resolveDefaultPayment(options) {
|
|
|
25
25
|
if (!defaultPayment) {
|
|
26
26
|
const payments = await store.listPayments(user.userId);
|
|
27
27
|
if (payments.length <= 0) {
|
|
28
|
-
throw new
|
|
28
|
+
throw new masamune_cloudflare_1.HttpError(404, "The payment method is not found.");
|
|
29
29
|
}
|
|
30
30
|
defaultPayment = payments[0]?.data["id"];
|
|
31
31
|
if (!defaultPayment) {
|
|
32
|
-
throw new
|
|
32
|
+
throw new masamune_cloudflare_1.HttpError(404, "The payment method is not found.");
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
await store.saveUser(user.userId, { defaultPayment });
|
|
@@ -57,7 +57,7 @@ async function resolveUserEmail(options) {
|
|
|
57
57
|
email = paymentMethod?.billing_details?.email ?? undefined;
|
|
58
58
|
}
|
|
59
59
|
if (!email) {
|
|
60
|
-
throw new
|
|
60
|
+
throw new masamune_cloudflare_1.HttpError(404, "The user's email is not found.");
|
|
61
61
|
}
|
|
62
62
|
return email;
|
|
63
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/lib/purchase/helpers.ts"],"names":[],"mappings":";;AAiBA,sDA0BC;AAWD,4CAsBC;AA1ED,
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/lib/purchase/helpers.ts"],"names":[],"mappings":";;AAiBA,sDA0BC;AAWD,4CAsBC;AA1ED,wEAA2D;AAI3D;;;;;;;;;;GAUG;AACI,KAAK,UAAU,qBAAqB,CAAC,OAI3C;IACG,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IAC9C,IAAI,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAuB,CAAC;IACvE,IAAI,cAAc,EAAE,CAAC;QACjB,OAAO,cAAc,CAAC;IAC1B,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,SAAS,CAAC,QAAQ,CAClD,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CACL,CAAC;IACrB,cAAc,GAAG,CAAC,QAAQ,CAAC,gBAAgB,CAAC,sBAAsB,IAAI,SAAS,CAAuB,CAAC;IACvG,IAAI,CAAC,cAAc,EAAE,CAAC;QAClB,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvD,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,+BA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|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import Stripe from "stripe";
|
|
2
|
+
/**
|
|
3
|
+
* Loosely typed Stripe object.
|
|
4
|
+
*
|
|
5
|
+
* Webhook payloads are rendered with the API version of the webhook endpoint,
|
|
6
|
+
* not the version pinned by the SDK, so they may contain legacy fields.
|
|
7
|
+
*
|
|
8
|
+
* 緩く型付けされたStripeオブジェクト。
|
|
9
|
+
*
|
|
10
|
+
* WebhookペイロードはSDKで固定したバージョンではなくWebhookエンドポイントの
|
|
11
|
+
* APIバージョンで生成されるため、旧フィールドを含む場合があります。
|
|
12
|
+
*/
|
|
13
|
+
export type StripeLooseObject = {
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Subscription fields stored in the purchase document.
|
|
18
|
+
*
|
|
19
|
+
* The field names are kept identical to the ones stored before the
|
|
20
|
+
* `2025-03-31.basil` migration so that downstream data stays compatible.
|
|
21
|
+
*
|
|
22
|
+
* 購入ドキュメントに保存するサブスクリプションのフィールド。
|
|
23
|
+
*
|
|
24
|
+
* 下流のデータ互換性を保つため、`2025-03-31.basil`移行前と同じフィールド名を
|
|
25
|
+
* 使用します。
|
|
26
|
+
*/
|
|
27
|
+
export interface StripeSubscriptionPurchaseFields {
|
|
28
|
+
/**
|
|
29
|
+
* Start of the current period (UNIX seconds). Earliest value across items.
|
|
30
|
+
*
|
|
31
|
+
* 現在の請求期間の開始(UNIX秒)。アイテム間で最も早い値。
|
|
32
|
+
*/
|
|
33
|
+
current_period_start: number | null;
|
|
34
|
+
/**
|
|
35
|
+
* End of the current period (UNIX seconds). Latest value across items.
|
|
36
|
+
*
|
|
37
|
+
* 現在の請求期間の終了(UNIX秒)。アイテム間で最も遅い値。
|
|
38
|
+
*/
|
|
39
|
+
current_period_end: number | null;
|
|
40
|
+
/**
|
|
41
|
+
* Price ID of the first subscription item.
|
|
42
|
+
*
|
|
43
|
+
* 最初のサブスクリプションアイテムの価格ID。
|
|
44
|
+
*/
|
|
45
|
+
price_id: string | null;
|
|
46
|
+
/**
|
|
47
|
+
* Whether the price of the first item is active.
|
|
48
|
+
*
|
|
49
|
+
* 最初のアイテムの価格が有効かどうか。
|
|
50
|
+
*/
|
|
51
|
+
active: boolean | null;
|
|
52
|
+
/**
|
|
53
|
+
* Unit amount of the price of the first item.
|
|
54
|
+
*
|
|
55
|
+
* 最初のアイテムの価格の単価。
|
|
56
|
+
*/
|
|
57
|
+
amount: number | null;
|
|
58
|
+
/**
|
|
59
|
+
* Billing scheme of the price of the first item.
|
|
60
|
+
*
|
|
61
|
+
* 最初のアイテムの価格の請求方式。
|
|
62
|
+
*/
|
|
63
|
+
billing_scheme: string | null;
|
|
64
|
+
/**
|
|
65
|
+
* Recurring interval of the price of the first item.
|
|
66
|
+
*
|
|
67
|
+
* 最初のアイテムの価格の請求間隔。
|
|
68
|
+
*/
|
|
69
|
+
interval: string | null;
|
|
70
|
+
/**
|
|
71
|
+
* Recurring interval count of the price of the first item.
|
|
72
|
+
*
|
|
73
|
+
* 最初のアイテムの価格の請求間隔数。
|
|
74
|
+
*/
|
|
75
|
+
interval_count: number | null;
|
|
76
|
+
/**
|
|
77
|
+
* Usage type of the price of the first item.
|
|
78
|
+
*
|
|
79
|
+
* 最初のアイテムの価格の使用タイプ。
|
|
80
|
+
*/
|
|
81
|
+
usage_type: string | null;
|
|
82
|
+
/**
|
|
83
|
+
* Quantity of the first item.
|
|
84
|
+
*
|
|
85
|
+
* 最初のアイテムの数量。
|
|
86
|
+
*/
|
|
87
|
+
quantity: number | null;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Resolve the current billing period of a subscription.
|
|
91
|
+
*
|
|
92
|
+
* Since `2025-03-31.basil` the period lives on each subscription item
|
|
93
|
+
* (`items.data[].current_period_*`). The earliest start and the latest end
|
|
94
|
+
* across items are returned. Falls back to the legacy top-level fields for
|
|
95
|
+
* payloads rendered with older API versions. Returns `null` instead of an
|
|
96
|
+
* invalid value when the period is unavailable.
|
|
97
|
+
*
|
|
98
|
+
* サブスクリプションの現在の請求期間を解決します。
|
|
99
|
+
*
|
|
100
|
+
* `2025-03-31.basil`以降、期間は各サブスクリプションアイテム
|
|
101
|
+
* (`items.data[].current_period_*`)に移動しました。アイテム間で最も早い開始と
|
|
102
|
+
* 最も遅い終了を返します。旧APIバージョンのペイロードでは従来のトップレベル
|
|
103
|
+
* フィールドにフォールバックします。期間が取得できない場合は不正値ではなく
|
|
104
|
+
* `null`を返します。
|
|
105
|
+
*/
|
|
106
|
+
export declare function resolveSubscriptionPeriod(subscription: Stripe.Subscription | StripeLooseObject): {
|
|
107
|
+
start: number | null;
|
|
108
|
+
end: number | null;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Build the subscription fields stored in the purchase document.
|
|
112
|
+
*
|
|
113
|
+
* Reads the price from the first subscription item (`items.data[0].price`)
|
|
114
|
+
* instead of the legacy `subscription.plan`, falling back to
|
|
115
|
+
* `items.data[0].plan` and `subscription.plan` for older payloads.
|
|
116
|
+
*
|
|
117
|
+
* 購入ドキュメントに保存するサブスクリプションのフィールドを構築します。
|
|
118
|
+
*
|
|
119
|
+
* 従来の`subscription.plan`ではなく最初のサブスクリプションアイテムの価格
|
|
120
|
+
* (`items.data[0].price`)を参照し、旧ペイロードでは`items.data[0].plan`と
|
|
121
|
+
* `subscription.plan`にフォールバックします。
|
|
122
|
+
*/
|
|
123
|
+
export declare function resolveSubscriptionPurchaseFields(subscription: Stripe.Subscription | StripeLooseObject): StripeSubscriptionPurchaseFields;
|
|
124
|
+
/**
|
|
125
|
+
* Receipt information of a PaymentIntent.
|
|
126
|
+
*
|
|
127
|
+
* PaymentIntentの領収書情報。
|
|
128
|
+
*/
|
|
129
|
+
export interface StripePaymentIntentReceipt {
|
|
130
|
+
/**
|
|
131
|
+
* Receipt URL of the latest charge.
|
|
132
|
+
*
|
|
133
|
+
* 最新のチャージの領収書URL。
|
|
134
|
+
*/
|
|
135
|
+
receiptUrl: string | null;
|
|
136
|
+
/**
|
|
137
|
+
* Captured amount of the latest charge.
|
|
138
|
+
*
|
|
139
|
+
* 最新のチャージのキャプチャ済み金額。
|
|
140
|
+
*/
|
|
141
|
+
capturedAmount: number | null;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Resolve the receipt URL and captured amount of a PaymentIntent.
|
|
145
|
+
*
|
|
146
|
+
* `PaymentIntent.charges` was removed in `2022-11-15`; the charge is now
|
|
147
|
+
* referenced by `latest_charge` (an ID in webhook payloads). An expanded
|
|
148
|
+
* charge is used as is, otherwise the charge is retrieved. The legacy
|
|
149
|
+
* `charges.data[0]` is used as a fallback for older payloads. Retrieval errors
|
|
150
|
+
* are logged and result in `null` values so the caller can still proceed.
|
|
151
|
+
*
|
|
152
|
+
* PaymentIntentの領収書URLとキャプチャ済み金額を解決します。
|
|
153
|
+
*
|
|
154
|
+
* `PaymentIntent.charges`は`2022-11-15`で削除され、チャージは`latest_charge`
|
|
155
|
+
* (WebhookペイロードではID)で参照されます。展開済みのチャージはそのまま使い、
|
|
156
|
+
* それ以外はチャージを取得します。旧ペイロードでは従来の`charges.data[0]`に
|
|
157
|
+
* フォールバックします。取得エラーはログに出力し`null`を返すため、呼び出し側は
|
|
158
|
+
* 処理を続行できます。
|
|
159
|
+
*/
|
|
160
|
+
export declare function resolvePaymentIntentReceipt(options: {
|
|
161
|
+
stripeClient: Stripe;
|
|
162
|
+
paymentIntent: Stripe.PaymentIntent | StripeLooseObject;
|
|
163
|
+
}): Promise<StripePaymentIntentReceipt>;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveSubscriptionPeriod = resolveSubscriptionPeriod;
|
|
4
|
+
exports.resolveSubscriptionPurchaseFields = resolveSubscriptionPurchaseFields;
|
|
5
|
+
exports.resolvePaymentIntentReceipt = resolvePaymentIntentReceipt;
|
|
6
|
+
function toFiniteNumber(value) {
|
|
7
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
8
|
+
}
|
|
9
|
+
function firstDefined(...values) {
|
|
10
|
+
for (const value of values) {
|
|
11
|
+
if (value !== undefined && value !== null) {
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Resolve the current billing period of a subscription.
|
|
19
|
+
*
|
|
20
|
+
* Since `2025-03-31.basil` the period lives on each subscription item
|
|
21
|
+
* (`items.data[].current_period_*`). The earliest start and the latest end
|
|
22
|
+
* across items are returned. Falls back to the legacy top-level fields for
|
|
23
|
+
* payloads rendered with older API versions. Returns `null` instead of an
|
|
24
|
+
* invalid value when the period is unavailable.
|
|
25
|
+
*
|
|
26
|
+
* サブスクリプションの現在の請求期間を解決します。
|
|
27
|
+
*
|
|
28
|
+
* `2025-03-31.basil`以降、期間は各サブスクリプションアイテム
|
|
29
|
+
* (`items.data[].current_period_*`)に移動しました。アイテム間で最も早い開始と
|
|
30
|
+
* 最も遅い終了を返します。旧APIバージョンのペイロードでは従来のトップレベル
|
|
31
|
+
* フィールドにフォールバックします。期間が取得できない場合は不正値ではなく
|
|
32
|
+
* `null`を返します。
|
|
33
|
+
*/
|
|
34
|
+
function resolveSubscriptionPeriod(subscription) {
|
|
35
|
+
const source = subscription;
|
|
36
|
+
const items = Array.isArray(source?.["items"]?.["data"])
|
|
37
|
+
? source["items"]["data"]
|
|
38
|
+
: [];
|
|
39
|
+
const starts = items
|
|
40
|
+
.map((item) => toFiniteNumber(item?.["current_period_start"]))
|
|
41
|
+
.filter((value) => value !== null);
|
|
42
|
+
const ends = items
|
|
43
|
+
.map((item) => toFiniteNumber(item?.["current_period_end"]))
|
|
44
|
+
.filter((value) => value !== null);
|
|
45
|
+
return {
|
|
46
|
+
start: starts.length > 0
|
|
47
|
+
? Math.min(...starts)
|
|
48
|
+
: toFiniteNumber(source?.["current_period_start"]),
|
|
49
|
+
end: ends.length > 0
|
|
50
|
+
? Math.max(...ends)
|
|
51
|
+
: toFiniteNumber(source?.["current_period_end"]),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Build the subscription fields stored in the purchase document.
|
|
56
|
+
*
|
|
57
|
+
* Reads the price from the first subscription item (`items.data[0].price`)
|
|
58
|
+
* instead of the legacy `subscription.plan`, falling back to
|
|
59
|
+
* `items.data[0].plan` and `subscription.plan` for older payloads.
|
|
60
|
+
*
|
|
61
|
+
* 購入ドキュメントに保存するサブスクリプションのフィールドを構築します。
|
|
62
|
+
*
|
|
63
|
+
* 従来の`subscription.plan`ではなく最初のサブスクリプションアイテムの価格
|
|
64
|
+
* (`items.data[0].price`)を参照し、旧ペイロードでは`items.data[0].plan`と
|
|
65
|
+
* `subscription.plan`にフォールバックします。
|
|
66
|
+
*/
|
|
67
|
+
function resolveSubscriptionPurchaseFields(subscription) {
|
|
68
|
+
const source = subscription;
|
|
69
|
+
const period = resolveSubscriptionPeriod(source);
|
|
70
|
+
const item = (Array.isArray(source?.["items"]?.["data"])
|
|
71
|
+
? source["items"]["data"][0]
|
|
72
|
+
: undefined) ?? {};
|
|
73
|
+
const price = item["price"] && typeof item["price"] === "object"
|
|
74
|
+
? item["price"]
|
|
75
|
+
: {};
|
|
76
|
+
const plan = (item["plan"] && typeof item["plan"] === "object"
|
|
77
|
+
? item["plan"]
|
|
78
|
+
: undefined) ?? (source?.["plan"] && typeof source["plan"] === "object"
|
|
79
|
+
? source["plan"]
|
|
80
|
+
: undefined) ?? {};
|
|
81
|
+
const recurring = price["recurring"] ?? {};
|
|
82
|
+
return {
|
|
83
|
+
current_period_start: period.start,
|
|
84
|
+
current_period_end: period.end,
|
|
85
|
+
price_id: firstDefined(price["id"], plan["id"]),
|
|
86
|
+
active: firstDefined(price["active"], plan["active"]),
|
|
87
|
+
amount: firstDefined(price["unit_amount"], plan["amount"]),
|
|
88
|
+
billing_scheme: firstDefined(price["billing_scheme"], plan["billing_scheme"]),
|
|
89
|
+
interval: firstDefined(recurring["interval"], plan["interval"]),
|
|
90
|
+
interval_count: firstDefined(recurring["interval_count"], plan["interval_count"]),
|
|
91
|
+
usage_type: firstDefined(recurring["usage_type"], plan["usage_type"]),
|
|
92
|
+
quantity: firstDefined(item["quantity"], source?.["quantity"]),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Resolve the receipt URL and captured amount of a PaymentIntent.
|
|
97
|
+
*
|
|
98
|
+
* `PaymentIntent.charges` was removed in `2022-11-15`; the charge is now
|
|
99
|
+
* referenced by `latest_charge` (an ID in webhook payloads). An expanded
|
|
100
|
+
* charge is used as is, otherwise the charge is retrieved. The legacy
|
|
101
|
+
* `charges.data[0]` is used as a fallback for older payloads. Retrieval errors
|
|
102
|
+
* are logged and result in `null` values so the caller can still proceed.
|
|
103
|
+
*
|
|
104
|
+
* PaymentIntentの領収書URLとキャプチャ済み金額を解決します。
|
|
105
|
+
*
|
|
106
|
+
* `PaymentIntent.charges`は`2022-11-15`で削除され、チャージは`latest_charge`
|
|
107
|
+
* (WebhookペイロードではID)で参照されます。展開済みのチャージはそのまま使い、
|
|
108
|
+
* それ以外はチャージを取得します。旧ペイロードでは従来の`charges.data[0]`に
|
|
109
|
+
* フォールバックします。取得エラーはログに出力し`null`を返すため、呼び出し側は
|
|
110
|
+
* 処理を続行できます。
|
|
111
|
+
*/
|
|
112
|
+
async function resolvePaymentIntentReceipt(options) {
|
|
113
|
+
const source = options.paymentIntent;
|
|
114
|
+
const latestCharge = source?.["latest_charge"];
|
|
115
|
+
let charge = null;
|
|
116
|
+
if (latestCharge && typeof latestCharge === "object") {
|
|
117
|
+
charge = latestCharge;
|
|
118
|
+
}
|
|
119
|
+
else if (typeof latestCharge === "string" && latestCharge.length > 0) {
|
|
120
|
+
try {
|
|
121
|
+
charge = await options.stripeClient.charges.retrieve(latestCharge);
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
125
|
+
console.warn("stripe latest_charge retrieve failed", message.slice(0, 240));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (!charge) {
|
|
129
|
+
const legacy = source?.["charges"]?.["data"];
|
|
130
|
+
if (Array.isArray(legacy) && legacy.length > 0 && legacy[0]) {
|
|
131
|
+
charge = legacy[0];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const receiptUrl = charge?.["receipt_url"];
|
|
135
|
+
const capturedAmount = charge?.["amount_captured"];
|
|
136
|
+
return {
|
|
137
|
+
receiptUrl: typeof receiptUrl === "string" && receiptUrl.length > 0 ? receiptUrl : null,
|
|
138
|
+
capturedAmount: toFiniteNumber(capturedAmount),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=stripe_mapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe_mapping.js","sourceRoot":"","sources":["../../../src/lib/purchase/stripe_mapping.ts"],"names":[],"mappings":";;AAgIA,8DAqBC;AAeD,8EA6BC;AAwCD,kEA6BC;AApKD,SAAS,cAAc,CAAC,KAAc;IAClC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9E,CAAC;AAED,SAAS,YAAY,CAAI,GAAG,MAAmC;IAC3D,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACzB,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACxC,OAAO,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,yBAAyB,CACrC,YAAqD;IAErD,MAAM,MAAM,GAAG,YAAiC,CAAC;IACjD,MAAM,KAAK,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;QACV,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;QAC7C,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1D,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACvB,CAAC;IACL,CAAC;IACD,MAAM,UAAU,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,CAAC;IAC3C,MAAM,cAAc,GAAG,MAAM,EAAE,CAAC,iBAAiB,CAAC,CAAC;IACnD,OAAO;QACH,UAAU,EAAE,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI;QACvF,cAAc,EAAE,cAAc,CAAC,cAAc,CAAC;KACjD,CAAC;AACN,CAAC"}
|
|
@@ -6,7 +6,7 @@ import Stripe from "stripe";
|
|
|
6
6
|
* このパッケージ全体で使用するStripe APIバージョン
|
|
7
7
|
* (`@mathrunet/masamune_firebase_purchase_stripe`と同一)。
|
|
8
8
|
*/
|
|
9
|
-
export declare const STRIPE_API_VERSION = "
|
|
9
|
+
export declare const STRIPE_API_VERSION = "2026-08-26.dahlia";
|
|
10
10
|
/**
|
|
11
11
|
* Options for [createStripeClient].
|
|
12
12
|
*
|
|
@@ -14,7 +14,7 @@ const stripe_1 = __importDefault(require("stripe"));
|
|
|
14
14
|
* このパッケージ全体で使用するStripe APIバージョン
|
|
15
15
|
* (`@mathrunet/masamune_firebase_purchase_stripe`と同一)。
|
|
16
16
|
*/
|
|
17
|
-
exports.STRIPE_API_VERSION = "
|
|
17
|
+
exports.STRIPE_API_VERSION = "2026-08-26.dahlia";
|
|
18
18
|
/**
|
|
19
19
|
* Create a Stripe SDK client configured for Cloudflare Workers.
|
|
20
20
|
*
|
package/dist/purchase.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export * from "./lib/purchase/interface";
|
|
|
22
22
|
export * from "./lib/purchase/d1_purchase_store";
|
|
23
23
|
export * from "./lib/purchase/helpers";
|
|
24
24
|
export * from "./lib/purchase/sync_payment";
|
|
25
|
+
export * from "./lib/purchase/stripe_mapping";
|
|
25
26
|
/**
|
|
26
27
|
* Builder signature of the purchase workers (`stripe` / `stripeWebhook` /
|
|
27
28
|
* `stripeWebhookConnect` / `stripeWebhookSecure`).
|
package/dist/purchase.js
CHANGED
|
@@ -21,6 +21,7 @@ __exportStar(require("./lib/purchase/interface"), exports);
|
|
|
21
21
|
__exportStar(require("./lib/purchase/d1_purchase_store"), exports);
|
|
22
22
|
__exportStar(require("./lib/purchase/helpers"), exports);
|
|
23
23
|
__exportStar(require("./lib/purchase/sync_payment"), exports);
|
|
24
|
+
__exportStar(require("./lib/purchase/stripe_mapping"), exports);
|
|
24
25
|
/**
|
|
25
26
|
* Build the mode-based Stripe action handler onto a Hono app.
|
|
26
27
|
*
|
package/dist/purchase.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"purchase.js","sourceRoot":"","sources":["../src/purchase.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAmBA,gDAA8B;AAC9B,sDAAoC;AACpC,2DAAyC;AACzC,mEAAiD;AACjD,yDAAuC;AACvC,8DAA4C;
|
|
1
|
+
{"version":3,"file":"purchase.js","sourceRoot":"","sources":["../src/purchase.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAmBA,gDAA8B;AAC9B,sDAAoC;AACpC,2DAAyC;AACzC,mEAAiD;AACjD,yDAAuC;AACvC,8DAA4C;AAC5C,gEAA8C;AAe9C;;;;GAIG;AACU,QAAA,WAAW,GAAwB,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAE5E;;;;GAIG;AACU,QAAA,kBAAkB,GAAwB,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAE3F;;;;GAIG;AACU,QAAA,yBAAyB,GAAwB,OAAO,CAAC,kCAAkC,CAAC,CAAC;AAE1G;;;;GAIG;AACU,QAAA,wBAAwB,GAAwB,OAAO,CAAC,iCAAiC,CAAC,CAAC"}
|