@aglyn/plugins-commerce 1.0.0-beta.290 → 1.0.0-beta.291
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/package.json +13 -13
- package/src/lib/components/commerce-console-page.js +2 -1
- package/src/lib/components/commerce-console-page.js.map +1 -1
- package/src/lib/components/console/host-orders-card.component.d.ts +6 -0
- package/src/lib/components/console/host-orders-card.component.js +3 -2
- package/src/lib/components/console/host-orders-card.component.js.map +1 -1
- package/src/lib/components/console/invoice-send.component.d.ts +44 -0
- package/src/lib/components/console/invoice-send.component.js +237 -0
- package/src/lib/components/console/invoice-send.component.js.map +1 -0
- package/src/lib/components/console/order-detail-dialog.component.d.ts +5 -0
- package/src/lib/components/console/order-detail-dialog.component.js +9 -2
- package/src/lib/components/console/order-detail-dialog.component.js.map +1 -1
- package/src/lib/components/console/order-invoice.component.d.ts +9 -0
- package/src/lib/components/console/order-invoice.component.js +27 -2
- package/src/lib/components/console/order-invoice.component.js.map +1 -1
- package/src/lib/components/console/quote-editor-dialog.component.d.ts +29 -0
- package/src/lib/components/console/quote-editor-dialog.component.js +102 -4
- package/src/lib/components/console/quote-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/quote-proofs.component.d.ts +11 -0
- package/src/lib/components/console/quote-proofs.component.js +68 -0
- package/src/lib/components/console/quote-proofs.component.js.map +1 -1
- package/src/lib/components/console/quote-send.component.d.ts +42 -0
- package/src/lib/components/console/quote-send.component.js +307 -0
- package/src/lib/components/console/quote-send.component.js.map +1 -0
- package/src/lib/components/console/quote-start.component.d.ts +45 -0
- package/src/lib/components/console/quote-start.component.js +182 -0
- package/src/lib/components/console/quote-start.component.js.map +1 -0
- package/src/lib/components/product-options-field-body.d.ts +44 -0
- package/src/lib/components/product-options-field-body.js +260 -0
- package/src/lib/components/product-options-field-body.js.map +1 -0
- package/src/lib/components/product-options-field.d.ts +32 -0
- package/src/lib/components/product-options-field.js +128 -0
- package/src/lib/components/product-options-field.js.map +1 -0
- package/src/lib/components/quote-page-body.js +39 -20
- package/src/lib/components/quote-page-body.js.map +1 -1
- package/src/lib/model/commerce-invoices.d.ts +132 -0
- package/src/lib/model/commerce-invoices.js +332 -0
- package/src/lib/model/commerce-invoices.js.map +1 -0
- package/src/lib/model/commerce-orders.d.ts +29 -2
- package/src/lib/model/commerce-orders.js.map +1 -1
- package/src/lib/model/commerce-product-field.d.ts +23 -0
- package/src/lib/model/commerce-product-field.js +26 -0
- package/src/lib/model/commerce-product-field.js.map +1 -0
- package/src/lib/model/commerce-quote-email.d.ts +67 -0
- package/src/lib/model/commerce-quote-email.js +154 -0
- package/src/lib/model/commerce-quote-email.js.map +1 -0
- package/src/lib/model/commerce-quote-pay.d.ts +49 -6
- package/src/lib/model/commerce-quote-pay.js +69 -36
- package/src/lib/model/commerce-quote-pay.js.map +1 -1
- package/src/lib/model/commerce-quote-request.d.ts +93 -0
- package/src/lib/model/commerce-quote-request.js +207 -0
- package/src/lib/model/commerce-quote-request.js.map +1 -0
- package/src/lib/model/commerce-quotes.d.ts +81 -0
- package/src/lib/model/commerce-quotes.js.map +1 -1
- package/src/lib/model/index.d.ts +3 -0
- package/src/lib/model/index.js +3 -0
- package/src/lib/model/index.js.map +1 -1
- package/src/lib/plugin.js +19 -0
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/server/billing-webhook.js +115 -70
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/commerce-pdf.d.ts +5 -1
- package/src/lib/server/commerce-pdf.js +37 -10
- package/src/lib/server/commerce-pdf.js.map +1 -1
- package/src/lib/server/draft-order.js +23 -3
- package/src/lib/server/draft-order.js.map +1 -1
- package/src/lib/server/invoice-email.d.ts +76 -0
- package/src/lib/server/invoice-email.js +183 -0
- package/src/lib/server/invoice-email.js.map +1 -0
- package/src/lib/server/order-invoice-send.d.ts +43 -0
- package/src/lib/server/order-invoice-send.js +218 -0
- package/src/lib/server/order-invoice-send.js.map +1 -0
- package/src/lib/server/order-status.d.ts +11 -0
- package/src/lib/server/order-status.js +44 -8
- package/src/lib/server/order-status.js.map +1 -1
- package/src/lib/server/person-eraser.d.ts +3 -2
- package/src/lib/server/person-eraser.js +25 -6
- package/src/lib/server/person-eraser.js.map +1 -1
- package/src/lib/server/quote-email.d.ts +85 -0
- package/src/lib/server/quote-email.js +211 -0
- package/src/lib/server/quote-email.js.map +1 -0
- package/src/lib/server/quote-link-token.d.ts +11 -0
- package/src/lib/server/quote-link-token.js +21 -0
- package/src/lib/server/quote-link-token.js.map +1 -1
- package/src/lib/server/quote-pay.d.ts +8 -3
- package/src/lib/server/quote-pay.js +105 -43
- package/src/lib/server/quote-pay.js.map +1 -1
- package/src/lib/server/quote.d.ts +11 -0
- package/src/lib/server/quote.js +309 -12
- package/src/lib/server/quote.js.map +1 -1
- package/src/lib/server/site-page-resolver.js +2 -1
- package/src/lib/server/site-page-resolver.js.map +1 -1
- package/src/lib/server.js +5 -0
- package/src/lib/server.js.map +1 -1
- package/src/lib/site.js +8 -0
- package/src/lib/site.js.map +1 -1
- package/src/lib/tenant-emails.js +243 -0
- package/src/lib/tenant-emails.js.map +1 -1
- package/src/lib/utils/commerce-document-pdf.d.ts +5 -0
- package/src/lib/utils/commerce-document-pdf.js +6 -1
- package/src/lib/utils/commerce-document-pdf.js.map +1 -1
- package/src/lib/utils/invoice-email-content.d.ts +45 -0
- package/src/lib/utils/invoice-email-content.js +126 -0
- package/src/lib/utils/invoice-email-content.js.map +1 -0
- package/src/lib/utils/order-invoice.d.ts +1 -1
- package/src/lib/utils/order-invoice.js +14 -6
- package/src/lib/utils/order-invoice.js.map +1 -1
- package/src/lib/utils/quote-email-content.d.ts +62 -0
- package/src/lib/utils/quote-email-content.js +154 -0
- package/src/lib/utils/quote-email-content.js.map +1 -0
|
@@ -3631,9 +3631,11 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3631
3631
|
// A payment a quote could not take (AGL-4094), reported below.
|
|
3632
3632
|
let quoteUnmatched = null;
|
|
3633
3633
|
let quoteLabel = '';
|
|
3634
|
+
// What the money was for, as the alert says it (AGL-4099).
|
|
3635
|
+
let unmatchedNoun = 'quote';
|
|
3634
3636
|
const flipped = await firestore.runTransaction(async (transaction)=>{
|
|
3635
3637
|
var _snapshot_data, _snapshot_data1, _snapshot_data2, _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;
|
|
3636
|
-
var _object_customer_details,
|
|
3638
|
+
var _object_metadata, _object_customer_details, _object_metadata1, _object_customer_details1, _lifted_totals1;
|
|
3637
3639
|
const snapshot = await transaction.get(orderRef);
|
|
3638
3640
|
if (!snapshot.exists) return false;
|
|
3639
3641
|
const raw = (_snapshot_data = snapshot.data()) != null ? _snapshot_data : null;
|
|
@@ -3644,20 +3646,20 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3644
3646
|
// and the business is told, as a paid-after-cancel payment is.
|
|
3645
3647
|
if (raw && CommerceModel.isQuote(raw) && raw.quote) {
|
|
3646
3648
|
var _ref7, _ref8, _ref9, _ref10, _ref11, _ref12, _ref13, _ref14;
|
|
3647
|
-
var
|
|
3649
|
+
var _object_metadata2, _object_metadata3, _object_customer_details2, _object_customer_details3, _object_metadata4, _object_metadata5;
|
|
3648
3650
|
const facts = {
|
|
3649
3651
|
sessionId: String((_ref7 = object == null ? void 0 : object.id) != null ? _ref7 : ''),
|
|
3650
3652
|
paymentIntentId: String((_ref8 = object == null ? void 0 : object.payment_intent) != null ? _ref8 : '') || null,
|
|
3651
|
-
linkVersion: (_ref9 = object == null ? void 0 : (
|
|
3652
|
-
quoteUpdatedAtMs: (_ref10 = object == null ? void 0 : (
|
|
3653
|
+
linkVersion: (_ref9 = object == null ? void 0 : (_object_metadata2 = object.metadata) == null ? void 0 : _object_metadata2.quoteLinkVersion) != null ? _ref9 : null,
|
|
3654
|
+
quoteUpdatedAtMs: (_ref10 = object == null ? void 0 : (_object_metadata3 = object.metadata) == null ? void 0 : _object_metadata3.quoteUpdatedAtMs) != null ? _ref10 : null,
|
|
3653
3655
|
paidAtMs: Date.now(),
|
|
3654
3656
|
email: (_ref11 = object == null ? void 0 : (_object_customer_details2 = object.customer_details) == null ? void 0 : _object_customer_details2.email) != null ? _ref11 : null,
|
|
3655
3657
|
name: (_ref12 = object == null ? void 0 : (_object_customer_details3 = object.customer_details) == null ? void 0 : _object_customer_details3.name) != null ? _ref12 : null,
|
|
3656
3658
|
amountTotalCents: Number.isFinite(chargedTotalCents) ? chargedTotalCents : null,
|
|
3657
3659
|
shippingCents,
|
|
3658
3660
|
taxCents: stripeTaxCents,
|
|
3659
|
-
feeCents: Number((_ref13 = object == null ? void 0 : (
|
|
3660
|
-
taxMode: storefrontTaxModeOf(object, Number((_ref14 = object == null ? void 0 : (
|
|
3661
|
+
feeCents: Number((_ref13 = object == null ? void 0 : (_object_metadata4 = object.metadata) == null ? void 0 : _object_metadata4.feeCents) != null ? _ref13 : 0) || 0,
|
|
3662
|
+
taxMode: storefrontTaxModeOf(object, Number((_ref14 = object == null ? void 0 : (_object_metadata5 = object.metadata) == null ? void 0 : _object_metadata5.taxCents) != null ? _ref14 : 0)),
|
|
3661
3663
|
shippingAddress: (shipTo == null ? void 0 : shipTo.address) ? Object.fromEntries(Object.entries({
|
|
3662
3664
|
name: shipTo.name,
|
|
3663
3665
|
line1: shipTo.address.line1,
|
|
@@ -3696,6 +3698,47 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3696
3698
|
return true;
|
|
3697
3699
|
}
|
|
3698
3700
|
const lifted = CommerceModel.liftLegacyOrder((_snapshot_data1 = snapshot.data()) != null ? _snapshot_data1 : {});
|
|
3701
|
+
// AN INVOICE'S PAY LINK (AGL-4099). A draft order paid through the
|
|
3702
|
+
// lasting link its invoice carries answers as a quote's link does:
|
|
3703
|
+
// a payment through a replaced link, or a second payment after the
|
|
3704
|
+
// order was paid, is recorded on the order (`payLink`) and the
|
|
3705
|
+
// business is told, never fulfilled and never lost. A payment for
|
|
3706
|
+
// it as it stands falls through to the flip below, which is the
|
|
3707
|
+
// draft's own: it restates the list fields from the document, so
|
|
3708
|
+
// the draft's are not stamped twice, and moves stock for catalog
|
|
3709
|
+
// lines only. A canceled order keeps AGL-2244's handling below.
|
|
3710
|
+
const invoiceLinkVersion = object == null ? void 0 : (_object_metadata = object.metadata) == null ? void 0 : _object_metadata.payLinkVersion;
|
|
3711
|
+
if (invoiceLinkVersion != null && invoiceLinkVersion !== '' && lifted.status !== 'cancelled') {
|
|
3712
|
+
var _ref15, _ref16;
|
|
3713
|
+
const facts = {
|
|
3714
|
+
sessionId: String((_ref15 = object == null ? void 0 : object.id) != null ? _ref15 : ''),
|
|
3715
|
+
paymentIntentId: String((_ref16 = object == null ? void 0 : object.payment_intent) != null ? _ref16 : '') || null,
|
|
3716
|
+
linkVersion: invoiceLinkVersion,
|
|
3717
|
+
paidAtMs: Date.now(),
|
|
3718
|
+
amountTotalCents: Number.isFinite(chargedTotalCents) ? chargedTotalCents : null
|
|
3719
|
+
};
|
|
3720
|
+
const disposition = CommerceModel.quotePaymentDisposition(lifted, facts);
|
|
3721
|
+
if (disposition === 'redelivery') return false;
|
|
3722
|
+
if (disposition !== 'pay') {
|
|
3723
|
+
var _lifted_payLink;
|
|
3724
|
+
const entry = CommerceModel.quoteUnmatchedPayment(facts, disposition);
|
|
3725
|
+
quoteUnmatched = entry;
|
|
3726
|
+
quoteLabel = CommerceModel.formatInvoiceNumber(lifted, String(orderId));
|
|
3727
|
+
unmatchedNoun = 'invoice';
|
|
3728
|
+
transaction.set(orderRef, {
|
|
3729
|
+
payLink: _extends({}, (_lifted_payLink = lifted.payLink) != null ? _lifted_payLink : {}, {
|
|
3730
|
+
unmatchedPayments: [
|
|
3731
|
+
...CommerceModel.orderPayLinkUnmatched(lifted),
|
|
3732
|
+
entry
|
|
3733
|
+
]
|
|
3734
|
+
}),
|
|
3735
|
+
timeline: CommerceModel.appendOrderEvent(lifted, 'invoice-payment-unmatched', CommerceModel.quoteUnmatchedPaymentDetail(entry, 'invoice'), facts.paidAtMs)
|
|
3736
|
+
}, {
|
|
3737
|
+
merge: true
|
|
3738
|
+
});
|
|
3739
|
+
return false;
|
|
3740
|
+
}
|
|
3741
|
+
}
|
|
3699
3742
|
if (lifted.status !== 'pending') {
|
|
3700
3743
|
var _lifted_timeline;
|
|
3701
3744
|
// NOT ALL NON-`pending` ORDERS ARE REDELIVERIES (AGL-2244), and
|
|
@@ -3750,7 +3793,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3750
3793
|
// record that any of the charge was tax (AGL-1953). Without it
|
|
3751
3794
|
// every register card sale would stamp `none` beside an order
|
|
3752
3795
|
// plainly carrying tax.
|
|
3753
|
-
taxMode: storefrontTaxModeOf(object, Number((_ref2 = object == null ? void 0 : (
|
|
3796
|
+
taxMode: storefrontTaxModeOf(object, Number((_ref2 = object == null ? void 0 : (_object_metadata1 = object.metadata) == null ? void 0 : _object_metadata1.taxCents) != null ? _ref2 : 0)),
|
|
3754
3797
|
paymentIntentId: String((_ref3 = object == null ? void 0 : object.payment_intent) != null ? _ref3 : '') || null,
|
|
3755
3798
|
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,
|
|
3756
3799
|
timeline: CommerceModel.appendOrderEvent(lifted, 'paid'),
|
|
@@ -3791,7 +3834,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3791
3834
|
await notifyHostManagers(String(hostId), {
|
|
3792
3835
|
type: 'content.order',
|
|
3793
3836
|
title: unmatched.reason === 'already-paid' ? `${quoteLabel} was paid twice` : `A replaced link for ${quoteLabel} was paid`,
|
|
3794
|
-
body: `${quoteLabel} on {site}: ${CommerceModel.quoteUnmatchedPaymentDetail(unmatched)}`,
|
|
3837
|
+
body: `${quoteLabel} on {site}: ${CommerceModel.quoteUnmatchedPaymentDetail(unmatched, unmatchedNoun)}`,
|
|
3795
3838
|
link: `/${hostId}/products/orders`
|
|
3796
3839
|
});
|
|
3797
3840
|
}
|
|
@@ -3804,8 +3847,8 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3804
3847
|
});
|
|
3805
3848
|
}
|
|
3806
3849
|
if (flipped) {
|
|
3807
|
-
var _ref62, _ref63, _ref64, _ref65, _ref66, _ref67;
|
|
3808
|
-
var _object_metadata28, _object_customer_details15, _order_totals, _object_customer_details16;
|
|
3850
|
+
var _ref62, _ref63, _ref64, _ref65, _ref66, _ref67, _ref68;
|
|
3851
|
+
var _object_metadata28, _object_customer_details15, _order_totals, _object_metadata29, _object_customer_details16;
|
|
3809
3852
|
const order = paidOrder;
|
|
3810
3853
|
// A legacy register QR sale is a register sale completing (AGL-3607).
|
|
3811
3854
|
if (order.channel === 'pos') {
|
|
@@ -3830,12 +3873,12 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3830
3873
|
// the hold existed, which Stripe's at-least-once delivery would run
|
|
3831
3874
|
// twice. The transition is what makes it once.
|
|
3832
3875
|
if ((_object_metadata28 = object.metadata) == null ? void 0 : _object_metadata28.discountId) {
|
|
3833
|
-
var
|
|
3834
|
-
var
|
|
3876
|
+
var _ref69;
|
|
3877
|
+
var _object_metadata30;
|
|
3835
3878
|
await settleRedemption({
|
|
3836
3879
|
firestore,
|
|
3837
3880
|
ref: hostRef.collection('discounts').doc(String(object.metadata.discountId)),
|
|
3838
|
-
holdKey: String((
|
|
3881
|
+
holdKey: String((_ref69 = (_object_metadata30 = object.metadata) == null ? void 0 : _object_metadata30.discountHoldKey) != null ? _ref69 : ''),
|
|
3839
3882
|
orderRef,
|
|
3840
3883
|
label: `discount ${object.metadata.discountId}`,
|
|
3841
3884
|
detail: `Discount ${object.metadata.discountId} was applied to this ` + 'order but no longer exists, so the redemption is uncounted ' + 'against its limit.'
|
|
@@ -3845,11 +3888,13 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3845
3888
|
const draftPayer = (_ref62 = (_ref63 = object == null ? void 0 : (_object_customer_details15 = object.customer_details) == null ? void 0 : _object_customer_details15.email) != null ? _ref63 : order.customerEmail) != null ? _ref62 : null;
|
|
3846
3889
|
const draftPaidCents = Number((_ref64 = object == null ? void 0 : object.amount_total) != null ? _ref64 : 0) || Number((_ref65 = (_order_totals = order.totals) == null ? void 0 : _order_totals.totalCents) != null ? _ref65 : 0);
|
|
3847
3890
|
const isQuotePayment = CommerceModel.isQuote(order);
|
|
3891
|
+
// A draft paid through its invoice's link (AGL-4099).
|
|
3892
|
+
const isInvoicePayment = !isQuotePayment && String((_ref66 = object == null ? void 0 : (_object_metadata29 = object.metadata) == null ? void 0 : _object_metadata29.payLinkVersion) != null ? _ref66 : '') !== '';
|
|
3848
3893
|
void notifyHostManagers(String(hostId), {
|
|
3849
3894
|
type: 'content.order',
|
|
3850
|
-
title: isQuotePayment ? `Quote paid — ${CommerceModel.formatQuoteNumber(order, String(orderId))}` : `Draft order paid — ${draftLabel}`,
|
|
3895
|
+
title: isQuotePayment ? `Quote paid — ${CommerceModel.formatQuoteNumber(order, String(orderId))}` : isInvoicePayment ? `Invoice paid — ${draftLabel}` : `Draft order paid — ${draftLabel}`,
|
|
3851
3896
|
// Who paid what, and where (AGL-3432).
|
|
3852
|
-
body: isQuotePayment ? `${draftPayer != null ? draftPayer : 'The customer'} paid ${CommerceModel.formatQuoteNumber(order, String(orderId))} ` + `on {site}: $${(draftPaidCents / 100).toFixed(2)}. It is order ${draftLabel} now.` : `${draftPayer != null ? draftPayer : 'The buyer'} paid draft order ${draftLabel} ` + `on {site}: $${(draftPaidCents / 100).toFixed(2)}.`,
|
|
3897
|
+
body: isQuotePayment ? `${draftPayer != null ? draftPayer : 'The customer'} paid ${CommerceModel.formatQuoteNumber(order, String(orderId))} ` + `on {site}: $${(draftPaidCents / 100).toFixed(2)}. It is order ${draftLabel} now.` : isInvoicePayment ? `${draftPayer != null ? draftPayer : 'The buyer'} paid the invoice for draft order ${draftLabel} ` + `on {site}: $${(draftPaidCents / 100).toFixed(2)}.` : `${draftPayer != null ? draftPayer : 'The buyer'} paid draft order ${draftLabel} ` + `on {site}: $${(draftPaidCents / 100).toFixed(2)}.`,
|
|
3853
3898
|
link: `/${hostId}/products`
|
|
3854
3899
|
});
|
|
3855
3900
|
// Contacts ingestion (AGL-1748): this branch flipped the order,
|
|
@@ -3864,17 +3909,17 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3864
3909
|
// figure the draft was priced at, and the two agree by construction,
|
|
3865
3910
|
// but only one of them is the money that moved. Stored totals remain
|
|
3866
3911
|
// the fallback for a session shape that reports no total.
|
|
3867
|
-
const draftEmail = (
|
|
3912
|
+
const draftEmail = (_ref67 = (_ref68 = object == null ? void 0 : (_object_customer_details16 = object.customer_details) == null ? void 0 : _object_customer_details16.email) != null ? _ref68 : order.customerEmail) != null ? _ref67 : null;
|
|
3868
3913
|
if (draftEmail) {
|
|
3869
|
-
var
|
|
3914
|
+
var _ref70, _ref71, _ref72, _ref73;
|
|
3870
3915
|
var _order_totals1, _object_customer_details17;
|
|
3871
|
-
const chargedCents = Number((
|
|
3916
|
+
const chargedCents = Number((_ref70 = object == null ? void 0 : object.amount_total) != null ? _ref70 : 0) || Number((_ref71 = (_order_totals1 = order.totals) == null ? void 0 : _order_totals1.totalCents) != null ? _ref71 : 0);
|
|
3872
3917
|
await recordCapturedContact(_extends({
|
|
3873
3918
|
orgId: '',
|
|
3874
3919
|
hostId: String(hostId),
|
|
3875
3920
|
identity: {
|
|
3876
3921
|
email: draftEmail,
|
|
3877
|
-
name: (
|
|
3922
|
+
name: (_ref72 = (_ref73 = object == null ? void 0 : (_object_customer_details17 = object.customer_details) == null ? void 0 : _object_customer_details17.name) != null ? _ref73 : order.customerName) != null ? _ref72 : null
|
|
3878
3923
|
},
|
|
3879
3924
|
surface: 'relationship',
|
|
3880
3925
|
lifecycleFloor: 'customer'
|
|
@@ -3901,15 +3946,15 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3901
3946
|
key: 'paid'
|
|
3902
3947
|
});
|
|
3903
3948
|
if (productId) {
|
|
3904
|
-
var _productSnapshot_data,
|
|
3905
|
-
var
|
|
3949
|
+
var _productSnapshot_data, _ref74, _ref75;
|
|
3950
|
+
var _object_metadata31, _lifted_variants_, _order_lineItems_, _order_lineItems;
|
|
3906
3951
|
const productRef = hostRef.collection('products').doc(String(productId));
|
|
3907
3952
|
const productSnapshot = await productRef.get();
|
|
3908
3953
|
const lifted = CommerceModel.liftLegacyProduct((_productSnapshot_data = productSnapshot.data()) != null ? _productSnapshot_data : {
|
|
3909
3954
|
name: 'Product'
|
|
3910
3955
|
});
|
|
3911
|
-
const soldVariantId = String((
|
|
3912
|
-
const quantity = (
|
|
3956
|
+
const soldVariantId = String((_ref74 = (_object_metadata31 = object.metadata) == null ? void 0 : _object_metadata31.variantId) != null ? _ref74 : '') || ((_lifted_variants_ = lifted.variants[0]) == null ? void 0 : _lifted_variants_.id);
|
|
3957
|
+
const quantity = (_ref75 = (_order_lineItems = order.lineItems) == null ? void 0 : (_order_lineItems_ = _order_lineItems[0]) == null ? void 0 : _order_lineItems_.quantity) != null ? _ref75 : 1;
|
|
3913
3958
|
if (soldVariantId) {
|
|
3914
3959
|
// Atomic since AGL-2320.
|
|
3915
3960
|
const moved = await decrementVariantStock({
|
|
@@ -3961,10 +4006,10 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
3961
4006
|
// would decrement it twice.
|
|
3962
4007
|
const paidProducts = new Map();
|
|
3963
4008
|
for (const line of (_order_lineItems1 = order.lineItems) != null ? _order_lineItems1 : []){
|
|
3964
|
-
var
|
|
4009
|
+
var _ref76, _ref77, _line_variantId1;
|
|
3965
4010
|
var _lineProduct_variants_;
|
|
3966
|
-
const lineProductId = String((
|
|
3967
|
-
const soldQty = Math.round(Number((
|
|
4011
|
+
const lineProductId = String((_ref76 = line == null ? void 0 : line.productId) != null ? _ref76 : '');
|
|
4012
|
+
const soldQty = Math.round(Number((_ref77 = line == null ? void 0 : line.quantity) != null ? _ref77 : 0));
|
|
3968
4013
|
if (!lineProductId || !(soldQty > 0)) continue;
|
|
3969
4014
|
// Firestore reserves `__…__` ids and `.doc()` throws
|
|
3970
4015
|
// synchronously on one; a corrupt line must not fail the
|
|
@@ -4024,11 +4069,11 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
4024
4069
|
}
|
|
4025
4070
|
// Commerce Starter orders (AGL-90): recorded under the selling host.
|
|
4026
4071
|
if (type === 'checkout.session.completed' && (object == null ? void 0 : (_object_metadata4 = object.metadata) == null ? void 0 : _object_metadata4.type) === 'commerce-order' && (object == null ? void 0 : object.payment_status) === 'paid') {
|
|
4027
|
-
var
|
|
4028
|
-
const { hostId, productId, feeCents, couponCode } = (
|
|
4072
|
+
var _object_metadata32;
|
|
4073
|
+
const { hostId, productId, feeCents, couponCode } = (_object_metadata32 = object.metadata) != null ? _object_metadata32 : {};
|
|
4029
4074
|
if (hostId && productId) {
|
|
4030
|
-
var
|
|
4031
|
-
var
|
|
4075
|
+
var _ref78, _productForSnapshot_get2, _productForSnapshot_data1, _ref79, _ref80, _object_shipping_details_address_postal_code1, _object_shipping_details_address_country1, _ref81, _ref82, _ref83, _ref84, _ref85;
|
|
4076
|
+
var _object_metadata33, _buyNowLineItems_, _object_shipping_details1, _object_customer_details18, _object_customer_details19, _object_customer_details20, _object_metadata34;
|
|
4032
4077
|
const firestore = firebaseAdmin.app().firestore();
|
|
4033
4078
|
const hostRef = firestore.collection('hosts').doc(String(hostId));
|
|
4034
4079
|
// Orders v1 (AGL-283): line-item snapshot + totals + timeline with
|
|
@@ -4038,7 +4083,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
4038
4083
|
// is bounded to Stripe's at-least-once edge).
|
|
4039
4084
|
const orderRef = hostRef.collection('orders').doc(String(object.id));
|
|
4040
4085
|
const counterRef = hostRef.collection('counters').doc('orders');
|
|
4041
|
-
const amountCents = Number((
|
|
4086
|
+
const amountCents = Number((_ref78 = object == null ? void 0 : object.amount_total) != null ? _ref78 : 0);
|
|
4042
4087
|
const productForSnapshot = await hostRef.collection('products').doc(String(productId)).get();
|
|
4043
4088
|
const snapshotName = String((_productForSnapshot_get2 = productForSnapshot.get('name')) != null ? _productForSnapshot_get2 : 'Product');
|
|
4044
4089
|
// AGL-1711: the line item and totals used to be fabricated from
|
|
@@ -4050,8 +4095,8 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
4050
4095
|
const liftedForSnapshot = CommerceModel.liftLegacyProduct((_productForSnapshot_data1 = productForSnapshot.data()) != null ? _productForSnapshot_data1 : {
|
|
4051
4096
|
name: snapshotName
|
|
4052
4097
|
});
|
|
4053
|
-
const soldVariant = ((
|
|
4054
|
-
const variantOptions = Object.values((
|
|
4098
|
+
const soldVariant = ((_object_metadata33 = object.metadata) == null ? void 0 : _object_metadata33.variantId) ? liftedForSnapshot.variants.find((item)=>item.id === String(object.metadata.variantId)) : liftedForSnapshot.variants[0];
|
|
4099
|
+
const variantOptions = Object.values((_ref79 = soldVariant == null ? void 0 : soldVariant.options) != null ? _ref79 : {});
|
|
4055
4100
|
const { lineItems: buyNowLineItems, totals: buyNowTotals } = CommerceModel.computeBuyNowOrder(object, _extends({
|
|
4056
4101
|
name: snapshotName
|
|
4057
4102
|
}, variantOptions.length ? {
|
|
@@ -4063,7 +4108,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
4063
4108
|
} : {}, liftedForSnapshot.supplierId ? {
|
|
4064
4109
|
supplierId: liftedForSnapshot.supplierId
|
|
4065
4110
|
} : {}));
|
|
4066
|
-
const soldQuantity = (
|
|
4111
|
+
const soldQuantity = (_ref80 = (_buyNowLineItems_ = buyNowLineItems[0]) == null ? void 0 : _buyNowLineItems_.quantity) != null ? _ref80 : 1;
|
|
4067
4112
|
// The number the merchant knows this order by, for the notices below
|
|
4068
4113
|
// (AGL-3432).
|
|
4069
4114
|
let buyNowOrderNumber;
|
|
@@ -4164,7 +4209,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
4164
4209
|
// In-app order notification (wave v6): host managers see sales
|
|
4165
4210
|
// in the bell, not just the owner's email: what came in, from whom
|
|
4166
4211
|
// and where (AGL-3432).
|
|
4167
|
-
const buyNowTotal = `$${(Number((
|
|
4212
|
+
const buyNowTotal = `$${(Number((_ref81 = object == null ? void 0 : object.amount_total) != null ? _ref81 : 0) / 100).toFixed(2)}`;
|
|
4168
4213
|
void notifyHostManagers(String(hostId), {
|
|
4169
4214
|
type: 'content.order',
|
|
4170
4215
|
title: `New order on {site} — ${buyNowTotal}`,
|
|
@@ -4313,15 +4358,15 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
4313
4358
|
hostId: String(hostId),
|
|
4314
4359
|
identity: {
|
|
4315
4360
|
email: object == null ? void 0 : (_object_customer_details19 = object.customer_details) == null ? void 0 : _object_customer_details19.email,
|
|
4316
|
-
name: (
|
|
4361
|
+
name: (_ref82 = object == null ? void 0 : (_object_customer_details20 = object.customer_details) == null ? void 0 : _object_customer_details20.name) != null ? _ref82 : null
|
|
4317
4362
|
},
|
|
4318
4363
|
surface: 'relationship',
|
|
4319
4364
|
lifecycleFloor: 'customer',
|
|
4320
|
-
purchaseCents: Number((
|
|
4365
|
+
purchaseCents: Number((_ref83 = object == null ? void 0 : object.amount_total) != null ? _ref83 : 0),
|
|
4321
4366
|
interaction: {
|
|
4322
4367
|
source: 'order',
|
|
4323
4368
|
refId: String(object.id),
|
|
4324
|
-
summary: `Placed an order ($${(Number((
|
|
4369
|
+
summary: `Placed an order ($${(Number((_ref84 = object == null ? void 0 : object.amount_total) != null ? _ref84 : 0) / 100).toFixed(2)})`
|
|
4325
4370
|
}
|
|
4326
4371
|
});
|
|
4327
4372
|
const productRef = hostRef.collection('products').doc(String(productId));
|
|
@@ -4339,12 +4384,12 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
4339
4384
|
// serialize; the snapshot above is still read, for the product NAME on
|
|
4340
4385
|
// the receipt below, and no longer decides any count.
|
|
4341
4386
|
{
|
|
4342
|
-
var _productSnapshot_data2,
|
|
4343
|
-
var
|
|
4387
|
+
var _productSnapshot_data2, _ref86;
|
|
4388
|
+
var _object_metadata35, _lifted_variants_1;
|
|
4344
4389
|
const lifted = CommerceModel.liftLegacyProduct((_productSnapshot_data2 = productSnapshot.data()) != null ? _productSnapshot_data2 : {
|
|
4345
4390
|
name: 'Product'
|
|
4346
4391
|
});
|
|
4347
|
-
const soldVariantId = String((
|
|
4392
|
+
const soldVariantId = String((_ref86 = (_object_metadata35 = object.metadata) == null ? void 0 : _object_metadata35.variantId) != null ? _ref86 : '') || ((_lifted_variants_1 = lifted.variants[0]) == null ? void 0 : _lifted_variants_1.id);
|
|
4348
4393
|
if (soldVariantId) {
|
|
4349
4394
|
// AGL-1711: `-1` regardless of how many units were bought, so a
|
|
4350
4395
|
// 3-unit buy-now sale decremented stock by one and the difference
|
|
@@ -4377,14 +4422,14 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
4377
4422
|
// Settlement, the same way round and for the same reason as the cart
|
|
4378
4423
|
// branch above (AGL-2356): the decrement lands first, then the
|
|
4379
4424
|
// reservation is dropped.
|
|
4380
|
-
await releaseStockHold(hostRef, String((
|
|
4425
|
+
await releaseStockHold(hostRef, String((_ref85 = (_object_metadata34 = object.metadata) == null ? void 0 : _object_metadata34.stockHoldKey) != null ? _ref85 : ''));
|
|
4381
4426
|
if (couponCode) {
|
|
4382
|
-
var
|
|
4383
|
-
var
|
|
4427
|
+
var _ref87;
|
|
4428
|
+
var _object_metadata36;
|
|
4384
4429
|
await settleRedemption({
|
|
4385
4430
|
firestore,
|
|
4386
4431
|
ref: hostRef.collection('coupons').doc(String(couponCode)),
|
|
4387
|
-
holdKey: String((
|
|
4432
|
+
holdKey: String((_ref87 = (_object_metadata36 = object.metadata) == null ? void 0 : _object_metadata36.couponHoldKey) != null ? _ref87 : ''),
|
|
4388
4433
|
orderRef,
|
|
4389
4434
|
label: `coupon ${couponCode}`,
|
|
4390
4435
|
detail: `Coupon ${couponCode} was applied to this order but no longer ` + 'exists, so the redemption is uncounted against its limit.'
|
|
@@ -4399,19 +4444,19 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
4399
4444
|
// Receipt + seller notification (AGL-96): env-gated like every
|
|
4400
4445
|
// other outbound email; failures never fail the webhook.
|
|
4401
4446
|
if (isEmailConfigured()) {
|
|
4402
|
-
var _productSnapshot_get,
|
|
4447
|
+
var _productSnapshot_get, _ref88;
|
|
4403
4448
|
var _object_customer_details21, _org, _this3;
|
|
4404
4449
|
const productName = String((_productSnapshot_get = productSnapshot.get('name')) != null ? _productSnapshot_get : 'your purchase');
|
|
4405
|
-
const amount = (Number((
|
|
4450
|
+
const amount = (Number((_ref88 = object == null ? void 0 : object.amount_total) != null ? _ref88 : 0) / 100).toFixed(2);
|
|
4406
4451
|
const buyerEmail = object == null ? void 0 : (_object_customer_details21 = object.customer_details) == null ? void 0 : _object_customer_details21.email;
|
|
4407
4452
|
const orderTotal = `$${amount}`;
|
|
4408
4453
|
// The store's receipt switch and the status link (AGL-3610).
|
|
4409
4454
|
const receiptExtras = await onlineReceiptExtras(String(hostId), String(object.id));
|
|
4410
4455
|
if (buyerEmail && receiptExtras.enabled) {
|
|
4411
|
-
var
|
|
4456
|
+
var _ref89, _ref90;
|
|
4412
4457
|
// The store's own Receipt footer, as the cart receipt carries it
|
|
4413
4458
|
// (AGL-3432).
|
|
4414
|
-
const receiptFooter = String((
|
|
4459
|
+
const receiptFooter = String((_ref89 = await hostRef.collection('settings').doc('store').get().then((snapshot)=>snapshot.get('receiptFooter')).catch(()=>'')) != null ? _ref89 : '');
|
|
4415
4460
|
// The quantity with the name (AGL-3432), so a three-unit sale
|
|
4416
4461
|
// does not read as one item at the whole total.
|
|
4417
4462
|
const receiptLine = `${soldQuantity}× ${productName}` + // Where to collect it, or when it is coming (AGL-3624).
|
|
@@ -4426,7 +4471,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
4426
4471
|
}, receiptExtras.tokens));
|
|
4427
4472
|
await sendEmail(_extends({
|
|
4428
4473
|
to: String(buyerEmail),
|
|
4429
|
-
subject: (
|
|
4474
|
+
subject: (_ref90 = designed == null ? void 0 : designed.subject) != null ? _ref90 : `Receipt: ${productName}`,
|
|
4430
4475
|
text: (designed == null ? void 0 : designed.text) || fallbackText
|
|
4431
4476
|
}, (designed == null ? void 0 : designed.html) ? {
|
|
4432
4477
|
html: designed.html
|
|
@@ -4460,7 +4505,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
4460
4505
|
// SSO.
|
|
4461
4506
|
const seller = (_this4 = await findUserByUidAcrossPools(sellerUid).catch(()=>null)) == null ? void 0 : _this4.record;
|
|
4462
4507
|
if (seller == null ? void 0 : seller.email) {
|
|
4463
|
-
var _hostSnapshot_get,
|
|
4508
|
+
var _hostSnapshot_get, _ref91;
|
|
4464
4509
|
const siteName = String((_hostSnapshot_get = hostSnapshot.get('displayName')) != null ? _hostSnapshot_get : hostId);
|
|
4465
4510
|
const fallbackText = `You made a sale on ${siteName}!\n\n${productName} — $${amount}` + (buyerEmail ? `\nBuyer: ${buyerEmail}` : '') + `\nOrder reference: ${object.id}`;
|
|
4466
4511
|
// Site-owner-designed template when published (AGL-771).
|
|
@@ -4474,7 +4519,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
4474
4519
|
});
|
|
4475
4520
|
await sendEmail(_extends({
|
|
4476
4521
|
to: seller.email,
|
|
4477
|
-
subject: (
|
|
4522
|
+
subject: (_ref91 = designed == null ? void 0 : designed.subject) != null ? _ref91 : `New order: ${productName}`,
|
|
4478
4523
|
text: (designed == null ? void 0 : designed.text) || fallbackText
|
|
4479
4524
|
}, (designed == null ? void 0 : designed.html) ? {
|
|
4480
4525
|
html: designed.html
|
|
@@ -4504,28 +4549,28 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
4504
4549
|
// the refund is written on the order's timeline. Nothing else is moved: a
|
|
4505
4550
|
// Dashboard refund is staff's act, and they chose its transfer reversal.
|
|
4506
4551
|
if (type === 'charge.refunded') {
|
|
4507
|
-
var
|
|
4552
|
+
var _ref92, _ref93;
|
|
4508
4553
|
var _object_payment_intent, _snapshot_ref_parent_parent;
|
|
4509
|
-
const paymentIntentId = typeof (object == null ? void 0 : object.payment_intent) === 'string' ? object.payment_intent : String((
|
|
4554
|
+
const paymentIntentId = typeof (object == null ? void 0 : object.payment_intent) === 'string' ? object.payment_intent : String((_ref92 = object == null ? void 0 : (_object_payment_intent = object.payment_intent) == null ? void 0 : _object_payment_intent.id) != null ? _ref92 : '');
|
|
4510
4555
|
const lookup = paymentIntentId ? await findOrderForDispute(paymentIntentId) : {
|
|
4511
4556
|
kind: 'not-ours'
|
|
4512
4557
|
};
|
|
4513
4558
|
if (lookup.kind !== 'order') return;
|
|
4514
4559
|
const snapshot = lookup.snapshot;
|
|
4515
|
-
const hostId = String((
|
|
4560
|
+
const hostId = String((_ref93 = (_snapshot_ref_parent_parent = snapshot.ref.parent.parent) == null ? void 0 : _snapshot_ref_parent_parent.id) != null ? _ref93 : '');
|
|
4516
4561
|
const external = await recordExternalRefund(snapshot.ref, object);
|
|
4517
4562
|
if (external && hostId) {
|
|
4518
|
-
var
|
|
4563
|
+
var _ref94, _ref95, _ref96;
|
|
4519
4564
|
var _object_refunds;
|
|
4520
4565
|
// A Stripe Dashboard refund is a refund to every subscriber too
|
|
4521
4566
|
// (AGL-3645): accounting books it and the merchant's webhooks hear it,
|
|
4522
4567
|
// as they do a console refund. Keyed by the charge's refunded total,
|
|
4523
4568
|
// which the record above only ever advances once per amount.
|
|
4524
|
-
const latestRefund = ((
|
|
4569
|
+
const latestRefund = ((_ref94 = object == null ? void 0 : (_object_refunds = object.refunds) == null ? void 0 : _object_refunds.data) != null ? _ref94 : [])[0];
|
|
4525
4570
|
await raiseOrderEvent(ORDER_REFUNDED_EVENT, {
|
|
4526
4571
|
hostId,
|
|
4527
4572
|
orderId: snapshot.id,
|
|
4528
|
-
key: `external-refund:${String((
|
|
4573
|
+
key: `external-refund:${String((_ref95 = object == null ? void 0 : object.id) != null ? _ref95 : paymentIntentId)}:${Number((_ref96 = object == null ? void 0 : object.amount_refunded) != null ? _ref96 : 0)}`,
|
|
4529
4574
|
extra: {
|
|
4530
4575
|
refund: {
|
|
4531
4576
|
id: (latestRefund == null ? void 0 : latestRefund.id) ? String(latestRefund.id) : null,
|
|
@@ -4575,16 +4620,16 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
4575
4620
|
// merchant; both report the site so the seller's fraud ledger can name it.
|
|
4576
4621
|
const risk = paymentRiskEventFrom(type, object);
|
|
4577
4622
|
if (risk && risk.signal.kind !== 'dispute') {
|
|
4578
|
-
var
|
|
4623
|
+
var _ref97, _snapshot_data1, _ref98, _ref99;
|
|
4579
4624
|
var _snapshot_ref_parent_parent1, _order_totals2;
|
|
4580
4625
|
const lookup = risk.paymentIntentId ? await findOrderForDispute(risk.paymentIntentId) : {
|
|
4581
4626
|
kind: 'not-ours'
|
|
4582
4627
|
};
|
|
4583
4628
|
if (lookup.kind !== 'order') return;
|
|
4584
4629
|
const snapshot = lookup.snapshot;
|
|
4585
|
-
const hostId = String((
|
|
4630
|
+
const hostId = String((_ref97 = (_snapshot_ref_parent_parent1 = snapshot.ref.parent.parent) == null ? void 0 : _snapshot_ref_parent_parent1.id) != null ? _ref97 : '');
|
|
4586
4631
|
const order = CommerceModel.liftLegacyOrder((_snapshot_data1 = snapshot.data()) != null ? _snapshot_data1 : {});
|
|
4587
|
-
const orderCents = Number((
|
|
4632
|
+
const orderCents = Number((_ref98 = (_ref99 = (_order_totals2 = order.totals) == null ? void 0 : _order_totals2.totalCents) != null ? _ref99 : order.amountCents) != null ? _ref98 : 0);
|
|
4588
4633
|
await recordPaymentRiskOnRecord({
|
|
4589
4634
|
ref: snapshot.ref,
|
|
4590
4635
|
signal: risk.signal,
|
|
@@ -4647,7 +4692,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
4647
4692
|
// finds). AGL-1554 will add its own `closed` branch for the marketplace
|
|
4648
4693
|
// side; the two coexist because each self-selects by finding its own record.
|
|
4649
4694
|
if (type === 'charge.dispute.created' || type === 'charge.dispute.closed') {
|
|
4650
|
-
var _dispute_payment_intent,
|
|
4695
|
+
var _dispute_payment_intent, _ref100;
|
|
4651
4696
|
var _snapshot_ref_parent_parent2;
|
|
4652
4697
|
const dispute = object != null ? object : {};
|
|
4653
4698
|
const paymentIntentId = String((_dispute_payment_intent = dispute.payment_intent) != null ? _dispute_payment_intent : '');
|
|
@@ -4673,9 +4718,9 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
4673
4718
|
const claimed = lookup.kind === 'order' || lookup.kind === 'unresolved';
|
|
4674
4719
|
const snapshot = lookup.kind === 'order' ? lookup.snapshot : null;
|
|
4675
4720
|
if (snapshot) {
|
|
4676
|
-
var
|
|
4721
|
+
var _ref101;
|
|
4677
4722
|
var _snapshot_ref_parent_parent3;
|
|
4678
|
-
const hostId = String((
|
|
4723
|
+
const hostId = String((_ref101 = (_snapshot_ref_parent_parent3 = snapshot.ref.parent.parent) == null ? void 0 : _snapshot_ref_parent_parent3.id) != null ? _ref101 : '');
|
|
4679
4724
|
if (type === 'charge.dispute.created') {
|
|
4680
4725
|
var _snapshot_data2;
|
|
4681
4726
|
// A chargeback's gift cards are frozen while it is open (AGL-3363).
|
|
@@ -4693,7 +4738,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
4693
4738
|
}, notifyRiskEvent);
|
|
4694
4739
|
const { opened, record } = await recordDisputeOpened(snapshot, dispute);
|
|
4695
4740
|
if (opened && hostId) {
|
|
4696
|
-
var _snapshot_data3, _record_evidenceDueByMs,
|
|
4741
|
+
var _snapshot_data3, _record_evidenceDueByMs, _ref102;
|
|
4697
4742
|
// Time-critical — Stripe's evidence window is days, not weeks — so
|
|
4698
4743
|
// this is awaited rather than fired off with `void`: the handler is
|
|
4699
4744
|
// serverless and work left running past the response is work the
|
|
@@ -4712,16 +4757,16 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
4712
4757
|
},
|
|
4713
4758
|
amount: `$${(record.amountCents / 100).toFixed(2)}`,
|
|
4714
4759
|
evidenceDueByMs: (_record_evidenceDueByMs = record.evidenceDueByMs) != null ? _record_evidenceDueByMs : null,
|
|
4715
|
-
dedupeKey: `sale:${String((
|
|
4760
|
+
dedupeKey: `sale:${String((_ref102 = dispute == null ? void 0 : dispute.id) != null ? _ref102 : snapshot.id)}`,
|
|
4716
4761
|
staffEvidence: record.reason ? `Reason: ${record.reason.replace(/_/g, ' ')}.` : null
|
|
4717
4762
|
});
|
|
4718
4763
|
}
|
|
4719
4764
|
} else {
|
|
4720
|
-
var
|
|
4765
|
+
var _ref103, _snapshot_data4, _ref104;
|
|
4721
4766
|
// Lost: the money went back, so the cards it bought are voided. Won
|
|
4722
4767
|
// (or closed on a warning): the dispute's freeze lifts; a freeze a
|
|
4723
4768
|
// fraud warning or review put on stays for the merchant (AGL-3363).
|
|
4724
|
-
await applyOrderGiftCardRisk(snapshot, String((
|
|
4769
|
+
await applyOrderGiftCardRisk(snapshot, String((_ref103 = dispute == null ? void 0 : dispute.status) != null ? _ref103 : '') === 'lost' ? {
|
|
4725
4770
|
kind: 'void',
|
|
4726
4771
|
reason: 'dispute-lost'
|
|
4727
4772
|
} : {
|
|
@@ -4792,7 +4837,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
4792
4837
|
// transiently-failed reversal gets its retry — and gated inside on
|
|
4793
4838
|
// the order's own `reversedTransferCents` marker, so it runs at most
|
|
4794
4839
|
// once per dispute however many times Stripe delivers.
|
|
4795
|
-
if (String((
|
|
4840
|
+
if (String((_ref104 = dispute == null ? void 0 : dispute.status) != null ? _ref104 : '') === 'lost') {
|
|
4796
4841
|
const pulledBackCents = await reverseSellerShare(snapshot.ref, dispute);
|
|
4797
4842
|
// The merchant-experience half of the AGL-1794 decision, and not an
|
|
4798
4843
|
// optional extra: the reversal takes money out of the connected
|
|
@@ -4822,7 +4867,7 @@ async function findOrderForDispute(paymentIntentId) {
|
|
|
4822
4867
|
return _extends({
|
|
4823
4868
|
claimed
|
|
4824
4869
|
}, snapshot ? {
|
|
4825
|
-
hostId: String((
|
|
4870
|
+
hostId: String((_ref100 = (_snapshot_ref_parent_parent2 = snapshot.ref.parent.parent) == null ? void 0 : _snapshot_ref_parent_parent2.id) != null ? _ref100 : '')
|
|
4826
4871
|
} : {});
|
|
4827
4872
|
}
|
|
4828
4873
|
};
|