* Convert back to dollars
* Save the transaction ID
*/
+
+ if (CRM_Utils_Array::value('is_recur', $params) && $params['contributionRecurID']) {
+ $params['contributionRecurID'] = $reply['billingid'];
+ }
$params['trxn_id'] = $reply['transid'];
+
$params['gross_amount'] = $tc_params['amount'] / 100;
return $params;
}
}
- /* Return TRUE when client is either IP or agent blacklisted, or
- * FALSE otherwise.
- */
function _isBlacklisted() {
- return $this->_isIPBlacklisted() || $this->_IsAgentBlacklisted();
+ if($this->_isIPBlacklisted()) {
+ return TRUE;
+ } else if($this->_IsAgentBlacklisted()) {
+ return TRUE;
+ }
+ return FALSE;
}
function _isAgentBlacklisted() {
$dao = CRM_Core_DAO::executeQuery('SELECT * FROM `trustcommerce_useragent_blacklist`');
while($dao->fetch()) {
if(preg_match('/'.$dao->name.'/', $agent) === 1) {
- error_log(' [client '.$ip.'] [agent '.$agent.'] - Blacklisted by USER_AGENT rule #'.$dao->id);
- return TRUE;
+ error_log(' [client '.$ip.'] [agent '.$agent.'] - Blacklisted by USER_AGENT rule #'.$dao->id);
+ return TRUE;
}
}
return FALSE;
$dao = CRM_Core_DAO::executeQuery('SELECT * FROM `trustcommerce_blacklist`');
while($dao->fetch()) {
if($ip >= $dao->start && $ip <= $dao->end) {
- error_log('[client '.$ip.'] [agent '.$agent.'] Blacklisted by IP rule #'.$dao->id);
- return TRUE;
+ error_log('[client '.long2ip($ip).'] [agent '.$agent.'] Blacklisted by IP rule #'.$dao->id);
+ return TRUE;
}
}
return FALSE;
$fields['cycle'] = '1'.$cycle; /* The billing cycle in years, months, weeks, or days. */
$fields['payments'] = $payments;
+ $fields['authnow'] = 'y';
$fields['action'] = 'store'; /* Change our mode to `store' mode. */
return $fields;
// TODO FIXME be more or less specific?
// declinetype can be: decline, avs, cvv, call, expiredcard, carderror, authexpired, fraud, blacklist, velocity
// See TC documentation for more info
+ switch($reply['declinetype']) {
+ case 'avs':
+ return self::error(9009, "Your transaction was declined for address verification reasons. If your address was correct please contact us at donate@fsf.org before attempting to retry your transaction.");
+ break;
+ }
return self::error(9009, "Your transaction was declined: {$reply['declinetype']}");
break;
case self::AUTH_BADDATA:
/* We are done, pass success */
return TRUE;
}
-
+
+ function changeSubscriptionAmount(&$message = '', $params = array()) {
+ $tc_params['custid'] = $this->_getParam('user_name');
+ $tc_params['password'] = $this->_getParam('password');
+ $tc_params['action'] = 'store';
+
+ $tc_params['billingid'] = CRM_Utils_Array::value('subscriptionId', $params);
+ $tc_params['payments'] = CRM_Utils_Array::value('installments', $params);
+ $tc_params['amount'] = CRM_Utils_Array::value('amount', $params) * 100;
+
+ if($tc_params['payments'] == 1) {
+ $tc_params['payments'] = 0;
+ }
+ $reply = $this->_sendTCRequest($tc_params);
+ $result = $this->_getTCReply($reply);
+
+ /* Test if call failed */
+ if(!$result) {
+ return self::error(9002, 'Could not initiate connection to payment gateway');
+ }
+
+ /* We are done, pass success */
+ return TRUE;
+
+ }
+
public function install() {
return TRUE;
}