Skip to content

Commit b612ead

Browse files
authored
fix: support empty post body for order creation (#183)
1 parent 5cae016 commit b612ead

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

server/node/src/routes/ordersRouteHandler.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ describe("createOrderForPayPalOneTimePaymentRouteHandler", () => {
236236
"/paypal-api/checkout/orders/create-order-for-paypal-one-time-payment-with-redirect",
237237
)
238238
.set("Referer", "https://url-from-referer-header.com/")
239-
.send({});
239+
.send();
240240

241241
expect(response.status).toBe(201);
242242
expect(response.body).toEqual(

server/node/src/routes/ordersRouteHandler.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export async function createOrderForOneTimePaymentRouteHandler(
8989
response: Response,
9090
) {
9191
const { currencyCode, totalAmount, items } = OneTimePaymentSchema.parse(
92-
request.body,
92+
request.body ?? {},
9393
);
9494

9595
const orderRequestBody = {
@@ -137,7 +137,7 @@ export async function createOrderForPayPalOneTimePaymentRouteHandler(
137137
request.get("referer") ??
138138
"https://www.example.com/cancel",
139139
};
140-
}).parse(request.body);
140+
}).parse(request.body ?? {});
141141

142142
const orderRequestBody = {
143143
intent: CheckoutPaymentIntent.Capture,
@@ -194,7 +194,7 @@ export async function createOrderForPayPalOneTimePaymentWithVaultRouteHandler(
194194
request.get("referer") ??
195195
"https://www.example.com/cancel",
196196
};
197-
}).parse(request.body);
197+
}).parse(request.body ?? {});
198198

199199
const orderRequestBody = {
200200
intent: CheckoutPaymentIntent.Capture,
@@ -245,7 +245,7 @@ export async function createOrderForOneTimePaymentWithShippingRouteHandler(
245245
response: Response,
246246
) {
247247
const { currencyCode, totalAmount, items } = OneTimePaymentSchema.parse(
248-
request.body,
248+
request.body ?? {},
249249
);
250250

251251
const orderRequestBody = {
@@ -374,7 +374,7 @@ export async function createOrderForCardWithThreeDSecureRouteHandler(
374374
request.get("referer") ??
375375
"https://www.example.com/cancel",
376376
};
377-
}).parse(request.body);
377+
}).parse(request.body ?? {});
378378

379379
const orderRequestBody = {
380380
intent: CheckoutPaymentIntent.Capture,

0 commit comments

Comments
 (0)