1998 Posts in 530 Topics by 433 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, Howard, Sean, Ryan M., biapar, Willr, Ingo, Jedateach, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 201 Views |
-
Orders with failed/pending payments

20 November 2011 at 8:28pm
Hi,
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.
#!/bin/bash
db_username='username'
db_password='paswword'
db_database='`database`'
emailbody="/tmp/order.txt"
OldestTime="2"
NewestTime="1"
TimeType="HOUR" # HOUR, DAY, MONTH, etc
ORDER_EMAIL="you@example.com"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 ;
do
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" >> $emailbodycat $emailbody
# mail -s "Order #${cell[0]} Has ${cell[1]} Payments " -a "From:errors@example.com" $ORDER_EMAIL < $emailbody
doneThe 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?
| 201 Views | ||
|
Page:
1
|
Go to Top |

