Index: trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphans.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | |
15 | 15 | protected $killfiles = array(); |
16 | 16 | protected $order_ids = array(); |
17 | | - protected $max_per_execute = 5; |
| 17 | + protected $max_per_execute = 3; |
18 | 18 | |
19 | 19 | |
20 | 20 | function execute(){ |
— | — | @@ -48,6 +48,25 @@ |
49 | 49 | |
50 | 50 | $xml = new DomDocument; |
51 | 51 | |
| 52 | + //fields that have generated notices if they're not there. |
| 53 | + $additional_fields = array( |
| 54 | + 'card_num', |
| 55 | + 'comment', |
| 56 | + 'size', |
| 57 | + 'utm_medium', |
| 58 | + 'utm_campaign', |
| 59 | + 'referrer', |
| 60 | + 'mname', |
| 61 | + 'fname2', |
| 62 | + 'lname2', |
| 63 | + 'street2', |
| 64 | + 'city2', |
| 65 | + 'state2', |
| 66 | + 'country2', |
| 67 | + 'zip2', |
| 68 | + ); |
| 69 | + |
| 70 | + |
52 | 71 | foreach ($payments as $key => $payment_data){ |
53 | 72 | $xml->loadXML($payment_data['xml']); |
54 | 73 | $parsed = $adapter->getResponseData($xml); |
— | — | @@ -55,9 +74,13 @@ |
56 | 75 | $payments[$key]['unstaged'] = $adapter->unstage_data($parsed); |
57 | 76 | $payments[$key]['unstaged']['contribution_tracking_id'] = $payments[$key]['contribution_tracking_id']; |
58 | 77 | $payments[$key]['unstaged']['i_order_id'] = $payments[$key]['unstaged']['order_id']; |
59 | | - $payments[$key]['unstaged']['card_num'] = ''; |
60 | | - } |
61 | | - |
| 78 | + foreach ($additional_fields as $val){ |
| 79 | + if (!array_key_exists($val, $payments[$key]['unstaged'])){ |
| 80 | + $payments[$key]['unstaged'][$val] = null; |
| 81 | + } |
| 82 | + } |
| 83 | + } |
| 84 | + |
62 | 85 | // ADDITIONAL: log out what you did here, to... somewhere. |
63 | 86 | // Preferably *before* you rewrite the Order ID file. |
64 | 87 | |
— | — | @@ -70,6 +93,9 @@ |
71 | 94 | unset($this->order_ids[$payments[$key]['unstaged']['order_id']]); |
72 | 95 | } else { |
73 | 96 | $adapter->log( $payment_data['unstaged']['contribution_tracking_id'] . ": ERROR: " . $results['message']); |
| 97 | + if (strpos($results['message'], "GET_ORDERSTATUS reports that the payment is already complete.")){ |
| 98 | + unset($this->order_ids[$payments[$key]['unstaged']['order_id']]); |
| 99 | + } |
74 | 100 | } |
75 | 101 | echo $results['message'] . "\n"; |
76 | 102 | } |
Index: trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphan_adapter.php |
— | — | @@ -1,6 +1,8 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class GlobalCollectOrphanAdapter extends GlobalCollectAdapter { |
| 5 | + |
| 6 | + protected $utm_source; |
5 | 7 | |
6 | 8 | public function unstage_data( $data = array(), $final = true ){ |
7 | 9 | $unstaged = array(); |
— | — | @@ -49,6 +51,11 @@ |
50 | 52 | $this->defineReturnValueMap(); |
51 | 53 | |
52 | 54 | $this->stageData(); |
| 55 | + |
| 56 | + //have to do this here, or else. |
| 57 | + $this->utm_source = $this->getUTMSourceFromDB(); |
| 58 | + $this->raw_data['utm_source'] = $this->utm_source; |
| 59 | + $this->staged_data['utm_source'] = $this->utm_source; |
53 | 60 | } |
54 | 61 | |
55 | 62 | public function addData($dataArray){ |
— | — | @@ -58,6 +65,8 @@ |
59 | 66 | $this->raw_data['i_order_id'] = $order_id; |
60 | 67 | $this->staged_data['order_id'] = $order_id; |
61 | 68 | $this->staged_data['i_order_id'] = $order_id; |
| 69 | + $this->raw_data['utm_source'] = $this->utm_source; |
| 70 | + $this->staged_data['utm_source'] = $this->utm_source; |
62 | 71 | } |
63 | 72 | |
64 | 73 | public function do_transaction($transaction){ |
— | — | @@ -66,8 +75,8 @@ |
67 | 76 | case 'CANCEL_PAYMENT': |
68 | 77 | self::log($this->getData_Raw('contribution_tracking_id') . ": CVV: " . $this->getData_Raw('cvv_result') . ": AVS: " . $this->getData_Raw('avs_result')); |
69 | 78 | //and then go on, unless you're testing, in which case: |
70 | | - //return "NOPE"; |
71 | | - //break; |
| 79 | +// return "NOPE"; |
| 80 | +// break; |
72 | 81 | default: |
73 | 82 | return parent::do_transaction($transaction); |
74 | 83 | break; |
— | — | @@ -89,4 +98,35 @@ |
90 | 99 | closelog(); |
91 | 100 | } |
92 | 101 | |
| 102 | + public function getUTMSourceFromDB(){ |
| 103 | + |
| 104 | + $db = ContributionTrackingProcessor::contributionTrackingConnection(); |
| 105 | + |
| 106 | + if ( !$db ) { |
| 107 | + die("There is something terribly wrong with your Contribution Tracking database. fixit."); |
| 108 | + return null; |
| 109 | + } |
| 110 | + |
| 111 | + $ctid = $this->getData_Raw('contribution_tracking_id'); |
| 112 | + |
| 113 | + // if contrib tracking id is not already set, we need to insert the data, otherwise update |
| 114 | + if ( $ctid ) { |
| 115 | + $res = $db->select( 'contribution_tracking', |
| 116 | + array( |
| 117 | + 'utm_source' |
| 118 | + ), |
| 119 | + array('id' => $ctid) |
| 120 | + ); |
| 121 | + foreach ($res as $thing){ |
| 122 | + $this->log("$ctid: Found UTM Source value $thing->utm_source"); |
| 123 | + return $thing->utm_source; |
| 124 | + } |
| 125 | + } |
| 126 | + |
| 127 | + //if we got here, we can't find anything else... |
| 128 | + $this->log("$ctid: FAILED to find UTM Source value. Using default."); |
| 129 | + return $this->getData_Raw('utm_source'); |
| 130 | + |
| 131 | + } |
| 132 | + |
93 | 133 | } |
\ No newline at end of file |