Skip to content

Commit f022974

Browse files
authored
Merge pull request #851 from paypal/fix/fix-bad-request-storybook
fix the bad request issue
2 parents a0ad530 + 0d2121a commit f022974

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

packages/react-paypal-js-storybook/v6/src/shared/code.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ import { PayPalProvider, PayPalSavePaymentButton } from "@paypal/react-paypal-js
8484
async function createVaultToken() {
8585
const response = await fetch("/api/paypal/create-vault-token", {
8686
method: "POST",
87+
headers: { "Content-Type": "application/json" },
8788
});
8889
const data = await response.json();
8990
return { vaultSetupToken: data.id };
@@ -118,6 +119,7 @@ import {
118119
async function createOrder() {
119120
const response = await fetch("/api/paypal/create-order", {
120121
method: "POST",
122+
headers: { "Content-Type": "application/json" },
121123
});
122124
const data = await response.json();
123125
return { orderId: data.id };
@@ -163,6 +165,7 @@ import { PayPalProvider, PayPalGuestPaymentButton } from "@paypal/react-paypal-j
163165
async function createOrder() {
164166
const response = await fetch("/api/paypal/create-order", {
165167
method: "POST",
168+
headers: { "Content-Type": "application/json" },
166169
});
167170
const data = await response.json();
168171
return { orderId: data.id };

packages/react-paypal-js-storybook/v6/src/shared/utils.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ export const PAYPAL_CLIENT_ID =
2929
export async function createOrder(): Promise<{ orderId: string }> {
3030
const response = await fetch(
3131
`${SAMPLE_INTEGRATION_API}/paypal-api/checkout/orders/create-order-for-one-time-payment`,
32-
{ method: "POST" },
32+
{
33+
method: "POST",
34+
headers: { "Content-Type": "application/json" },
35+
},
3336
);
3437
const data = await response.json();
3538
return { orderId: data.id };
@@ -40,7 +43,10 @@ export async function captureOrder(
4043
): Promise<Record<string, unknown>> {
4144
const response = await fetch(
4245
`${SAMPLE_INTEGRATION_API}/paypal-api/checkout/orders/${orderId}/capture`,
43-
{ method: "POST" },
46+
{
47+
method: "POST",
48+
headers: { "Content-Type": "application/json" },
49+
},
4450
);
4551
return response.json();
4652
}
@@ -50,7 +56,10 @@ export async function captureOrder(
5056
export async function createVaultToken(): Promise<{ vaultSetupToken: string }> {
5157
const response = await fetch(
5258
`${SAMPLE_INTEGRATION_API}/paypal-api/vault/create-setup-token-for-paypal-save-payment`,
53-
{ method: "POST" },
59+
{
60+
method: "POST",
61+
headers: { "Content-Type": "application/json" },
62+
},
5463
);
5564
const data = await response.json();
5665
return { vaultSetupToken: data.id };

0 commit comments

Comments
 (0)