3 # TrustCommerce IPN generator
4 # This script generates a TrustCommerece CSV report via a POST request
5 # and then loops though the results and contacts CiviCRM to submit IPN
6 # requests. This script exists because TrustCommerce does not currently
7 # support sending IPNs.
9 # Author: Lisa Marie Maginnis, Sr SysAdmin
10 # Copyright: Free Software Foundation 2014
13 .
$HOME/etc
/ipn.conf.sh
16 curl
-s "$vault_url?custid=$USER&password=$PASS&querytype=transaction&begindate="$
(date '+%m-%d-%Y') > $datafile
18 # Flip date for consitancy (TC changes this)
19 sed 's/\([0-9][0-9]\)-\([0-9][0-9]\)-\([0-9][0-9][0-9][0-9]\)/\3-\1-\2/g' -i $datafile
21 # Loop though today's IPNs (this is an embedded awk script that generates our query string)
22 for link
in `awk -F, '
27 sub(/[[:blank:]].*/,"",date);
33 if($13 == "approved") {
36 } else if($13 == "decline") {
40 checks=sprintf("%s%s%s%s", bid, tid, amount, date);
41 command="printf \"%s\" \"" checks "\" | md5sum";
42 command | getline data;
44 sub(/[[:blank:]].*/,"",data);
45 printf("'$civicrm_url'?reset=1&billingid=%s&amount=%s&trxn_id=%s&date=%s&status=%s&checksum=%s&key=meh&module=contribute\n", bid, amount, tid, date, status, data);
49 # Process IPN URL and log it
50 echo "Running: $link" >> $logfile
51 curl
-s $link >> $logfile