From 2ff316432c114cb080419446e1283b47fcf16de1 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 4 Feb 2015 16:27:34 -0500 Subject: [PATCH] Implement changeSubscriptionAmount method. --- trustcommerce.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/trustcommerce.php b/trustcommerce.php index 9426cf1..560cae3 100644 --- a/trustcommerce.php +++ b/trustcommerce.php @@ -435,7 +435,32 @@ class org_fsf_payment_trustcommerce extends CRM_Core_Payment { /* 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; } -- 2.25.1