0

I have a ticketing order system, where users select a ticket, pay for it, then the item is removed from the orderable items. I have paypal integrated with ipn etc.. ipn inserts a row in the database when the item has been paid for, the next time a user tries to order the item, the item is disabled, therefore they cannot select it.

my issue is this, if 2 people try to order the same item, while the first order is going through ipn, the page stills shows the item are orderable and will be processed by paypal.. however, by the time the 2nd order goes through, ipn from the first order will have inserted the row in to the database, therefore causing a duplicate key conflict.. this is fine. however, I need to think of a way to stop people ordering the item when the item is already been selected and going through paypal process.

?

thanks Craig.

  • Add a boolean flag to the item: 'buyable'. While PayPal is processing, set the flag to false. When PayPal finishes, set it to true. In the frontend, set a check for this flag (maybe disabling the buy button if the flag is false). This would be a quick and cheap approach – SrAxi Nov 16 '17 at 14:40
  • hi, the issue with this solution is that if user abandons cart, item is still set as false .. would need some sort of cron job to control this.. I was thinking is there anyway on the paypal IPN, once it verifies payment and tries to insert the order details in to my database, if it fails on duplicate key, can I force a refund automatically? – Craig Johnstone Nov 17 '17 at 09:22

0 Answers0