Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/app-store/paypal/lib/PaymentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class PaypalPaymentService implements IAbstractPaymentService {
},
amount: payment.amount,
currency: payment.currency,
data: Object.assign({}, preference) as unknown as Prisma.InputJsonValue,
data: Object.assign({}, { order: preference }) as unknown as Prisma.InputJsonValue,
fee: 0,
refunded: false,
success: false,
Expand Down
33 changes: 16 additions & 17 deletions packages/app-store/paypal/lib/Paypal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,24 @@ class Paypal {
},
};

try {
const response = await this.fetcher("/v2/checkout/orders", {
method: "POST",
headers: {
"PayPal-Request-Id": uuidv4(),
},
body: JSON.stringify(createOrderRequestBody),
});
const response = await this.fetcher("/v2/checkout/orders", {
method: "POST",
headers: {
"PayPal-Request-Id": uuidv4(),
},
body: JSON.stringify(createOrderRequestBody),
});

if (response.ok) {
const createOrderResponse: CreateOrderResponse = await response.json();
return createOrderResponse;
} else {
console.error(`Request failed with status ${response.status}`);
}
} catch (error) {
console.error(error);
if (!response.ok) {
const errorBody = await response.text();
throw new Error(`PayPal order creation failed: ${response.status} ${errorBody}`);
}

const createOrderResponse: CreateOrderResponse = await response.json();
if (!createOrderResponse.id || !createOrderResponse.links?.length) {
throw new Error("PayPal order response missing id or links");
}
return {} as CreateOrderResponse;
return createOrderResponse;
}

async captureOrder(orderId: string): Promise<boolean> {
Expand Down
Loading