@aglyn/plugins-commerce 1.0.0-beta.199 → 1.0.0-beta.200
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/package.json +13 -13
- package/src/lib/components/console/catalog-organization-card.component.js +48 -3
- package/src/lib/components/console/catalog-organization-card.component.js.map +1 -1
- package/src/lib/components/console/gift-cards-card.component.d.ts +9 -0
- package/src/lib/components/console/gift-cards-card.component.js +53 -28
- package/src/lib/components/console/gift-cards-card.component.js.map +1 -1
- package/src/lib/components/console/host-orders-card.component.d.ts +26 -0
- package/src/lib/components/console/host-orders-card.component.js +264 -194
- package/src/lib/components/console/host-orders-card.component.js.map +1 -1
- package/src/lib/components/console/pos-page.component.d.ts +14 -0
- package/src/lib/components/console/pos-page.component.js +86 -45
- package/src/lib/components/console/pos-page.component.js.map +1 -1
- package/src/lib/components/console/product-editor-dialog.component.js +30 -6
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/product-slugs.d.ts +43 -0
- package/src/lib/components/console/product-slugs.js +60 -0
- package/src/lib/components/console/product-slugs.js.map +1 -0
- package/src/lib/components/console/products-hub-card.component.d.ts +2 -2
- package/src/lib/components/console/products-hub-card.component.js +229 -282
- package/src/lib/components/console/products-hub-card.component.js.map +1 -1
- package/src/lib/components/console/products-hub-zone.component.d.ts +10 -5
- package/src/lib/components/console/products-hub-zone.component.js +32 -9
- package/src/lib/components/console/products-hub-zone.component.js.map +1 -1
- package/src/lib/components/console/recovery-queue-card.component.d.ts +37 -5
- package/src/lib/components/console/recovery-queue-card.component.js +107 -86
- package/src/lib/components/console/recovery-queue-card.component.js.map +1 -1
- package/src/lib/components/console/reservations-card.component.js +15 -3
- package/src/lib/components/console/reservations-card.component.js.map +1 -1
- package/src/lib/components/console/smart-collections.d.ts +32 -0
- package/src/lib/components/console/smart-collections.js +57 -0
- package/src/lib/components/console/smart-collections.js.map +1 -0
- package/src/lib/components/console/stock-movements-card.component.d.ts +13 -4
- package/src/lib/components/console/stock-movements-card.component.js +142 -180
- package/src/lib/components/console/stock-movements-card.component.js.map +1 -1
- package/src/lib/components/product-grid.d.ts +5 -0
- package/src/lib/components/product-grid.js +95 -34
- package/src/lib/components/product-grid.js.map +1 -1
- package/src/lib/constants/orders-list-query.d.ts +40 -0
- package/src/lib/constants/orders-list-query.js +205 -0
- package/src/lib/constants/orders-list-query.js.map +1 -0
- package/src/lib/constants/product-list-query.d.ts +42 -0
- package/src/lib/constants/product-list-query.js +217 -0
- package/src/lib/constants/product-list-query.js.map +1 -0
- package/src/lib/constants/stock-movement-query.d.ts +27 -0
- package/src/lib/constants/stock-movement-query.js +110 -0
- package/src/lib/constants/stock-movement-query.js.map +1 -0
- package/src/lib/constants/storefront-catalog-query.d.ts +103 -0
- package/src/lib/constants/storefront-catalog-query.js +312 -0
- package/src/lib/constants/storefront-catalog-query.js.map +1 -0
- package/src/lib/model/checkout-recovery.d.ts +37 -0
- package/src/lib/model/checkout-recovery.js +44 -0
- package/src/lib/model/checkout-recovery.js.map +1 -0
- package/src/lib/model/commerce.d.ts +80 -0
- package/src/lib/model/commerce.js +67 -6
- package/src/lib/model/commerce.js.map +1 -1
- package/src/lib/model/gift-card-search.d.ts +24 -0
- package/src/lib/model/gift-card-search.js +48 -0
- package/src/lib/model/gift-card-search.js.map +1 -0
- package/src/lib/model/index.d.ts +1 -0
- package/src/lib/model/index.js +1 -0
- package/src/lib/model/index.js.map +1 -1
- package/src/lib/model/order-list-fields.d.ts +80 -0
- package/src/lib/model/order-list-fields.js +112 -0
- package/src/lib/model/order-list-fields.js.map +1 -0
- package/src/lib/server/billing-webhook.js +108 -89
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/cancel-order.js +6 -6
- package/src/lib/server/cancel-order.js.map +1 -1
- package/src/lib/server/cart-checkout.js +6 -0
- package/src/lib/server/cart-checkout.js.map +1 -1
- package/src/lib/server/catalog.d.ts +46 -30
- package/src/lib/server/catalog.js +492 -170
- package/src/lib/server/catalog.js.map +1 -1
- package/src/lib/server/collection-membership.d.ts +35 -0
- package/src/lib/server/collection-membership.js +172 -0
- package/src/lib/server/collection-membership.js.map +1 -0
- package/src/lib/server/draft-order.js +3 -2
- package/src/lib/server/draft-order.js.map +1 -1
- package/src/lib/server/gift-cards.js +3 -0
- package/src/lib/server/gift-cards.js.map +1 -1
- package/src/lib/server/member-name-search.d.ts +17 -0
- package/src/lib/server/member-name-search.js +23 -1
- package/src/lib/server/member-name-search.js.map +1 -1
- package/src/lib/server/membership-account.js +7 -3
- package/src/lib/server/membership-account.js.map +1 -1
- package/src/lib/server/membership-register.js +3 -1
- package/src/lib/server/membership-register.js.map +1 -1
- package/src/lib/server/pos-order.js +6 -4
- package/src/lib/server/pos-order.js.map +1 -1
- package/src/lib/server/process-abandoned.js +14 -5
- package/src/lib/server/process-abandoned.js.map +1 -1
- package/src/lib/server/reserve-stock.js +3 -4
- package/src/lib/server/reserve-stock.js.map +1 -1
- package/src/lib/server/site-page-enricher.js +3 -3
- package/src/lib/server/site-page-enricher.js.map +1 -1
- package/src/lib/server.js +4 -0
- package/src/lib/server.js.map +1 -1
|
@@ -28,6 +28,7 @@ import { reverseEmailAttributedRevenue } from "@aglyn/tenant-data-admin/server/e
|
|
|
28
28
|
import { mintDownloadToken, tokenSigningSecret } from "./download.js";
|
|
29
29
|
import { alertLowStockCrossing } from "./low-stock.js";
|
|
30
30
|
import { decrementVariantStock } from "./reserve-stock.js";
|
|
31
|
+
import { giftCardSearchTokens } from "../model/gift-card-search.js";
|
|
31
32
|
import { releaseStockHold } from "./stock-hold.js";
|
|
32
33
|
import { releasePromotionHold, settlePromotionSlot } from "./promotion-hold.js";
|
|
33
34
|
import { flagOrderRestock } from "./restock-flag.js";
|
|
@@ -326,7 +327,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
326
327
|
*/ async function recordDisputeOpened(snapshot, dispute) {
|
|
327
328
|
const record = disputeFromEvent(dispute);
|
|
328
329
|
const opened = await firebaseAdmin.app().firestore().runTransaction(async (transaction)=>{
|
|
329
|
-
var _fresh_data;
|
|
330
|
+
var _fresh_data, _fresh_data1;
|
|
330
331
|
var _order_dispute;
|
|
331
332
|
const fresh = await transaction.get(snapshot.ref);
|
|
332
333
|
if (!fresh.exists) return false;
|
|
@@ -347,10 +348,12 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
347
348
|
// the same charge and does replace it.
|
|
348
349
|
if (((_order_dispute = order.dispute) == null ? void 0 : _order_dispute.id) === record.id) return false;
|
|
349
350
|
const amount = `$${(record.amountCents / 100).toFixed(2)}`;
|
|
350
|
-
transaction.update(snapshot.ref, {
|
|
351
|
+
transaction.update(snapshot.ref, _extends({}, CommerceModel.orderListFields(_extends({}, (_fresh_data1 = fresh.data()) != null ? _fresh_data1 : {}, {
|
|
352
|
+
dispute: record
|
|
353
|
+
}), snapshot.id), {
|
|
351
354
|
dispute: record,
|
|
352
355
|
timeline: CommerceModel.appendOrderEvent(order, 'dispute', `Chargeback opened for ${amount}` + (record.reason ? ` (${record.reason.replace(/_/g, ' ')})` : '') + (record.evidenceDueByMs ? ` — evidence due ${new Date(record.evidenceDueByMs).toISOString().slice(0, 10)}` : ''), record.openedAtMs)
|
|
353
|
-
});
|
|
356
|
+
}));
|
|
354
357
|
return true;
|
|
355
358
|
});
|
|
356
359
|
return {
|
|
@@ -407,7 +410,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
407
410
|
const outcome = String((_ref = dispute == null ? void 0 : dispute.status) != null ? _ref : '');
|
|
408
411
|
const lost = outcome === 'lost';
|
|
409
412
|
return firebaseAdmin.app().firestore().runTransaction(async (transaction)=>{
|
|
410
|
-
var _fresh_data, _ref, _order_amountCents, _order_refundedCents;
|
|
413
|
+
var _fresh_data, _ref, _order_amountCents, _order_refundedCents, _fresh_data1;
|
|
411
414
|
var _order_totals;
|
|
412
415
|
const idle = {
|
|
413
416
|
recorded: false,
|
|
@@ -430,19 +433,24 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
430
433
|
const closedTheOrder = fullyReversed && CommerceModel.canTransitionOrder(order.status, 'refunded');
|
|
431
434
|
const closedAtMs = Date.now();
|
|
432
435
|
const amount = `$${(reversedCents / 100).toFixed(2)}`;
|
|
433
|
-
|
|
436
|
+
const settled = _extends({}, event, (stored == null ? void 0 : stored.id) === event.id && stored.openedAtMs ? {
|
|
437
|
+
openedAtMs: stored.openedAtMs
|
|
438
|
+
} : {}, {
|
|
439
|
+
status: outcome,
|
|
440
|
+
outcome,
|
|
441
|
+
closedAtMs,
|
|
442
|
+
reversedCents
|
|
443
|
+
});
|
|
444
|
+
transaction.update(snapshot.ref, _extends({}, CommerceModel.orderListFields(_extends({}, (_fresh_data1 = fresh.data()) != null ? _fresh_data1 : {}, closedTheOrder ? {
|
|
445
|
+
status: 'refunded'
|
|
446
|
+
} : {}, {
|
|
447
|
+
dispute: settled
|
|
448
|
+
}), snapshot.id), reversedCents > 0 ? {
|
|
434
449
|
refundedCents: reversedTotal
|
|
435
450
|
} : {}, closedTheOrder ? {
|
|
436
451
|
status: 'refunded'
|
|
437
452
|
} : {}, {
|
|
438
|
-
dispute:
|
|
439
|
-
openedAtMs: stored.openedAtMs
|
|
440
|
-
} : {}, {
|
|
441
|
-
status: outcome,
|
|
442
|
-
outcome,
|
|
443
|
-
closedAtMs,
|
|
444
|
-
reversedCents
|
|
445
|
-
}),
|
|
453
|
+
dispute: settled,
|
|
446
454
|
timeline: CommerceModel.appendOrderEvent(order, 'dispute', lost ? `${amount} charged back (dispute lost)` + (closedTheOrder ? ' (full)' : '') : `Dispute ${outcome.replace(/_/g, ' ')} — no money reversed`, closedAtMs)
|
|
447
455
|
}));
|
|
448
456
|
return {
|
|
@@ -1394,7 +1402,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
1394
1402
|
* this far. A notification is not idempotent by any doc key of its own.
|
|
1395
1403
|
*/ const settle = async (reversedTransferCents, transferReversalId, note)=>{
|
|
1396
1404
|
return firebaseAdmin.app().firestore().runTransaction(async (transaction)=>{
|
|
1397
|
-
var _fresh_data;
|
|
1405
|
+
var _fresh_data, _fresh_data1;
|
|
1398
1406
|
const fresh = await transaction.get(orderRef);
|
|
1399
1407
|
if (!fresh.exists) return false;
|
|
1400
1408
|
const current = CommerceModel.liftLegacyOrder((_fresh_data = fresh.data()) != null ? _fresh_data : {});
|
|
@@ -1402,15 +1410,18 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
1402
1410
|
if ((record == null ? void 0 : record.id) !== disputeId || record.reversedTransferCents != null) {
|
|
1403
1411
|
return false;
|
|
1404
1412
|
}
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1413
|
+
// Written whole, the field's own rule — see `OrderDispute`.
|
|
1414
|
+
const dispute = _extends({}, record, {
|
|
1415
|
+
reversedTransferCents
|
|
1416
|
+
}, transferReversalId ? {
|
|
1417
|
+
transferReversalId
|
|
1418
|
+
} : {});
|
|
1419
|
+
transaction.update(orderRef, _extends({}, CommerceModel.orderListFields(_extends({}, (_fresh_data1 = fresh.data()) != null ? _fresh_data1 : {}, {
|
|
1420
|
+
dispute
|
|
1421
|
+
}), orderRef.id), {
|
|
1422
|
+
dispute,
|
|
1412
1423
|
timeline: CommerceModel.appendOrderEvent(current, 'dispute', note)
|
|
1413
|
-
});
|
|
1424
|
+
}));
|
|
1414
1425
|
return true;
|
|
1415
1426
|
});
|
|
1416
1427
|
};
|
|
@@ -2215,7 +2226,8 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
2215
2226
|
}, {
|
|
2216
2227
|
merge: true
|
|
2217
2228
|
});
|
|
2218
|
-
|
|
2229
|
+
// With the fields the orders list queries by (AGL-3321).
|
|
2230
|
+
transaction.set(orderRef, CommerceModel.withOrderListFields(orderRef.id, _extends({
|
|
2219
2231
|
number: orderNumber,
|
|
2220
2232
|
status: 'paid',
|
|
2221
2233
|
channel: 'subscription',
|
|
@@ -2256,7 +2268,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
2256
2268
|
feeCents: Number((_invoiceTotals_feeCents = invoiceTotals.feeCents) != null ? _invoiceTotals_feeCents : 0),
|
|
2257
2269
|
createdAtMs: paidAtMs,
|
|
2258
2270
|
createdAt: firebaseAdmin.firestore.FieldValue.serverTimestamp()
|
|
2259
|
-
}));
|
|
2271
|
+
})));
|
|
2260
2272
|
}
|
|
2261
2273
|
return true;
|
|
2262
2274
|
});
|
|
@@ -2681,7 +2693,8 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
2681
2693
|
const totals = CommerceModel.computeCheckoutSessionTotals(lineItems, object, {
|
|
2682
2694
|
feeCents: Number(feeCents != null ? feeCents : 0)
|
|
2683
2695
|
});
|
|
2684
|
-
|
|
2696
|
+
// With the fields the orders list queries by (AGL-3321).
|
|
2697
|
+
transaction.set(orderRef, CommerceModel.withOrderListFields(orderRef.id, _extends({
|
|
2685
2698
|
number,
|
|
2686
2699
|
status: 'paid',
|
|
2687
2700
|
channel: 'online',
|
|
@@ -2735,7 +2748,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
2735
2748
|
feeCents: Number(feeCents != null ? feeCents : 0),
|
|
2736
2749
|
createdAtMs: Date.now(),
|
|
2737
2750
|
createdAt: firebaseAdmin.firestore.FieldValue.serverTimestamp()
|
|
2738
|
-
}));
|
|
2751
|
+
})));
|
|
2739
2752
|
return true;
|
|
2740
2753
|
});
|
|
2741
2754
|
// Redelivery/replay guard (AGL-498): only fulfil when the order was
|
|
@@ -3042,8 +3055,8 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3042
3055
|
const lineProduct = productsById.get(line.productId);
|
|
3043
3056
|
if (!(lineProduct == null ? void 0 : lineProduct.giftCard)) continue;
|
|
3044
3057
|
for(let unit = 0; unit < line.quantity; unit += 1){
|
|
3045
|
-
var _ref53;
|
|
3046
|
-
var _object_customer_details12, _object_customer_details13;
|
|
3058
|
+
var _ref53, _ref54;
|
|
3059
|
+
var _object_customer_details12, _object_customer_details13, _object_customer_details14;
|
|
3047
3060
|
const code = `GC-${createHmac('sha256', String(object.id)).update(`${line.productId}:${unit}:${Date.now()}`).digest('hex').slice(0, 12).toUpperCase()}`;
|
|
3048
3061
|
// THE EMAIL IS GATED ON THE WRITE (AGL-2161). This `.set()` used
|
|
3049
3062
|
// to `.catch(() => undefined)` and fall straight through to the
|
|
@@ -3063,6 +3076,8 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3063
3076
|
balanceCents: line.unitAmountCents,
|
|
3064
3077
|
recipientEmail: (_ref53 = object == null ? void 0 : (_object_customer_details12 = object.customer_details) == null ? void 0 : _object_customer_details12.email) != null ? _ref53 : null,
|
|
3065
3078
|
orderId: String(object.id),
|
|
3079
|
+
// What the console's Gift cards search asks (AGL-3321).
|
|
3080
|
+
searchTokens: giftCardSearchTokens(code, (_ref54 = object == null ? void 0 : (_object_customer_details13 = object.customer_details) == null ? void 0 : _object_customer_details13.email) != null ? _ref54 : null),
|
|
3066
3081
|
createdAtMs: Date.now()
|
|
3067
3082
|
}).then(()=>true).catch((error)=>{
|
|
3068
3083
|
console.error('Gift card issuance failed', hostId, code, error);
|
|
@@ -3088,9 +3103,9 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3088
3103
|
});
|
|
3089
3104
|
continue;
|
|
3090
3105
|
}
|
|
3091
|
-
const giftTo = object == null ? void 0 : (
|
|
3106
|
+
const giftTo = object == null ? void 0 : (_object_customer_details14 = object.customer_details) == null ? void 0 : _object_customer_details14.email;
|
|
3092
3107
|
if (giftTo) {
|
|
3093
|
-
var
|
|
3108
|
+
var _ref55;
|
|
3094
3109
|
const giftValue = `$${(line.unitAmountCents / 100).toFixed(2)}`;
|
|
3095
3110
|
const fallbackText = `Gift card code: ${code}\n` + `Value: ${giftValue}\n\n` + 'Enter it at checkout to apply the balance.';
|
|
3096
3111
|
// Site-owner-designed template when published (AGL-771).
|
|
@@ -3100,7 +3115,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3100
3115
|
});
|
|
3101
3116
|
await sendEmail(_extends({
|
|
3102
3117
|
to: giftTo,
|
|
3103
|
-
subject: (
|
|
3118
|
+
subject: (_ref55 = designed == null ? void 0 : designed.subject) != null ? _ref55 : 'Your gift card',
|
|
3104
3119
|
text: (designed == null ? void 0 : designed.text) || fallbackText
|
|
3105
3120
|
}, (designed == null ? void 0 : designed.html) ? {
|
|
3106
3121
|
html: designed.html
|
|
@@ -3118,12 +3133,12 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3118
3133
|
}
|
|
3119
3134
|
// Discounts engine redemptions (AGL-305).
|
|
3120
3135
|
if ((_object_metadata22 = object.metadata) == null ? void 0 : _object_metadata22.discountId) {
|
|
3121
|
-
var
|
|
3136
|
+
var _ref56;
|
|
3122
3137
|
var _object_metadata26;
|
|
3123
3138
|
await settleRedemption({
|
|
3124
3139
|
firestore,
|
|
3125
3140
|
ref: hostRef.collection('discounts').doc(String(object.metadata.discountId)),
|
|
3126
|
-
holdKey: String((
|
|
3141
|
+
holdKey: String((_ref56 = (_object_metadata26 = object.metadata) == null ? void 0 : _object_metadata26.discountHoldKey) != null ? _ref56 : ''),
|
|
3127
3142
|
orderRef,
|
|
3128
3143
|
label: `discount ${object.metadata.discountId}`,
|
|
3129
3144
|
detail: `Discount ${object.metadata.discountId} was applied to this ` + 'order but no longer exists, so the redemption is uncounted ' + 'against its limit.'
|
|
@@ -3137,7 +3152,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3137
3152
|
var _object_metadata27;
|
|
3138
3153
|
const { hostId, orderId, productId } = (_object_metadata27 = object.metadata) != null ? _object_metadata27 : {};
|
|
3139
3154
|
if (hostId && orderId) {
|
|
3140
|
-
var
|
|
3155
|
+
var _ref57, _ref58, _ref59;
|
|
3141
3156
|
var _object_total_details, _object_total_details1;
|
|
3142
3157
|
const firestore = firebaseAdmin.app().firestore();
|
|
3143
3158
|
const hostRef = firestore.collection('hosts').doc(String(hostId));
|
|
@@ -3176,7 +3191,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3176
3191
|
//
|
|
3177
3192
|
// The whole map is written rather than one field of it, so a
|
|
3178
3193
|
// `merge`-set's nested-map merge and a plain replace agree.
|
|
3179
|
-
const shippingCents = Math.max(0, Math.round(Number((
|
|
3194
|
+
const shippingCents = Math.max(0, Math.round(Number((_ref57 = object == null ? void 0 : (_object_total_details = object.total_details) == null ? void 0 : _object_total_details.amount_shipping) != null ? _ref57 : 0) || 0));
|
|
3180
3195
|
// Tax joins shipping in the fold (AGL-1953). `draft-order.ts` now
|
|
3181
3196
|
// declares tax — a Stripe Tax Rate for a `manual` store, whose figure
|
|
3182
3197
|
// it already froze into `totals`, or `automatic_tax` for a `stripe`
|
|
@@ -3189,8 +3204,8 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3189
3204
|
// `amount_tax` 0 here (its own figure stays on the order, and its
|
|
3190
3205
|
// AGL-1953 witness is metadata, not this field), and a draft composed
|
|
3191
3206
|
// by a store with no tax reports 0 too.
|
|
3192
|
-
const stripeTaxCents = Math.max(0, Math.round(Number((
|
|
3193
|
-
const chargedTotalCents = Number((
|
|
3207
|
+
const stripeTaxCents = Math.max(0, Math.round(Number((_ref58 = object == null ? void 0 : (_object_total_details1 = object.total_details) == null ? void 0 : _object_total_details1.amount_tax) != null ? _ref58 : 0) || 0));
|
|
3208
|
+
const chargedTotalCents = Number((_ref59 = object == null ? void 0 : object.amount_total) != null ? _ref59 : NaN);
|
|
3194
3209
|
// `shipping_details` ONLY, unlike the cart branch's
|
|
3195
3210
|
// `?? customer_details` fallback: that address is the BILLING one, and
|
|
3196
3211
|
// a card sale rung up at a register completes here too — it must not
|
|
@@ -3203,8 +3218,8 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3203
3218
|
// the transaction commits.
|
|
3204
3219
|
let paidAfterCancel = false;
|
|
3205
3220
|
const flipped = await firestore.runTransaction(async (transaction)=>{
|
|
3206
|
-
var _snapshot_data, _ref, _ref1, _ref2, _ref3, _lifted_totals,
|
|
3207
|
-
var _object_metadata,
|
|
3221
|
+
var _snapshot_data, _snapshot_data1, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _lifted_totals, _ref6, _shipTo_name, _shipTo_address_line1, _shipTo_address_line2, _shipTo_address_city, _shipTo_address_state, _shipTo_address_postal_code, _shipTo_address_country;
|
|
3222
|
+
var _object_customer_details, _object_metadata, _object_customer_details1, _lifted_totals1;
|
|
3208
3223
|
const snapshot = await transaction.get(orderRef);
|
|
3209
3224
|
if (!snapshot.exists) return false;
|
|
3210
3225
|
const lifted = CommerceModel.liftLegacyOrder((_snapshot_data = snapshot.data()) != null ? _snapshot_data : {});
|
|
@@ -3241,7 +3256,10 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3241
3256
|
return false;
|
|
3242
3257
|
}
|
|
3243
3258
|
paidOrder = lifted;
|
|
3244
|
-
transaction.set(orderRef, _extends({
|
|
3259
|
+
transaction.set(orderRef, _extends({}, CommerceModel.orderListFields(_extends({}, (_snapshot_data1 = snapshot.data()) != null ? _snapshot_data1 : {}, {
|
|
3260
|
+
status: 'paid',
|
|
3261
|
+
customerEmail: (_ref = (_ref1 = object == null ? void 0 : (_object_customer_details = object.customer_details) == null ? void 0 : _object_customer_details.email) != null ? _ref1 : lifted.customerEmail) != null ? _ref : null
|
|
3262
|
+
}), orderRef.id), {
|
|
3245
3263
|
status: 'paid',
|
|
3246
3264
|
// WHICH TAX THIS ORDER CARRIED (AGL-2451), resolved from the
|
|
3247
3265
|
// session that actually charged it rather than from the draft's
|
|
@@ -3258,9 +3276,9 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3258
3276
|
// record that any of the charge was tax (AGL-1953). Without it
|
|
3259
3277
|
// every register card sale would stamp `none` beside an order
|
|
3260
3278
|
// plainly carrying tax.
|
|
3261
|
-
taxMode: storefrontTaxModeOf(object, Number((
|
|
3262
|
-
paymentIntentId: String((
|
|
3263
|
-
customerEmail: (
|
|
3279
|
+
taxMode: storefrontTaxModeOf(object, Number((_ref2 = object == null ? void 0 : (_object_metadata = object.metadata) == null ? void 0 : _object_metadata.taxCents) != null ? _ref2 : 0)),
|
|
3280
|
+
paymentIntentId: String((_ref3 = object == null ? void 0 : object.payment_intent) != null ? _ref3 : '') || null,
|
|
3281
|
+
customerEmail: (_ref4 = (_ref5 = object == null ? void 0 : (_object_customer_details1 = object.customer_details) == null ? void 0 : _object_customer_details1.email) != null ? _ref5 : lifted.customerEmail) != null ? _ref4 : null,
|
|
3264
3282
|
timeline: CommerceModel.appendOrderEvent(lifted, 'paid')
|
|
3265
3283
|
}, shippingCents > 0 || stripeTaxCents > 0 ? {
|
|
3266
3284
|
totals: _extends({}, (_lifted_totals = lifted.totals) != null ? _lifted_totals : {}, shippingCents > 0 ? {
|
|
@@ -3271,7 +3289,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3271
3289
|
// Stripe's own figure, for the AGL-1698 reason: the
|
|
3272
3290
|
// frozen total is what the draft was priced at, and only
|
|
3273
3291
|
// `amount_total` is the money that moved.
|
|
3274
|
-
totalCents: Number.isFinite(chargedTotalCents) ? chargedTotalCents : Number((
|
|
3292
|
+
totalCents: Number.isFinite(chargedTotalCents) ? chargedTotalCents : Number((_ref6 = (_lifted_totals1 = lifted.totals) == null ? void 0 : _lifted_totals1.totalCents) != null ? _ref6 : 0) + shippingCents
|
|
3275
3293
|
})
|
|
3276
3294
|
} : {}, (shipTo == null ? void 0 : shipTo.address) ? {
|
|
3277
3295
|
shippingAddress: {
|
|
@@ -3301,8 +3319,8 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3301
3319
|
});
|
|
3302
3320
|
}
|
|
3303
3321
|
if (flipped) {
|
|
3304
|
-
var
|
|
3305
|
-
var _object_metadata28,
|
|
3322
|
+
var _ref60, _ref61;
|
|
3323
|
+
var _object_metadata28, _object_customer_details15;
|
|
3306
3324
|
const order = paidOrder;
|
|
3307
3325
|
// Discounts engine redemptions (AGL-305), for this branch's BOTH
|
|
3308
3326
|
// tenants: a console draft order and a POS card sale, which carry the
|
|
@@ -3317,12 +3335,12 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3317
3335
|
// the hold existed, which Stripe's at-least-once delivery would run
|
|
3318
3336
|
// twice. The transition is what makes it once.
|
|
3319
3337
|
if ((_object_metadata28 = object.metadata) == null ? void 0 : _object_metadata28.discountId) {
|
|
3320
|
-
var
|
|
3338
|
+
var _ref62;
|
|
3321
3339
|
var _object_metadata29;
|
|
3322
3340
|
await settleRedemption({
|
|
3323
3341
|
firestore,
|
|
3324
3342
|
ref: hostRef.collection('discounts').doc(String(object.metadata.discountId)),
|
|
3325
|
-
holdKey: String((
|
|
3343
|
+
holdKey: String((_ref62 = (_object_metadata29 = object.metadata) == null ? void 0 : _object_metadata29.discountHoldKey) != null ? _ref62 : ''),
|
|
3326
3344
|
orderRef,
|
|
3327
3345
|
label: `discount ${object.metadata.discountId}`,
|
|
3328
3346
|
detail: `Discount ${object.metadata.discountId} was applied to this ` + 'order but no longer exists, so the redemption is uncounted ' + 'against its limit.'
|
|
@@ -3345,15 +3363,15 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3345
3363
|
// figure the draft was priced at, and the two agree by construction,
|
|
3346
3364
|
// but only one of them is the money that moved. Stored totals remain
|
|
3347
3365
|
// the fallback for a session shape that reports no total.
|
|
3348
|
-
const draftEmail = (
|
|
3366
|
+
const draftEmail = (_ref60 = (_ref61 = object == null ? void 0 : (_object_customer_details15 = object.customer_details) == null ? void 0 : _object_customer_details15.email) != null ? _ref61 : order.customerEmail) != null ? _ref60 : null;
|
|
3349
3367
|
if (draftEmail) {
|
|
3350
|
-
var
|
|
3351
|
-
var _order_totals,
|
|
3352
|
-
const chargedCents = Number((
|
|
3368
|
+
var _ref63, _ref64, _ref65;
|
|
3369
|
+
var _order_totals, _object_customer_details16;
|
|
3370
|
+
const chargedCents = Number((_ref63 = object == null ? void 0 : object.amount_total) != null ? _ref63 : 0) || Number((_ref64 = (_order_totals = order.totals) == null ? void 0 : _order_totals.totalCents) != null ? _ref64 : 0);
|
|
3353
3371
|
await captureHostContact(_extends({
|
|
3354
3372
|
hostId: String(hostId),
|
|
3355
3373
|
email: draftEmail,
|
|
3356
|
-
name: (
|
|
3374
|
+
name: (_ref65 = object == null ? void 0 : (_object_customer_details16 = object.customer_details) == null ? void 0 : _object_customer_details16.name) != null ? _ref65 : undefined,
|
|
3357
3375
|
source: 'order',
|
|
3358
3376
|
initialLifecycleStage: 'customer'
|
|
3359
3377
|
}, chargedCents > 0 ? {
|
|
@@ -3366,15 +3384,15 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3366
3384
|
}));
|
|
3367
3385
|
}
|
|
3368
3386
|
if (productId) {
|
|
3369
|
-
var _productSnapshot_data,
|
|
3387
|
+
var _productSnapshot_data, _ref66, _ref67;
|
|
3370
3388
|
var _object_metadata30, _lifted_variants_, _order_lineItems_, _order_lineItems;
|
|
3371
3389
|
const productRef = hostRef.collection('products').doc(String(productId));
|
|
3372
3390
|
const productSnapshot = await productRef.get();
|
|
3373
3391
|
const lifted = CommerceModel.liftLegacyProduct((_productSnapshot_data = productSnapshot.data()) != null ? _productSnapshot_data : {
|
|
3374
3392
|
name: 'Product'
|
|
3375
3393
|
});
|
|
3376
|
-
const soldVariantId = String((
|
|
3377
|
-
const quantity = (
|
|
3394
|
+
const soldVariantId = String((_ref66 = (_object_metadata30 = object.metadata) == null ? void 0 : _object_metadata30.variantId) != null ? _ref66 : '') || ((_lifted_variants_ = lifted.variants[0]) == null ? void 0 : _lifted_variants_.id);
|
|
3395
|
+
const quantity = (_ref67 = (_order_lineItems = order.lineItems) == null ? void 0 : (_order_lineItems_ = _order_lineItems[0]) == null ? void 0 : _order_lineItems_.quantity) != null ? _ref67 : 1;
|
|
3378
3396
|
if (soldVariantId) {
|
|
3379
3397
|
// Atomic since AGL-2320.
|
|
3380
3398
|
const moved = await decrementVariantStock({
|
|
@@ -3426,10 +3444,10 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3426
3444
|
// would decrement it twice.
|
|
3427
3445
|
const paidProducts = new Map();
|
|
3428
3446
|
for (const line of (_order_lineItems1 = order.lineItems) != null ? _order_lineItems1 : []){
|
|
3429
|
-
var
|
|
3447
|
+
var _ref68, _ref69, _line_variantId1;
|
|
3430
3448
|
var _lineProduct_variants_;
|
|
3431
|
-
const lineProductId = String((
|
|
3432
|
-
const soldQty = Math.round(Number((
|
|
3449
|
+
const lineProductId = String((_ref68 = line == null ? void 0 : line.productId) != null ? _ref68 : '');
|
|
3450
|
+
const soldQty = Math.round(Number((_ref69 = line == null ? void 0 : line.quantity) != null ? _ref69 : 0));
|
|
3433
3451
|
if (!lineProductId || !(soldQty > 0)) continue;
|
|
3434
3452
|
// Firestore reserves `__…__` ids and `.doc()` throws
|
|
3435
3453
|
// synchronously on one; a corrupt line must not fail the
|
|
@@ -3492,8 +3510,8 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3492
3510
|
var _object_metadata31;
|
|
3493
3511
|
const { hostId, productId, feeCents, couponCode } = (_object_metadata31 = object.metadata) != null ? _object_metadata31 : {};
|
|
3494
3512
|
if (hostId && productId) {
|
|
3495
|
-
var
|
|
3496
|
-
var _object_metadata32, _buyNowLineItems_,
|
|
3513
|
+
var _ref70, _productForSnapshot_get1, _productForSnapshot_data1, _ref71, _ref72, _ref73, _ref74, _ref75, _ref76, _ref77;
|
|
3514
|
+
var _object_metadata32, _buyNowLineItems_, _object_customer_details17, _object_customer_details18, _object_customer_details19, _object_metadata33;
|
|
3497
3515
|
const firestore = firebaseAdmin.app().firestore();
|
|
3498
3516
|
const hostRef = firestore.collection('hosts').doc(String(hostId));
|
|
3499
3517
|
// Orders v1 (AGL-283): line-item snapshot + totals + timeline with
|
|
@@ -3503,7 +3521,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3503
3521
|
// is bounded to Stripe's at-least-once edge).
|
|
3504
3522
|
const orderRef = hostRef.collection('orders').doc(String(object.id));
|
|
3505
3523
|
const counterRef = hostRef.collection('counters').doc('orders');
|
|
3506
|
-
const amountCents = Number((
|
|
3524
|
+
const amountCents = Number((_ref70 = object == null ? void 0 : object.amount_total) != null ? _ref70 : 0);
|
|
3507
3525
|
const productForSnapshot = await hostRef.collection('products').doc(String(productId)).get();
|
|
3508
3526
|
const snapshotName = String((_productForSnapshot_get1 = productForSnapshot.get('name')) != null ? _productForSnapshot_get1 : 'Product');
|
|
3509
3527
|
// AGL-1711: the line item and totals used to be fabricated from
|
|
@@ -3516,7 +3534,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3516
3534
|
name: snapshotName
|
|
3517
3535
|
});
|
|
3518
3536
|
const soldVariant = ((_object_metadata32 = object.metadata) == null ? void 0 : _object_metadata32.variantId) ? liftedForSnapshot.variants.find((item)=>item.id === String(object.metadata.variantId)) : liftedForSnapshot.variants[0];
|
|
3519
|
-
const variantOptions = Object.values((
|
|
3537
|
+
const variantOptions = Object.values((_ref71 = soldVariant == null ? void 0 : soldVariant.options) != null ? _ref71 : {});
|
|
3520
3538
|
const { lineItems: buyNowLineItems, totals: buyNowTotals } = CommerceModel.computeBuyNowOrder(object, _extends({
|
|
3521
3539
|
name: snapshotName
|
|
3522
3540
|
}, variantOptions.length ? {
|
|
@@ -3528,7 +3546,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3528
3546
|
} : {}, liftedForSnapshot.supplierId ? {
|
|
3529
3547
|
supplierId: liftedForSnapshot.supplierId
|
|
3530
3548
|
} : {}));
|
|
3531
|
-
const soldQuantity = (
|
|
3549
|
+
const soldQuantity = (_ref72 = (_buyNowLineItems_ = buyNowLineItems[0]) == null ? void 0 : _buyNowLineItems_.quantity) != null ? _ref72 : 1;
|
|
3532
3550
|
const created = await firestore.runTransaction(async (transaction)=>{
|
|
3533
3551
|
var _counter_get, _ref, _ref1, _ref2, _ref3;
|
|
3534
3552
|
var _object_metadata, _object_customer_details, _object_customer_details1;
|
|
@@ -3543,7 +3561,8 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3543
3561
|
}, {
|
|
3544
3562
|
merge: true
|
|
3545
3563
|
});
|
|
3546
|
-
|
|
3564
|
+
// With the fields the orders list queries by (AGL-3321).
|
|
3565
|
+
transaction.set(orderRef, CommerceModel.withOrderListFields(orderRef.id, _extends({
|
|
3547
3566
|
number,
|
|
3548
3567
|
status: 'paid',
|
|
3549
3568
|
channel: 'online',
|
|
@@ -3577,7 +3596,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3577
3596
|
couponCode
|
|
3578
3597
|
} : {}, {
|
|
3579
3598
|
createdAt: firebaseAdmin.firestore.FieldValue.serverTimestamp()
|
|
3580
|
-
}));
|
|
3599
|
+
})));
|
|
3581
3600
|
return true;
|
|
3582
3601
|
});
|
|
3583
3602
|
// Redelivery guard (AGL-498): skip the notification + fulfilment side
|
|
@@ -3587,8 +3606,8 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3587
3606
|
// in the bell, not just the owner's email.
|
|
3588
3607
|
void notifyHostManagers(String(hostId), _extends({
|
|
3589
3608
|
type: 'content.order',
|
|
3590
|
-
title: `New order — $${(Number((
|
|
3591
|
-
}, (object == null ? void 0 : (
|
|
3609
|
+
title: `New order — $${(Number((_ref73 = object == null ? void 0 : object.amount_total) != null ? _ref73 : 0) / 100).toFixed(2)}`
|
|
3610
|
+
}, (object == null ? void 0 : (_object_customer_details17 = object.customer_details) == null ? void 0 : _object_customer_details17.email) ? {
|
|
3592
3611
|
body: `From ${object.customer_details.email}`
|
|
3593
3612
|
} : {}, {
|
|
3594
3613
|
link: `/${hostId}/products`
|
|
@@ -3692,14 +3711,14 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3692
3711
|
// Contacts ingestion (AGL-197): buyers become contacts.
|
|
3693
3712
|
await captureHostContact({
|
|
3694
3713
|
hostId: String(hostId),
|
|
3695
|
-
email: object == null ? void 0 : (
|
|
3696
|
-
name: (
|
|
3714
|
+
email: object == null ? void 0 : (_object_customer_details18 = object.customer_details) == null ? void 0 : _object_customer_details18.email,
|
|
3715
|
+
name: (_ref74 = object == null ? void 0 : (_object_customer_details19 = object.customer_details) == null ? void 0 : _object_customer_details19.name) != null ? _ref74 : undefined,
|
|
3697
3716
|
source: 'order',
|
|
3698
3717
|
initialLifecycleStage: 'customer',
|
|
3699
|
-
purchaseCents: Number((
|
|
3718
|
+
purchaseCents: Number((_ref75 = object == null ? void 0 : object.amount_total) != null ? _ref75 : 0),
|
|
3700
3719
|
interaction: {
|
|
3701
3720
|
refId: String(object.id),
|
|
3702
|
-
summary: `Placed an order ($${(Number((
|
|
3721
|
+
summary: `Placed an order ($${(Number((_ref76 = object == null ? void 0 : object.amount_total) != null ? _ref76 : 0) / 100).toFixed(2)})`
|
|
3703
3722
|
}
|
|
3704
3723
|
});
|
|
3705
3724
|
const productRef = hostRef.collection('products').doc(String(productId));
|
|
@@ -3717,12 +3736,12 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3717
3736
|
// serialize; the snapshot above is still read, for the product NAME on
|
|
3718
3737
|
// the receipt below, and no longer decides any count.
|
|
3719
3738
|
{
|
|
3720
|
-
var _productSnapshot_data2,
|
|
3739
|
+
var _productSnapshot_data2, _ref78;
|
|
3721
3740
|
var _object_metadata34, _lifted_variants_1;
|
|
3722
3741
|
const lifted = CommerceModel.liftLegacyProduct((_productSnapshot_data2 = productSnapshot.data()) != null ? _productSnapshot_data2 : {
|
|
3723
3742
|
name: 'Product'
|
|
3724
3743
|
});
|
|
3725
|
-
const soldVariantId = String((
|
|
3744
|
+
const soldVariantId = String((_ref78 = (_object_metadata34 = object.metadata) == null ? void 0 : _object_metadata34.variantId) != null ? _ref78 : '') || ((_lifted_variants_1 = lifted.variants[0]) == null ? void 0 : _lifted_variants_1.id);
|
|
3726
3745
|
if (soldVariantId) {
|
|
3727
3746
|
// AGL-1711: `-1` regardless of how many units were bought, so a
|
|
3728
3747
|
// 3-unit buy-now sale decremented stock by one and the difference
|
|
@@ -3753,14 +3772,14 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3753
3772
|
// Settlement, the same way round and for the same reason as the cart
|
|
3754
3773
|
// branch above (AGL-2356): the decrement lands first, then the
|
|
3755
3774
|
// reservation is dropped.
|
|
3756
|
-
await releaseStockHold(hostRef, String((
|
|
3775
|
+
await releaseStockHold(hostRef, String((_ref77 = (_object_metadata33 = object.metadata) == null ? void 0 : _object_metadata33.stockHoldKey) != null ? _ref77 : ''));
|
|
3757
3776
|
if (couponCode) {
|
|
3758
|
-
var
|
|
3777
|
+
var _ref79;
|
|
3759
3778
|
var _object_metadata35;
|
|
3760
3779
|
await settleRedemption({
|
|
3761
3780
|
firestore,
|
|
3762
3781
|
ref: hostRef.collection('coupons').doc(String(couponCode)),
|
|
3763
|
-
holdKey: String((
|
|
3782
|
+
holdKey: String((_ref79 = (_object_metadata35 = object.metadata) == null ? void 0 : _object_metadata35.couponHoldKey) != null ? _ref79 : ''),
|
|
3764
3783
|
orderRef,
|
|
3765
3784
|
label: `coupon ${couponCode}`,
|
|
3766
3785
|
detail: `Coupon ${couponCode} was applied to this order but no longer ` + 'exists, so the redemption is uncounted against its limit.'
|
|
@@ -3769,14 +3788,14 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3769
3788
|
// Receipt + seller notification (AGL-96): env-gated like every
|
|
3770
3789
|
// other outbound email; failures never fail the webhook.
|
|
3771
3790
|
if (isEmailConfigured()) {
|
|
3772
|
-
var _productSnapshot_get,
|
|
3773
|
-
var
|
|
3791
|
+
var _productSnapshot_get, _ref80;
|
|
3792
|
+
var _object_customer_details20, _org, _this3;
|
|
3774
3793
|
const productName = String((_productSnapshot_get = productSnapshot.get('name')) != null ? _productSnapshot_get : 'your purchase');
|
|
3775
|
-
const amount = (Number((
|
|
3776
|
-
const buyerEmail = object == null ? void 0 : (
|
|
3794
|
+
const amount = (Number((_ref80 = object == null ? void 0 : object.amount_total) != null ? _ref80 : 0) / 100).toFixed(2);
|
|
3795
|
+
const buyerEmail = object == null ? void 0 : (_object_customer_details20 = object.customer_details) == null ? void 0 : _object_customer_details20.email;
|
|
3777
3796
|
const orderTotal = `$${amount}`;
|
|
3778
3797
|
if (buyerEmail) {
|
|
3779
|
-
var
|
|
3798
|
+
var _ref81;
|
|
3780
3799
|
const fallbackText = `Thanks for your purchase!\n\n${productName} — $${amount}` + `\nOrder reference: ${object.id}`;
|
|
3781
3800
|
// Site-owner-designed template when published (AGL-771).
|
|
3782
3801
|
const designed = await renderHostEmailWithTokens(firebaseAdmin.app().firestore(), String(hostId), 'order-receipt', {
|
|
@@ -3786,7 +3805,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3786
3805
|
});
|
|
3787
3806
|
await sendEmail(_extends({
|
|
3788
3807
|
to: String(buyerEmail),
|
|
3789
|
-
subject: (
|
|
3808
|
+
subject: (_ref81 = designed == null ? void 0 : designed.subject) != null ? _ref81 : `Receipt: ${productName}`,
|
|
3790
3809
|
text: (designed == null ? void 0 : designed.text) || fallbackText
|
|
3791
3810
|
}, (designed == null ? void 0 : designed.html) ? {
|
|
3792
3811
|
html: designed.html
|
|
@@ -3817,7 +3836,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3817
3836
|
// SSO.
|
|
3818
3837
|
const seller = (_this4 = await findUserByUidAcrossPools(sellerUid).catch(()=>null)) == null ? void 0 : _this4.record;
|
|
3819
3838
|
if (seller == null ? void 0 : seller.email) {
|
|
3820
|
-
var _hostSnapshot_get,
|
|
3839
|
+
var _hostSnapshot_get, _ref82;
|
|
3821
3840
|
const siteName = String((_hostSnapshot_get = hostSnapshot.get('displayName')) != null ? _hostSnapshot_get : hostId);
|
|
3822
3841
|
const fallbackText = `You made a sale on ${siteName}!\n\n${productName} — $${amount}` + (buyerEmail ? `\nBuyer: ${buyerEmail}` : '') + `\nOrder reference: ${object.id}`;
|
|
3823
3842
|
// Site-owner-designed template when published (AGL-771).
|
|
@@ -3830,7 +3849,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3830
3849
|
});
|
|
3831
3850
|
await sendEmail(_extends({
|
|
3832
3851
|
to: seller.email,
|
|
3833
|
-
subject: (
|
|
3852
|
+
subject: (_ref82 = designed == null ? void 0 : designed.subject) != null ? _ref82 : `New order: ${productName}`,
|
|
3834
3853
|
text: (designed == null ? void 0 : designed.text) || fallbackText
|
|
3835
3854
|
}, (designed == null ? void 0 : designed.html) ? {
|
|
3836
3855
|
html: designed.html
|
|
@@ -3898,9 +3917,9 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3898
3917
|
const claimed = lookup.kind === 'order' || lookup.kind === 'unresolved';
|
|
3899
3918
|
const snapshot = lookup.kind === 'order' ? lookup.snapshot : null;
|
|
3900
3919
|
if (snapshot) {
|
|
3901
|
-
var
|
|
3920
|
+
var _ref83;
|
|
3902
3921
|
var _snapshot_ref_parent_parent;
|
|
3903
|
-
const hostId = String((
|
|
3922
|
+
const hostId = String((_ref83 = (_snapshot_ref_parent_parent = snapshot.ref.parent.parent) == null ? void 0 : _snapshot_ref_parent_parent.id) != null ? _ref83 : '');
|
|
3904
3923
|
if (type === 'charge.dispute.created') {
|
|
3905
3924
|
const { opened, record } = await recordDisputeOpened(snapshot, dispute);
|
|
3906
3925
|
if (opened && hostId) {
|
|
@@ -3917,7 +3936,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3917
3936
|
});
|
|
3918
3937
|
}
|
|
3919
3938
|
} else {
|
|
3920
|
-
var
|
|
3939
|
+
var _ref84;
|
|
3921
3940
|
const settled = await recordDisputeClosed(snapshot, dispute);
|
|
3922
3941
|
if (settled.recorded && hostId) {
|
|
3923
3942
|
await notifyHostManagers(hostId, {
|
|
@@ -3975,7 +3994,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3975
3994
|
// transiently-failed reversal gets its retry — and gated inside on
|
|
3976
3995
|
// the order's own `reversedTransferCents` marker, so it runs at most
|
|
3977
3996
|
// once per dispute however many times Stripe delivers.
|
|
3978
|
-
if (String((
|
|
3997
|
+
if (String((_ref84 = dispute == null ? void 0 : dispute.status) != null ? _ref84 : '') === 'lost') {
|
|
3979
3998
|
const pulledBackCents = await reverseSellerShare(snapshot.ref, dispute);
|
|
3980
3999
|
// The merchant-experience half of the AGL-1794 decision, and not an
|
|
3981
4000
|
// optional extra: the reversal takes money out of the connected
|