Skip to content

Commit 5c02910

Browse files
authored
perf(PayPal): use paypalCaptureId in queries (#11565)
1 parent 581936f commit 5c02910

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

server/paymentProviders/paypal/payment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ const processPaypalOrder = async (order, paypalOrderId): Promise<Transaction | u
200200
OrderId: order.id,
201201
type: 'CREDIT',
202202
kind: 'CONTRIBUTION',
203-
data: { capture: { id: captureId } },
203+
data: { paypalCaptureId: captureId },
204204
},
205205
});
206206

server/paymentProviders/paypal/webhook.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { createRefundTransaction, pauseOrderInDb } from '../../lib/payments';
1414
import { validateWebhookEvent } from '../../lib/paypal';
1515
import { recordOrderProcessed } from '../../lib/recurring-contributions';
1616
import { reportErrorToSentry, reportMessageToSentry } from '../../lib/sentry';
17-
import models, { Op } from '../../models';
17+
import models from '../../models';
1818
import { PayoutWebhookRequest, PaypalCapture } from '../../types/paypal';
1919

2020
import { paypalRequestV2 } from './api';
@@ -197,7 +197,7 @@ async function handleCaptureCompleted(req: Request): Promise<void> {
197197
const existingTransaction = await models.Transaction.findOne({
198198
where: {
199199
OrderId: order.id,
200-
data: { capture: { id: capture.id } },
200+
data: { paypalCaptureId: capture.id },
201201
},
202202
});
203203

@@ -249,13 +249,7 @@ async function handleCaptureRefunded(req: Request): Promise<void> {
249249
kind: TransactionKind.CONTRIBUTION,
250250
isRefund: false,
251251
RefundTransactionId: null,
252-
data: {
253-
[Op.or]: [
254-
{ capture: { id: captureDetails.id } },
255-
{ paypalSale: { id: captureDetails.id } },
256-
{ paypalTransaction: { id: captureDetails.id } },
257-
],
258-
},
252+
data: { paypalCaptureId: captureDetails.id },
259253
},
260254
include: [
261255
{

0 commit comments

Comments
 (0)