@shware/purchase 0.1.19 → 0.2.1
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/dist/stripe/index.cjs +6 -2
- package/dist/stripe/index.cjs.map +1 -1
- package/dist/stripe/index.d.cts +1 -1
- package/dist/stripe/index.d.ts +1 -1
- package/dist/stripe/index.mjs +6 -2
- package/dist/stripe/index.mjs.map +1 -1
- package/dist/stripe/mapper.cjs +35 -3
- package/dist/stripe/mapper.cjs.map +1 -1
- package/dist/stripe/mapper.d.cts +26 -2
- package/dist/stripe/mapper.d.ts +26 -2
- package/dist/stripe/mapper.mjs +32 -2
- package/dist/stripe/mapper.mjs.map +1 -1
- package/package.json +1 -1
package/dist/stripe/index.cjs
CHANGED
|
@@ -25,10 +25,12 @@ __export(stripe_exports, {
|
|
|
25
25
|
checkoutSessionSchema: () => import_schema.checkoutSessionSchema,
|
|
26
26
|
getBeginCheckoutProperties: () => import_mapper.getBeginCheckoutProperties,
|
|
27
27
|
getPurchaseProperties: () => import_mapper.getPurchaseProperties,
|
|
28
|
+
mapCharge: () => import_mapper.mapCharge,
|
|
28
29
|
mapCheckoutSession: () => import_mapper.mapCheckoutSession,
|
|
29
30
|
mapInvoice: () => import_mapper.mapInvoice,
|
|
30
31
|
mapLineItem: () => import_mapper.mapLineItem,
|
|
31
|
-
|
|
32
|
+
mapPaymentIntent: () => import_mapper.mapPaymentIntent,
|
|
33
|
+
mapSubscriptionStatus: () => import_mapper.mapSubscriptionStatus,
|
|
32
34
|
mapTime: () => import_mapper.mapTime,
|
|
33
35
|
minorUnits: () => import_mapper.minorUnits,
|
|
34
36
|
price: () => import_mapper.price
|
|
@@ -44,10 +46,12 @@ var import_metadata = require("./metadata.cjs");
|
|
|
44
46
|
checkoutSessionSchema,
|
|
45
47
|
getBeginCheckoutProperties,
|
|
46
48
|
getPurchaseProperties,
|
|
49
|
+
mapCharge,
|
|
47
50
|
mapCheckoutSession,
|
|
48
51
|
mapInvoice,
|
|
49
52
|
mapLineItem,
|
|
50
|
-
|
|
53
|
+
mapPaymentIntent,
|
|
54
|
+
mapSubscriptionStatus,
|
|
51
55
|
mapTime,
|
|
52
56
|
minorUnits,
|
|
53
57
|
price
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/stripe/index.ts"],"sourcesContent":["export {\n mapTime,\n
|
|
1
|
+
{"version":3,"sources":["../../src/stripe/index.ts"],"sourcesContent":["export {\n mapTime,\n mapCharge,\n mapInvoice,\n mapLineItem,\n mapPaymentIntent,\n mapCheckoutSession,\n mapSubscriptionStatus,\n minorUnits,\n price,\n getPurchaseProperties,\n getBeginCheckoutProperties,\n type CheckoutSession,\n type PurchaseProperties,\n type ProductPrice,\n type BeginCheckoutProperties,\n} from './mapper';\nexport {\n cancellationDetailsSchema,\n checkoutSessionSchema,\n type CancellationDetails,\n} from './schema';\nexport type { ProductId, PriceId, Config, CreateCheckoutSessionDTO } from './types';\nexport { METADATA_KEYS } from './metadata';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAgBO;AACP,oBAIO;AAEP,sBAA8B;","names":[]}
|
package/dist/stripe/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { BeginCheckoutProperties, CheckoutSession, ProductPrice, PurchaseProperties, getBeginCheckoutProperties, getPurchaseProperties, mapCheckoutSession, mapInvoice, mapLineItem,
|
|
1
|
+
export { BeginCheckoutProperties, CheckoutSession, ProductPrice, PurchaseProperties, getBeginCheckoutProperties, getPurchaseProperties, mapCharge, mapCheckoutSession, mapInvoice, mapLineItem, mapPaymentIntent, mapSubscriptionStatus, mapTime, minorUnits, price } from './mapper.cjs';
|
|
2
2
|
export { CancellationDetails, cancellationDetailsSchema, checkoutSessionSchema } from './schema.cjs';
|
|
3
3
|
export { Config, CreateCheckoutSessionDTO, PriceId, ProductId } from './types.cjs';
|
|
4
4
|
export { METADATA_KEYS } from './metadata.cjs';
|
package/dist/stripe/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { BeginCheckoutProperties, CheckoutSession, ProductPrice, PurchaseProperties, getBeginCheckoutProperties, getPurchaseProperties, mapCheckoutSession, mapInvoice, mapLineItem,
|
|
1
|
+
export { BeginCheckoutProperties, CheckoutSession, ProductPrice, PurchaseProperties, getBeginCheckoutProperties, getPurchaseProperties, mapCharge, mapCheckoutSession, mapInvoice, mapLineItem, mapPaymentIntent, mapSubscriptionStatus, mapTime, minorUnits, price } from './mapper.js';
|
|
2
2
|
export { CancellationDetails, cancellationDetailsSchema, checkoutSessionSchema } from './schema.js';
|
|
3
3
|
export { Config, CreateCheckoutSessionDTO, PriceId, ProductId } from './types.js';
|
|
4
4
|
export { METADATA_KEYS } from './metadata.js';
|
package/dist/stripe/index.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// src/stripe/index.ts
|
|
2
2
|
import {
|
|
3
3
|
mapTime,
|
|
4
|
-
|
|
4
|
+
mapCharge,
|
|
5
5
|
mapInvoice,
|
|
6
6
|
mapLineItem,
|
|
7
|
+
mapPaymentIntent,
|
|
7
8
|
mapCheckoutSession,
|
|
9
|
+
mapSubscriptionStatus,
|
|
8
10
|
minorUnits,
|
|
9
11
|
price,
|
|
10
12
|
getPurchaseProperties,
|
|
@@ -21,10 +23,12 @@ export {
|
|
|
21
23
|
checkoutSessionSchema,
|
|
22
24
|
getBeginCheckoutProperties,
|
|
23
25
|
getPurchaseProperties,
|
|
26
|
+
mapCharge,
|
|
24
27
|
mapCheckoutSession,
|
|
25
28
|
mapInvoice,
|
|
26
29
|
mapLineItem,
|
|
27
|
-
|
|
30
|
+
mapPaymentIntent,
|
|
31
|
+
mapSubscriptionStatus,
|
|
28
32
|
mapTime,
|
|
29
33
|
minorUnits,
|
|
30
34
|
price
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/stripe/index.ts"],"sourcesContent":["export {\n mapTime,\n
|
|
1
|
+
{"version":3,"sources":["../../src/stripe/index.ts"],"sourcesContent":["export {\n mapTime,\n mapCharge,\n mapInvoice,\n mapLineItem,\n mapPaymentIntent,\n mapCheckoutSession,\n mapSubscriptionStatus,\n minorUnits,\n price,\n getPurchaseProperties,\n getBeginCheckoutProperties,\n type CheckoutSession,\n type PurchaseProperties,\n type ProductPrice,\n type BeginCheckoutProperties,\n} from './mapper';\nexport {\n cancellationDetailsSchema,\n checkoutSessionSchema,\n type CancellationDetails,\n} from './schema';\nexport type { ProductId, PriceId, Config, CreateCheckoutSessionDTO } from './types';\nexport { METADATA_KEYS } from './metadata';\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,qBAAqB;","names":[]}
|
package/dist/stripe/mapper.cjs
CHANGED
|
@@ -23,10 +23,12 @@ __export(mapper_exports, {
|
|
|
23
23
|
ZERO_DECIMAL_CURRENCIES: () => ZERO_DECIMAL_CURRENCIES,
|
|
24
24
|
getBeginCheckoutProperties: () => getBeginCheckoutProperties,
|
|
25
25
|
getPurchaseProperties: () => getPurchaseProperties,
|
|
26
|
+
mapCharge: () => mapCharge,
|
|
26
27
|
mapCheckoutSession: () => mapCheckoutSession,
|
|
27
28
|
mapInvoice: () => mapInvoice,
|
|
28
29
|
mapLineItem: () => mapLineItem,
|
|
29
|
-
|
|
30
|
+
mapPaymentIntent: () => mapPaymentIntent,
|
|
31
|
+
mapSubscriptionStatus: () => mapSubscriptionStatus,
|
|
30
32
|
mapTime: () => mapTime,
|
|
31
33
|
minorUnits: () => minorUnits,
|
|
32
34
|
price: () => price
|
|
@@ -94,7 +96,35 @@ function mapInvoice(i) {
|
|
|
94
96
|
period_end: i.period_end
|
|
95
97
|
};
|
|
96
98
|
}
|
|
97
|
-
function
|
|
99
|
+
function mapPaymentIntent(intent) {
|
|
100
|
+
return {
|
|
101
|
+
id: intent.id,
|
|
102
|
+
amount: intent.amount,
|
|
103
|
+
amount_capturable: intent.amount_capturable,
|
|
104
|
+
amount_received: intent.amount_received,
|
|
105
|
+
currency: intent.currency,
|
|
106
|
+
client_secret: intent.client_secret,
|
|
107
|
+
description: intent.description,
|
|
108
|
+
status: intent.status,
|
|
109
|
+
created: intent.created
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function mapCharge(charge) {
|
|
113
|
+
return {
|
|
114
|
+
id: charge.id,
|
|
115
|
+
description: charge.description,
|
|
116
|
+
currency: charge.currency,
|
|
117
|
+
amount: charge.amount,
|
|
118
|
+
amount_captured: charge.amount_captured,
|
|
119
|
+
amount_refunded: charge.amount_refunded,
|
|
120
|
+
receipt_email: charge.receipt_email,
|
|
121
|
+
receipt_number: charge.receipt_number,
|
|
122
|
+
receipt_url: charge.receipt_url,
|
|
123
|
+
status: charge.status,
|
|
124
|
+
created: charge.created
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function mapSubscriptionStatus(status) {
|
|
98
128
|
switch (status) {
|
|
99
129
|
case "active":
|
|
100
130
|
return import_subscription.SubscriptionStatus.ACTIVE;
|
|
@@ -185,10 +215,12 @@ function getBeginCheckoutProperties(p) {
|
|
|
185
215
|
ZERO_DECIMAL_CURRENCIES,
|
|
186
216
|
getBeginCheckoutProperties,
|
|
187
217
|
getPurchaseProperties,
|
|
218
|
+
mapCharge,
|
|
188
219
|
mapCheckoutSession,
|
|
189
220
|
mapInvoice,
|
|
190
221
|
mapLineItem,
|
|
191
|
-
|
|
222
|
+
mapPaymentIntent,
|
|
223
|
+
mapSubscriptionStatus,
|
|
192
224
|
mapTime,
|
|
193
225
|
minorUnits,
|
|
194
226
|
price
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/stripe/mapper.ts"],"sourcesContent":["import { SubscriptionStatus } from '../subscription/index';\nimport type Stripe from 'stripe';\n\nexport function mapTime<T extends number | null>(\n stripeTimestampSeconds: T\n): T extends number ? string : null {\n if (!stripeTimestampSeconds) return null as T extends number ? string : null;\n return new Date(stripeTimestampSeconds * 1000).toISOString() as T extends number ? string : null;\n}\n\nexport function mapLineItem(item: Stripe.LineItem) {\n return {\n id: item.price\n ? typeof item.price.product === 'string'\n ? item.price.product\n : item.price.product.id\n : item.id,\n currency: item.currency,\n quantity: item.quantity,\n description: item.description,\n amount_tax: item.amount_tax,\n amount_total: item.amount_total,\n amount_subtotal: item.amount_subtotal,\n amount_discount: item.amount_discount,\n price: item.price ? { id: item.price.id } : null,\n };\n}\n\nexport function mapCheckoutSession(session: Stripe.Checkout.Session) {\n let coupon: string | undefined = undefined;\n if (Array.isArray(session.discounts) && session.discounts.length !== 0) {\n const discount = session.discounts[0];\n if (discount.coupon && typeof discount.coupon === 'object') {\n coupon = discount.coupon.id;\n } else if (typeof discount.coupon === 'string') {\n coupon = discount.coupon;\n } else {\n coupon = undefined;\n }\n }\n\n return {\n id: session.id,\n url: session.url,\n coupon,\n livemode: session.livemode,\n expires_at: session.expires_at,\n payment_status: session.payment_status,\n currency: session.currency,\n amount_total: session.amount_total,\n line_items: session.line_items?.data.map(mapLineItem),\n };\n}\n\nexport function mapInvoice(i: Stripe.Invoice) {\n return {\n id: i.id,\n number: i.number,\n total: i.total,\n subtotal: i.subtotal,\n amount_due: i.amount_due,\n amount_paid: i.amount_paid,\n amount_remaining: i.amount_remaining,\n currency: i.currency,\n billing_reason: i.billing_reason,\n hosted_invoice_url: i.hosted_invoice_url,\n invoice_pdf: i.invoice_pdf,\n receipt_number: i.receipt_number,\n status: i.status,\n created: i.created,\n period_start: i.period_start,\n period_end: i.period_end,\n };\n}\n\nexport type CheckoutSession = ReturnType<typeof mapCheckoutSession>;\nexport type ProductPrice = {\n id: string;\n type: Stripe.Price.Type;\n unit_amount: number;\n currency: Stripe.Price['currency'];\n product: {\n id: Stripe.Product['id'];\n name: Stripe.Product['name'];\n description: Stripe.Product['description'];\n livemode: Stripe.Product['livemode'];\n };\n};\n\nexport function mapStatus(status: Stripe.Subscription.Status): SubscriptionStatus {\n switch (status) {\n case 'active':\n return SubscriptionStatus.ACTIVE;\n case 'canceled':\n return SubscriptionStatus.CANCELED;\n case 'incomplete':\n return SubscriptionStatus.INCOMPLETE;\n case 'incomplete_expired':\n return SubscriptionStatus.INCOMPLETE_EXPIRED;\n case 'past_due':\n return SubscriptionStatus.PAST_DUE;\n case 'paused':\n return SubscriptionStatus.PAUSED;\n case 'trialing':\n return SubscriptionStatus.TRIALING;\n case 'unpaid':\n return SubscriptionStatus.UNPAID;\n default: {\n console.error(`Invalid stripe status: ${status}`);\n throw new Error(`Invalid stripe status: ${status}`);\n }\n }\n}\n\nexport const ZERO_DECIMAL_CURRENCIES = [\n 'BIF',\n 'CLP',\n 'DJF',\n 'GNF',\n 'JPY',\n 'KMF',\n 'KRW',\n 'MGA',\n 'PYG',\n 'RWF',\n 'UGX',\n 'VND',\n 'VUV',\n 'XAF',\n 'XOF',\n 'XPF',\n];\n\nexport function minorUnits(currency: string) {\n return ZERO_DECIMAL_CURRENCIES.includes(currency.toUpperCase()) ? 1 : 100;\n}\n\nexport function price(value: number, currency: string) {\n return value / minorUnits(currency);\n}\nexport interface Item {\n item_id: string;\n item_name: string;\n affiliation?: 'Google Store' | (string & {});\n coupon?: string;\n discount?: number;\n index?: number;\n item_brand?: string;\n item_category?: string;\n item_category2?: string;\n item_category3?: string;\n item_category4?: string;\n item_category5?: string;\n item_list_id?: string;\n item_list_name?: string;\n item_variant?: string;\n location_id?: string;\n price?: number;\n quantity?: number;\n}\n\nexport interface PurchaseProperties {\n currency: string;\n value: number;\n transaction_id: string;\n coupon?: string;\n shipping?: number;\n tax?: number;\n items?: Item[];\n}\n\nexport interface BeginCheckoutProperties {\n currency: string;\n value: number;\n coupon?: string;\n items: Item[];\n}\n\nexport function getPurchaseProperties(session: CheckoutSession): PurchaseProperties {\n let value: number;\n let currency: string;\n if (!session.amount_total || !session.currency) {\n value = session.line_items?.reduce((acc, item) => acc + (item.amount_total ?? 0), 0) ?? 0;\n currency = session.line_items?.[0]?.currency ?? 'usd';\n } else {\n value = session.amount_total;\n currency = session.currency;\n }\n\n return {\n transaction_id: session.id,\n value: price(value, currency),\n currency: currency.toUpperCase(),\n coupon: session.coupon,\n items: session.line_items?.map((item, index) => ({\n index,\n item_id: item.id,\n item_name: item.description ?? '',\n price: price(item.amount_total, item.currency),\n quantity: item.quantity ?? 1,\n discount: price(item.amount_discount, item.currency),\n })),\n };\n}\n\nexport function getBeginCheckoutProperties(p: ProductPrice): BeginCheckoutProperties {\n return {\n currency: p.currency.toUpperCase(),\n value: price(p.unit_amount, p.currency),\n items: [\n {\n item_id: p.product.id,\n item_name: p.product.name,\n price: price(p.unit_amount, p.currency),\n },\n ],\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAmC;AAG5B,SAAS,QACd,wBACkC;AAClC,MAAI,CAAC,uBAAwB,QAAO;AACpC,SAAO,IAAI,KAAK,yBAAyB,GAAI,EAAE,YAAY;AAC7D;AAEO,SAAS,YAAY,MAAuB;AACjD,SAAO;AAAA,IACL,IAAI,KAAK,QACL,OAAO,KAAK,MAAM,YAAY,WAC5B,KAAK,MAAM,UACX,KAAK,MAAM,QAAQ,KACrB,KAAK;AAAA,IACT,UAAU,KAAK;AAAA,IACf,UAAU,KAAK;AAAA,IACf,aAAa,KAAK;AAAA,IAClB,YAAY,KAAK;AAAA,IACjB,cAAc,KAAK;AAAA,IACnB,iBAAiB,KAAK;AAAA,IACtB,iBAAiB,KAAK;AAAA,IACtB,OAAO,KAAK,QAAQ,EAA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AS,KAAK;AAAA,MACd,WAAW,KAAK,eAAe;AAAA,MAC/B,OAAO,MAAM,KAAK,cAAc,KAAK,QAAQ;AAAA,MAC7C,UAAU,KAAK,YAAY;AAAA,MAC3B,UAAU,MAAM,KAAK,iBAAiB,KAAK,QAAQ;AAAA,IACrD,EAAE;AAAA,EACJ;AACF;AAEO,SAAS,2BAA2B,GAA0C;AACnF,SAAO;AAAA,IACL,UAAU,EAAE,SAAS,YAAY;AAAA,IACjC,OAAO,MAAM,EAAE,aAAa,EAAE,QAAQ;AAAA,IACtC,OAAO;AAAA,MACL;AAAA,QACE,SAAS,EAAE,QAAQ;AAAA,QACnB,WAAW,EAAE,QAAQ;AAAA,QACrB,OAAO,MAAM,EAAE,aAAa,EAAE,QAAQ;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/stripe/mapper.ts"],"sourcesContent":["import { SubscriptionStatus } from '../subscription/index';\nimport type Stripe from 'stripe';\n\nexport function mapTime<T extends number | null>(\n stripeTimestampSeconds: T\n): T extends number ? string : null {\n if (!stripeTimestampSeconds) return null as T extends number ? string : null;\n return new Date(stripeTimestampSeconds * 1000).toISOString() as T extends number ? string : null;\n}\n\nexport function mapLineItem(item: Stripe.LineItem) {\n return {\n id: item.price\n ? typeof item.price.product === 'string'\n ? item.price.product\n : item.price.product.id\n : item.id,\n currency: item.currency,\n quantity: item.quantity,\n description: item.description,\n amount_tax: item.amount_tax,\n amount_total: item.amount_total,\n amount_subtotal: item.amount_subtotal,\n amount_discount: item.amount_discount,\n price: item.price ? { id: item.price.id } : null,\n };\n}\n\nexport function mapCheckoutSession(session: Stripe.Checkout.Session) {\n let coupon: string | undefined = undefined;\n if (Array.isArray(session.discounts) && session.discounts.length !== 0) {\n const discount = session.discounts[0];\n if (discount.coupon && typeof discount.coupon === 'object') {\n coupon = discount.coupon.id;\n } else if (typeof discount.coupon === 'string') {\n coupon = discount.coupon;\n } else {\n coupon = undefined;\n }\n }\n\n return {\n id: session.id,\n url: session.url,\n coupon,\n livemode: session.livemode,\n expires_at: session.expires_at,\n payment_status: session.payment_status,\n currency: session.currency,\n amount_total: session.amount_total,\n line_items: session.line_items?.data.map(mapLineItem),\n };\n}\n\nexport function mapInvoice(i: Stripe.Invoice) {\n return {\n id: i.id,\n number: i.number,\n total: i.total,\n subtotal: i.subtotal,\n amount_due: i.amount_due,\n amount_paid: i.amount_paid,\n amount_remaining: i.amount_remaining,\n currency: i.currency,\n billing_reason: i.billing_reason,\n hosted_invoice_url: i.hosted_invoice_url,\n invoice_pdf: i.invoice_pdf,\n receipt_number: i.receipt_number,\n status: i.status,\n created: i.created,\n period_start: i.period_start,\n period_end: i.period_end,\n };\n}\n\nexport function mapPaymentIntent(intent: Stripe.PaymentIntent) {\n return {\n id: intent.id,\n amount: intent.amount,\n amount_capturable: intent.amount_capturable,\n amount_received: intent.amount_received,\n currency: intent.currency,\n client_secret: intent.client_secret,\n description: intent.description,\n status: intent.status,\n created: intent.created,\n };\n}\n\nexport function mapCharge(charge: Stripe.Charge) {\n return {\n id: charge.id,\n description: charge.description,\n currency: charge.currency,\n amount: charge.amount,\n amount_captured: charge.amount_captured,\n amount_refunded: charge.amount_refunded,\n receipt_email: charge.receipt_email,\n receipt_number: charge.receipt_number,\n receipt_url: charge.receipt_url,\n status: charge.status,\n created: charge.created,\n };\n}\n\nexport type CheckoutSession = ReturnType<typeof mapCheckoutSession>;\nexport type ProductPrice = {\n id: string;\n type: Stripe.Price.Type;\n unit_amount: number;\n currency: Stripe.Price['currency'];\n product: {\n id: Stripe.Product['id'];\n name: Stripe.Product['name'];\n description: Stripe.Product['description'];\n livemode: Stripe.Product['livemode'];\n };\n};\n\nexport function mapSubscriptionStatus(status: Stripe.Subscription.Status): SubscriptionStatus {\n switch (status) {\n case 'active':\n return SubscriptionStatus.ACTIVE;\n case 'canceled':\n return SubscriptionStatus.CANCELED;\n case 'incomplete':\n return SubscriptionStatus.INCOMPLETE;\n case 'incomplete_expired':\n return SubscriptionStatus.INCOMPLETE_EXPIRED;\n case 'past_due':\n return SubscriptionStatus.PAST_DUE;\n case 'paused':\n return SubscriptionStatus.PAUSED;\n case 'trialing':\n return SubscriptionStatus.TRIALING;\n case 'unpaid':\n return SubscriptionStatus.UNPAID;\n default: {\n console.error(`Invalid stripe status: ${status}`);\n throw new Error(`Invalid stripe status: ${status}`);\n }\n }\n}\n\nexport const ZERO_DECIMAL_CURRENCIES = [\n 'BIF',\n 'CLP',\n 'DJF',\n 'GNF',\n 'JPY',\n 'KMF',\n 'KRW',\n 'MGA',\n 'PYG',\n 'RWF',\n 'UGX',\n 'VND',\n 'VUV',\n 'XAF',\n 'XOF',\n 'XPF',\n];\n\nexport function minorUnits(currency: string) {\n return ZERO_DECIMAL_CURRENCIES.includes(currency.toUpperCase()) ? 1 : 100;\n}\n\nexport function price(value: number, currency: string) {\n return value / minorUnits(currency);\n}\n\nexport interface Item {\n item_id: string;\n item_name: string;\n affiliation?: 'Google Store' | (string & {});\n coupon?: string;\n discount?: number;\n index?: number;\n item_brand?: string;\n item_category?: string;\n item_category2?: string;\n item_category3?: string;\n item_category4?: string;\n item_category5?: string;\n item_list_id?: string;\n item_list_name?: string;\n item_variant?: string;\n location_id?: string;\n price?: number;\n quantity?: number;\n}\n\nexport interface PurchaseProperties {\n currency: string;\n value: number;\n transaction_id: string;\n coupon?: string;\n shipping?: number;\n tax?: number;\n items?: Item[];\n}\n\nexport interface BeginCheckoutProperties {\n currency: string;\n value: number;\n coupon?: string;\n items: Item[];\n}\n\nexport function getPurchaseProperties(session: CheckoutSession): PurchaseProperties {\n let value: number;\n let currency: string;\n if (!session.amount_total || !session.currency) {\n value = session.line_items?.reduce((acc, item) => acc + (item.amount_total ?? 0), 0) ?? 0;\n currency = session.line_items?.[0]?.currency ?? 'usd';\n } else {\n value = session.amount_total;\n currency = session.currency;\n }\n\n return {\n transaction_id: session.id,\n value: price(value, currency),\n currency: currency.toUpperCase(),\n coupon: session.coupon,\n items: session.line_items?.map((item, index) => ({\n index,\n item_id: item.id,\n item_name: item.description ?? '',\n price: price(item.amount_total, item.currency),\n quantity: item.quantity ?? 1,\n discount: price(item.amount_discount, item.currency),\n })),\n };\n}\n\nexport function getBeginCheckoutProperties(p: ProductPrice): BeginCheckoutProperties {\n return {\n currency: p.currency.toUpperCase(),\n value: price(p.unit_amount, p.currency),\n items: [\n {\n item_id: p.product.id,\n item_name: p.product.name,\n price: price(p.unit_amount, p.currency),\n },\n ],\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAmC;AAG5B,SAAS,QACd,wBACkC;AAClC,MAAI,CAAC,uBAAwB,QAAO;AACpC,SAAO,IAAI,KAAK,yBAAyB,GAAI,EAAE,YAAY;AAC7D;AAEO,SAAS,YAAY,MAAuB;AACjD,SAAO;AAAA,IACL,IAAI,KAAK,QACL,OAAO,KAAK,MAAM,YAAY,WAC5B,KAAK,MAAM,UACX,KAAK,MAAM,QAAQ,KACrB,KAAK;AAAA,IACT,UAAU,KAAK;AAAA,IACf,UAAU,KAAK;AAAA,IACf,aAAa,KAAK;AAAA,IAClB,YAAY,KAAK;AAAA,IACjB,cAAc,KAAK;AAAA,IACnB,iBAAiB,KAAK;AAAA,IACtB,iBAAiB,KAAK;AAAA,IACtB,OAAO,KAAK,QAAQ,EAAE,IAAI,KAAK,MAAM,GAAG,IAAI;AAAA,EAC9C;AACF;AAEO,SAAS,mBAAmB,SAAkC;AACnE,MAAI,SAA6B;AACjC,MAAI,MAAM,QAAQ,QAAQ,SAAS,KAAK,QAAQ,UAAU,WAAW,GAAG;AACtE,UAAM,WAAW,QAAQ,UAAU,CAAC;AACpC,QAAI,SAAS,UAAU,OAAO,SAAS,WAAW,UAAU;AAC1D,eAAS,SAAS,OAAO;AAAA,IAC3B,WAAW,OAAO,SAAS,WA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AG,YAAY;AAAA,EAClD,OAAO;AACL,YAAQ,QAAQ;AAChB,eAAW,QAAQ;AAAA,EACrB;AAEA,SAAO;AAAA,IACL,gBAAgB,QAAQ;AAAA,IACxB,OAAO,MAAM,OAAO,QAAQ;AAAA,IAC5B,UAAU,SAAS,YAAY;AAAA,IAC/B,QAAQ,QAAQ;AAAA,IAChB,OAAO,QAAQ,YAAY,IAAI,CAAC,MAAM,WAAW;AAAA,MAC/C;AAAA,MACA,SAAS,KAAK;AAAA,MACd,WAAW,KAAK,eAAe;AAAA,MAC/B,OAAO,MAAM,KAAK,cAAc,KAAK,QAAQ;AAAA,MAC7C,UAAU,KAAK,YAAY;AAAA,MAC3B,UAAU,MAAM,KAAK,iBAAiB,KAAK,QAAQ;AAAA,IACrD,EAAE;AAAA,EACJ;AACF;AAEO,SAAS,2BAA2B,GAA0C;AACnF,SAAO;AAAA,IACL,UAAU,EAAE,SAAS,YAAY;AAAA,IACjC,OAAO,MAAM,EAAE,aAAa,EAAE,QAAQ;AAAA,IACtC,OAAO;AAAA,MACL;AAAA,QACE,SAAS,EAAE,QAAQ;AAAA,QACnB,WAAW,EAAE,QAAQ;AAAA,QACrB,OAAO,MAAM,EAAE,aAAa,EAAE,QAAQ;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/dist/stripe/mapper.d.cts
CHANGED
|
@@ -56,6 +56,30 @@ declare function mapInvoice(i: Stripe.Invoice): {
|
|
|
56
56
|
period_start: number;
|
|
57
57
|
period_end: number;
|
|
58
58
|
};
|
|
59
|
+
declare function mapPaymentIntent(intent: Stripe.PaymentIntent): {
|
|
60
|
+
id: string;
|
|
61
|
+
amount: number;
|
|
62
|
+
amount_capturable: number;
|
|
63
|
+
amount_received: number;
|
|
64
|
+
currency: string;
|
|
65
|
+
client_secret: string | null;
|
|
66
|
+
description: string | null;
|
|
67
|
+
status: Stripe.PaymentIntent.Status;
|
|
68
|
+
created: number;
|
|
69
|
+
};
|
|
70
|
+
declare function mapCharge(charge: Stripe.Charge): {
|
|
71
|
+
id: string;
|
|
72
|
+
description: string | null;
|
|
73
|
+
currency: string;
|
|
74
|
+
amount: number;
|
|
75
|
+
amount_captured: number;
|
|
76
|
+
amount_refunded: number;
|
|
77
|
+
receipt_email: string | null;
|
|
78
|
+
receipt_number: string | null;
|
|
79
|
+
receipt_url: string | null;
|
|
80
|
+
status: Stripe.Charge.Status;
|
|
81
|
+
created: number;
|
|
82
|
+
};
|
|
59
83
|
type CheckoutSession = ReturnType<typeof mapCheckoutSession>;
|
|
60
84
|
type ProductPrice = {
|
|
61
85
|
id: string;
|
|
@@ -69,7 +93,7 @@ type ProductPrice = {
|
|
|
69
93
|
livemode: Stripe.Product['livemode'];
|
|
70
94
|
};
|
|
71
95
|
};
|
|
72
|
-
declare function
|
|
96
|
+
declare function mapSubscriptionStatus(status: Stripe.Subscription.Status): SubscriptionStatus;
|
|
73
97
|
declare const ZERO_DECIMAL_CURRENCIES: string[];
|
|
74
98
|
declare function minorUnits(currency: string): 1 | 100;
|
|
75
99
|
declare function price(value: number, currency: string): number;
|
|
@@ -111,4 +135,4 @@ interface BeginCheckoutProperties {
|
|
|
111
135
|
declare function getPurchaseProperties(session: CheckoutSession): PurchaseProperties;
|
|
112
136
|
declare function getBeginCheckoutProperties(p: ProductPrice): BeginCheckoutProperties;
|
|
113
137
|
|
|
114
|
-
export { type BeginCheckoutProperties, type CheckoutSession, type Item, type ProductPrice, type PurchaseProperties, ZERO_DECIMAL_CURRENCIES, getBeginCheckoutProperties, getPurchaseProperties, mapCheckoutSession, mapInvoice, mapLineItem,
|
|
138
|
+
export { type BeginCheckoutProperties, type CheckoutSession, type Item, type ProductPrice, type PurchaseProperties, ZERO_DECIMAL_CURRENCIES, getBeginCheckoutProperties, getPurchaseProperties, mapCharge, mapCheckoutSession, mapInvoice, mapLineItem, mapPaymentIntent, mapSubscriptionStatus, mapTime, minorUnits, price };
|
package/dist/stripe/mapper.d.ts
CHANGED
|
@@ -56,6 +56,30 @@ declare function mapInvoice(i: Stripe.Invoice): {
|
|
|
56
56
|
period_start: number;
|
|
57
57
|
period_end: number;
|
|
58
58
|
};
|
|
59
|
+
declare function mapPaymentIntent(intent: Stripe.PaymentIntent): {
|
|
60
|
+
id: string;
|
|
61
|
+
amount: number;
|
|
62
|
+
amount_capturable: number;
|
|
63
|
+
amount_received: number;
|
|
64
|
+
currency: string;
|
|
65
|
+
client_secret: string | null;
|
|
66
|
+
description: string | null;
|
|
67
|
+
status: Stripe.PaymentIntent.Status;
|
|
68
|
+
created: number;
|
|
69
|
+
};
|
|
70
|
+
declare function mapCharge(charge: Stripe.Charge): {
|
|
71
|
+
id: string;
|
|
72
|
+
description: string | null;
|
|
73
|
+
currency: string;
|
|
74
|
+
amount: number;
|
|
75
|
+
amount_captured: number;
|
|
76
|
+
amount_refunded: number;
|
|
77
|
+
receipt_email: string | null;
|
|
78
|
+
receipt_number: string | null;
|
|
79
|
+
receipt_url: string | null;
|
|
80
|
+
status: Stripe.Charge.Status;
|
|
81
|
+
created: number;
|
|
82
|
+
};
|
|
59
83
|
type CheckoutSession = ReturnType<typeof mapCheckoutSession>;
|
|
60
84
|
type ProductPrice = {
|
|
61
85
|
id: string;
|
|
@@ -69,7 +93,7 @@ type ProductPrice = {
|
|
|
69
93
|
livemode: Stripe.Product['livemode'];
|
|
70
94
|
};
|
|
71
95
|
};
|
|
72
|
-
declare function
|
|
96
|
+
declare function mapSubscriptionStatus(status: Stripe.Subscription.Status): SubscriptionStatus;
|
|
73
97
|
declare const ZERO_DECIMAL_CURRENCIES: string[];
|
|
74
98
|
declare function minorUnits(currency: string): 1 | 100;
|
|
75
99
|
declare function price(value: number, currency: string): number;
|
|
@@ -111,4 +135,4 @@ interface BeginCheckoutProperties {
|
|
|
111
135
|
declare function getPurchaseProperties(session: CheckoutSession): PurchaseProperties;
|
|
112
136
|
declare function getBeginCheckoutProperties(p: ProductPrice): BeginCheckoutProperties;
|
|
113
137
|
|
|
114
|
-
export { type BeginCheckoutProperties, type CheckoutSession, type Item, type ProductPrice, type PurchaseProperties, ZERO_DECIMAL_CURRENCIES, getBeginCheckoutProperties, getPurchaseProperties, mapCheckoutSession, mapInvoice, mapLineItem,
|
|
138
|
+
export { type BeginCheckoutProperties, type CheckoutSession, type Item, type ProductPrice, type PurchaseProperties, ZERO_DECIMAL_CURRENCIES, getBeginCheckoutProperties, getPurchaseProperties, mapCharge, mapCheckoutSession, mapInvoice, mapLineItem, mapPaymentIntent, mapSubscriptionStatus, mapTime, minorUnits, price };
|
package/dist/stripe/mapper.mjs
CHANGED
|
@@ -61,7 +61,35 @@ function mapInvoice(i) {
|
|
|
61
61
|
period_end: i.period_end
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function mapPaymentIntent(intent) {
|
|
65
|
+
return {
|
|
66
|
+
id: intent.id,
|
|
67
|
+
amount: intent.amount,
|
|
68
|
+
amount_capturable: intent.amount_capturable,
|
|
69
|
+
amount_received: intent.amount_received,
|
|
70
|
+
currency: intent.currency,
|
|
71
|
+
client_secret: intent.client_secret,
|
|
72
|
+
description: intent.description,
|
|
73
|
+
status: intent.status,
|
|
74
|
+
created: intent.created
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function mapCharge(charge) {
|
|
78
|
+
return {
|
|
79
|
+
id: charge.id,
|
|
80
|
+
description: charge.description,
|
|
81
|
+
currency: charge.currency,
|
|
82
|
+
amount: charge.amount,
|
|
83
|
+
amount_captured: charge.amount_captured,
|
|
84
|
+
amount_refunded: charge.amount_refunded,
|
|
85
|
+
receipt_email: charge.receipt_email,
|
|
86
|
+
receipt_number: charge.receipt_number,
|
|
87
|
+
receipt_url: charge.receipt_url,
|
|
88
|
+
status: charge.status,
|
|
89
|
+
created: charge.created
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function mapSubscriptionStatus(status) {
|
|
65
93
|
switch (status) {
|
|
66
94
|
case "active":
|
|
67
95
|
return SubscriptionStatus.ACTIVE;
|
|
@@ -151,10 +179,12 @@ export {
|
|
|
151
179
|
ZERO_DECIMAL_CURRENCIES,
|
|
152
180
|
getBeginCheckoutProperties,
|
|
153
181
|
getPurchaseProperties,
|
|
182
|
+
mapCharge,
|
|
154
183
|
mapCheckoutSession,
|
|
155
184
|
mapInvoice,
|
|
156
185
|
mapLineItem,
|
|
157
|
-
|
|
186
|
+
mapPaymentIntent,
|
|
187
|
+
mapSubscriptionStatus,
|
|
158
188
|
mapTime,
|
|
159
189
|
minorUnits,
|
|
160
190
|
price
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/stripe/mapper.ts"],"sourcesContent":["import { SubscriptionStatus } from '../subscription/index';\nimport type Stripe from 'stripe';\n\nexport function mapTime<T extends number | null>(\n stripeTimestampSeconds: T\n): T extends number ? string : null {\n if (!stripeTimestampSeconds) return null as T extends number ? string : null;\n return new Date(stripeTimestampSeconds * 1000).toISOString() as T extends number ? string : null;\n}\n\nexport function mapLineItem(item: Stripe.LineItem) {\n return {\n id: item.price\n ? typeof item.price.product === 'string'\n ? item.price.product\n : item.price.product.id\n : item.id,\n currency: item.currency,\n quantity: item.quantity,\n description: item.description,\n amount_tax: item.amount_tax,\n amount_total: item.amount_total,\n amount_subtotal: item.amount_subtotal,\n amount_discount: item.amount_discount,\n price: item.price ? { id: item.price.id } : null,\n };\n}\n\nexport function mapCheckoutSession(session: Stripe.Checkout.Session) {\n let coupon: string | undefined = undefined;\n if (Array.isArray(session.discounts) && session.discounts.length !== 0) {\n const discount = session.discounts[0];\n if (discount.coupon && typeof discount.coupon === 'object') {\n coupon = discount.coupon.id;\n } else if (typeof discount.coupon === 'string') {\n coupon = discount.coupon;\n } else {\n coupon = undefined;\n }\n }\n\n return {\n id: session.id,\n url: session.url,\n coupon,\n livemode: session.livemode,\n expires_at: session.expires_at,\n payment_status: session.payment_status,\n currency: session.currency,\n amount_total: session.amount_total,\n line_items: session.line_items?.data.map(mapLineItem),\n };\n}\n\nexport function mapInvoice(i: Stripe.Invoice) {\n return {\n id: i.id,\n number: i.number,\n total: i.total,\n subtotal: i.subtotal,\n amount_due: i.amount_due,\n amount_paid: i.amount_paid,\n amount_remaining: i.amount_remaining,\n currency: i.currency,\n billing_reason: i.billing_reason,\n hosted_invoice_url: i.hosted_invoice_url,\n invoice_pdf: i.invoice_pdf,\n receipt_number: i.receipt_number,\n status: i.status,\n created: i.created,\n period_start: i.period_start,\n period_end: i.period_end,\n };\n}\n\nexport type CheckoutSession = ReturnType<typeof mapCheckoutSession>;\nexport type ProductPrice = {\n id: string;\n type: Stripe.Price.Type;\n unit_amount: number;\n currency: Stripe.Price['currency'];\n product: {\n id: Stripe.Product['id'];\n name: Stripe.Product['name'];\n description: Stripe.Product['description'];\n livemode: Stripe.Product['livemode'];\n };\n};\n\nexport function mapStatus(status: Stripe.Subscription.Status): SubscriptionStatus {\n switch (status) {\n case 'active':\n return SubscriptionStatus.ACTIVE;\n case 'canceled':\n return SubscriptionStatus.CANCELED;\n case 'incomplete':\n return SubscriptionStatus.INCOMPLETE;\n case 'incomplete_expired':\n return SubscriptionStatus.INCOMPLETE_EXPIRED;\n case 'past_due':\n return SubscriptionStatus.PAST_DUE;\n case 'paused':\n return SubscriptionStatus.PAUSED;\n case 'trialing':\n return SubscriptionStatus.TRIALING;\n case 'unpaid':\n return SubscriptionStatus.UNPAID;\n default: {\n console.error(`Invalid stripe status: ${status}`);\n throw new Error(`Invalid stripe status: ${status}`);\n }\n }\n}\n\nexport const ZERO_DECIMAL_CURRENCIES = [\n 'BIF',\n 'CLP',\n 'DJF',\n 'GNF',\n 'JPY',\n 'KMF',\n 'KRW',\n 'MGA',\n 'PYG',\n 'RWF',\n 'UGX',\n 'VND',\n 'VUV',\n 'XAF',\n 'XOF',\n 'XPF',\n];\n\nexport function minorUnits(currency: string) {\n return ZERO_DECIMAL_CURRENCIES.includes(currency.toUpperCase()) ? 1 : 100;\n}\n\nexport function price(value: number, currency: string) {\n return value / minorUnits(currency);\n}\nexport interface Item {\n item_id: string;\n item_name: string;\n affiliation?: 'Google Store' | (string & {});\n coupon?: string;\n discount?: number;\n index?: number;\n item_brand?: string;\n item_category?: string;\n item_category2?: string;\n item_category3?: string;\n item_category4?: string;\n item_category5?: string;\n item_list_id?: string;\n item_list_name?: string;\n item_variant?: string;\n location_id?: string;\n price?: number;\n quantity?: number;\n}\n\nexport interface PurchaseProperties {\n currency: string;\n value: number;\n transaction_id: string;\n coupon?: string;\n shipping?: number;\n tax?: number;\n items?: Item[];\n}\n\nexport interface BeginCheckoutProperties {\n currency: string;\n value: number;\n coupon?: string;\n items: Item[];\n}\n\nexport function getPurchaseProperties(session: CheckoutSession): PurchaseProperties {\n let value: number;\n let currency: string;\n if (!session.amount_total || !session.currency) {\n value = session.line_items?.reduce((acc, item) => acc + (item.amount_total ?? 0), 0) ?? 0;\n currency = session.line_items?.[0]?.currency ?? 'usd';\n } else {\n value = session.amount_total;\n currency = session.currency;\n }\n\n return {\n transaction_id: session.id,\n value: price(value, currency),\n currency: currency.toUpperCase(),\n coupon: session.coupon,\n items: session.line_items?.map((item, index) => ({\n index,\n item_id: item.id,\n item_name: item.description ?? '',\n price: price(item.amount_total, item.currency),\n quantity: item.quantity ?? 1,\n discount: price(item.amount_discount, item.currency),\n })),\n };\n}\n\nexport function getBeginCheckoutProperties(p: ProductPrice): BeginCheckoutProperties {\n return {\n currency: p.currency.toUpperCase(),\n value: price(p.unit_amount, p.currency),\n items: [\n {\n item_id: p.product.id,\n item_name: p.product.name,\n price: price(p.unit_amount, p.currency),\n },\n ],\n };\n}\n"],"mappings":";AAAA,SAAS,0BAA0B;AAG5B,SAAS,QACd,wBACkC;AAClC,MAAI,CAAC,uBAAwB,QAAO;AACpC,SAAO,IAAI,KAAK,yBAAyB,GAAI,EAAE,YAAY;AAC7D;AAEO,SAAS,YAAY,MAAuB;AACjD,SAAO;AAAA,IACL,IAAI,KAAK,QACL,OAAO,KAAK,MAAM,YAAY,WAC5B,KAAK,MAAM,UACX,KAAK,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;AAAA,EACrB;AAEA,SAAO;AAAA,IACL,gBAAgB,QAAQ;AAAA,IACxB,OAAO,MAAM,OAAO,QAAQ;AAAA,IAC5B,UAAU,SAAS,YAAY;AAAA,IAC/B,QAAQ,QAAQ;AAAA,IAChB,OAAO,QAAQ,YAAY,IAAI,CAAC,MAAM,WAAW;AAAA,MAC/C;AAAA,MACA,SAAS,KAAK;AAAA,MACd,WAAW,KAAK,eAAe;AAAA,MAC/B,OAAO,MAAM,KAAK,cAAc,KAAK,QAAQ;AAAA,MAC7C,UAAU,KAAK,YAAY;AAAA,MAC3B,UAAU,MAAM,KAAK,iBAAiB,KAAK,QAAQ;AAAA,IACrD,EAAE;AAAA,EACJ;AACF;AAEO,SAAS,2BAA2B,GAA0C;AACnF,SAAO;AAAA,IACL,UAAU,EAAE,SAAS,YAAY;AAAA,IACjC,OAAO,MAAM,EAAE,aAAa,EAAE,QAAQ;AAAA,IACtC,OAAO;AAAA,MACL;AAAA,QACE,SAAS,EAAE,QAAQ;AAAA,QACnB,WAAW,EAAE,QAAQ;AAAA,QACrB,OAAO,MAAM,EAAE,aAAa,EAAE,QAAQ;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/stripe/mapper.ts"],"sourcesContent":["import { SubscriptionStatus } from '../subscription/index';\nimport type Stripe from 'stripe';\n\nexport function mapTime<T extends number | null>(\n stripeTimestampSeconds: T\n): T extends number ? string : null {\n if (!stripeTimestampSeconds) return null as T extends number ? string : null;\n return new Date(stripeTimestampSeconds * 1000).toISOString() as T extends number ? string : null;\n}\n\nexport function mapLineItem(item: Stripe.LineItem) {\n return {\n id: item.price\n ? typeof item.price.product === 'string'\n ? item.price.product\n : item.price.product.id\n : item.id,\n currency: item.currency,\n quantity: item.quantity,\n description: item.description,\n amount_tax: item.amount_tax,\n amount_total: item.amount_total,\n amount_subtotal: item.amount_subtotal,\n amount_discount: item.amount_discount,\n price: item.price ? { id: item.price.id } : null,\n };\n}\n\nexport function mapCheckoutSession(session: Stripe.Checkout.Session) {\n let coupon: string | undefined = undefined;\n if (Array.isArray(session.discounts) && session.discounts.length !== 0) {\n const discount = session.discounts[0];\n if (discount.coupon && typeof discount.coupon === 'object') {\n coupon = discount.coupon.id;\n } else if (typeof discount.coupon === 'string') {\n coupon = discount.coupon;\n } else {\n coupon = undefined;\n }\n }\n\n return {\n id: session.id,\n url: session.url,\n coupon,\n livemode: session.livemode,\n expires_at: session.expires_at,\n payment_status: session.payment_status,\n currency: session.currency,\n amount_total: session.amount_total,\n line_items: session.line_items?.data.map(mapLineItem),\n };\n}\n\nexport function mapInvoice(i: Stripe.Invoice) {\n return {\n id: i.id,\n number: i.number,\n total: i.total,\n subtotal: i.subtotal,\n amount_due: i.amount_due,\n amount_paid: i.amount_paid,\n amount_remaining: i.amount_remaining,\n currency: i.currency,\n billing_reason: i.billing_reason,\n hosted_invoice_url: i.hosted_invoice_url,\n invoice_pdf: i.invoice_pdf,\n receipt_number: i.receipt_number,\n status: i.status,\n created: i.created,\n period_start: i.period_start,\n period_end: i.period_end,\n };\n}\n\nexport function mapPaymentIntent(intent: Stripe.PaymentIntent) {\n return {\n id: intent.id,\n amount: intent.amount,\n amount_capturable: intent.amount_capturable,\n amount_received: intent.amount_received,\n currency: intent.currency,\n client_secret: intent.client_secret,\n description: intent.description,\n status: intent.status,\n created: intent.created,\n };\n}\n\nexport function mapCharge(charge: Stripe.Charge) {\n return {\n id: charge.id,\n description: charge.description,\n currency: charge.currency,\n amount: charge.amount,\n amount_captured: charge.amount_captured,\n amount_refunded: charge.amount_refunded,\n receipt_email: charge.receipt_email,\n receipt_number: charge.receipt_number,\n receipt_url: charge.receipt_url,\n status: charge.status,\n created: charge.created,\n };\n}\n\nexport type CheckoutSession = ReturnType<typeof mapCheckoutSession>;\nexport type ProductPrice = {\n id: string;\n type: Stripe.Price.Type;\n unit_amount: number;\n currency: Stripe.Price['currency'];\n product: {\n id: Stripe.Product['id'];\n name: Stripe.Product['name'];\n description: Stripe.Product['description'];\n livemode: Stripe.Product['livemode'];\n };\n};\n\nexport function mapSubscriptionStatus(status: Stripe.Subscription.Status): SubscriptionStatus {\n switch (status) {\n case 'active':\n return SubscriptionStatus.ACTIVE;\n case 'canceled':\n return SubscriptionStatus.CANCELED;\n case 'incomplete':\n return SubscriptionStatus.INCOMPLETE;\n case 'incomplete_expired':\n return SubscriptionStatus.INCOMPLETE_EXPIRED;\n case 'past_due':\n return SubscriptionStatus.PAST_DUE;\n case 'paused':\n return SubscriptionStatus.PAUSED;\n case 'trialing':\n return SubscriptionStatus.TRIALING;\n case 'unpaid':\n return SubscriptionStatus.UNPAID;\n default: {\n console.error(`Invalid stripe status: ${status}`);\n throw new Error(`Invalid stripe status: ${status}`);\n }\n }\n}\n\nexport const ZERO_DECIMAL_CURRENCIES = [\n 'BIF',\n 'CLP',\n 'DJF',\n 'GNF',\n 'JPY',\n 'KMF',\n 'KRW',\n 'MGA',\n 'PYG',\n 'RWF',\n 'UGX',\n 'VND',\n 'VUV',\n 'XAF',\n 'XOF',\n 'XPF',\n];\n\nexport function minorUnits(currency: string) {\n return ZERO_DECIMAL_CURRENCIES.includes(currency.toUpperCase()) ? 1 : 100;\n}\n\nexport function price(value: number, currency: string) {\n return value / minorUnits(currency);\n}\n\nexport interface Item {\n item_id: string;\n item_name: string;\n affiliation?: 'Google Store' | (string & {});\n coupon?: string;\n discount?: number;\n index?: number;\n item_brand?: string;\n item_category?: string;\n item_category2?: string;\n item_category3?: string;\n item_category4?: string;\n item_category5?: string;\n item_list_id?: string;\n item_list_name?: string;\n item_variant?: string;\n location_id?: string;\n price?: number;\n quantity?: number;\n}\n\nexport interface PurchaseProperties {\n currency: string;\n value: number;\n transaction_id: string;\n coupon?: string;\n shipping?: number;\n tax?: number;\n items?: Item[];\n}\n\nexport interface BeginCheckoutProperties {\n currency: string;\n value: number;\n coupon?: string;\n items: Item[];\n}\n\nexport function getPurchaseProperties(session: CheckoutSession): PurchaseProperties {\n let value: number;\n let currency: string;\n if (!session.amount_total || !session.currency) {\n value = session.line_items?.reduce((acc, item) => acc + (item.amount_total ?? 0), 0) ?? 0;\n currency = session.line_items?.[0]?.currency ?? 'usd';\n } else {\n value = session.amount_total;\n currency = session.currency;\n }\n\n return {\n transaction_id: session.id,\n value: price(value, currency),\n currency: currency.toUpperCase(),\n coupon: session.coupon,\n items: session.line_items?.map((item, index) => ({\n index,\n item_id: item.id,\n item_name: item.description ?? '',\n price: price(item.amount_total, item.currency),\n quantity: item.quantity ?? 1,\n discount: price(item.amount_discount, item.currency),\n })),\n };\n}\n\nexport function getBeginCheckoutProperties(p: ProductPrice): BeginCheckoutProperties {\n return {\n currency: p.currency.toUpperCase(),\n value: price(p.unit_amount, p.currency),\n items: [\n {\n item_id: p.product.id,\n item_name: p.product.name,\n price: price(p.unit_amount, p.currency),\n },\n ],\n };\n}\n"],"mappings":";AAAA,SAAS,0BAA0B;AAG5B,SAAS,QACd,wBACkC;AAClC,MAAI,CAAC,uBAAwB,QAAO;AACpC,SAAO,IAAI,KAAK,yBAAyB,GAAI,EAAE,YAAY;AAC7D;AAEO,SAAS,YAAY,MAAuB;AACjD,SAAO;AAAA,IACL,IAAI,KAAK,QACL,OAAO,KAAK,MAAM,YAAY,WAC5B,KAAK,MAAM,UACX,KAAK,MAAM,QAAQ,KACrB,KAAK;AAAA,IACT,UAAU,KAAK;AAAA,IACf,UAAU,KAAK;AAAA,IACf,aAAa,KAAK;AAAA,IAClB,YAAY,KAAK;AAAA,IACjB,cAAc,KAAK;AAAA,IACnB,iBAAiB,KAAK;AAAA,IACtB,iBAAiB,KAAK;AAAA,IACtB,OAAO,KAAK,QAAQ,EAAE,IAAI,KAAK,MAAM,GAAG,IAAI;AAAA,EAC9C;AACF;AAEO,SAAS,mBAAmB,SAAkC;AACnE,MAAI,SAA6B;AACjC,MAAI,MAAM,QAAQ,QAAQ,SAAS,KAAK,QAAQ,UAAU,WAAW,GAAG;AACtE,UAAM,WAAW,QAAQ,UA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