Jump to:

2088 Posts in 1007 Topics by 455 members

E-Commerce Modules

SilverStripe Forums » E-Commerce Modules » Orders with failed/pending payments

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, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba, simon_w

Page: 1
Go to End
Author Topic: 357 Views
  • rog
    Community Member
    8 Posts

    Orders with failed/pending payments Link to this post


    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 "From:errors@example.com" $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?

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.