Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

E-Commerce Modules /

Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.

Moderators: martimiz, Nicolaas, Sean, Ed, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba

Orders with failed/pending payments

Go to End



Community Member, 8 Posts

20 November 2011 at 8:28pm


I notice that when an order is placed and the payment fails or is left pending because the user closes the browser etc then is no notification that the order was placed. I know that this could easily be done in php but I'm a sysadmin at heart. My solution was to run the following as a cron job on say the 50th minute of every hour or could be as often as you like. This would then let you know that an order as been placed and you could contact the customer to find out why it wasn't completed or what when wrong.

TimeType="HOUR" # HOUR, DAY, MONTH, etc 

dbquery=$(mysql -u$db_username -p$db_password -e "SELECT OrderID, Status, AmountAmount FROM $db_database.Payment WHERE LastEdited > now() - INTERVAL $OldestTime $TimeType and LastEdited < now() - INTERVAL $NewestTime $TimeType ;" | sed '1d' | sed 's/\t/,/g;s/\n//g')
for row in $dbquery ;
	IFS=',' cell=( ${row} )
	echo "OrderID: ${cell[0]}" > $emailbody
	echo "Status: ${cell[1]}" >> $emailbody
	echo "Amount: ${cell[2]}" >> $emailbody
	Order=$(mysql -u$db_username -p$db_password -e "SELECT MemberID FROM $db_database.Order WHERE ID = \"${cell[0]}\";" | tail -n 1)
	echo "$Order" >> $emailbody
	Member=$(mysql -u$db_username -p$db_password -e "SELECT FirstName, Surname, Email FROM $db_database.Member WHERE ID = \"$Order\";"  | tail -n 1 | sed 's/\t/\n/g')
	echo "$Member" >> $emailbody

	cat $emailbody
#	mail -s "Order #${cell[0]} Has ${cell[1]} Payments " -a "" $ORDER_EMAIL < $emailbody

The other thing that I notice that happens is that the stock is removed. Is there a simple way of reversing this? Maybe the stock should only be taken once the payment has been received?