Skip to content

Commit

Permalink
Fix: update PayPal order status check from 'APPROVED' to 'COMPLETED' …
Browse files Browse the repository at this point in the history
…and capture order on approval
  • Loading branch information
aelassas committed Feb 23, 2025
1 parent 8f6911e commit 35bd3bd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/src/controllers/paypalController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const checkPayPalOrder = async (req: Request, res: Response) => {
// 2. Update Booking if the payment succeeded
// (Set BookingStatus to Paid and remove expireAt TTL index)
//
if (order.status === 'APPROVED') {
if (order.status === 'COMPLETED') {
booking.expireAt = undefined
booking.status = movininTypes.BookingStatus.Paid
await booking.save()
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/pages/Checkout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -634,9 +634,10 @@ const Checkout = () => {
const orderId = await PayPalService.createOrder(bookingId!, price, PaymentService.getCurrency(), name, description)
return orderId
}}
onApprove={async (data) => {
onApprove={async (data, actions) => {
try {
setPayPalProcessing(true)
await actions.order?.capture()
const { orderID } = data
const status = await PayPalService.checkOrder(bookingId!, orderID)

Expand Down

0 comments on commit 35bd3bd

Please sign in to comment.