<?php
/*
+----------------------------------------------------------------------------+
- | PayflowPro Core Payment Module for CiviCRM version 4.5 |
+ | PayflowPro Core Payment Module for CiviCRM version 4.6 |
+----------------------------------------------------------------------------+
| Licensed to CiviCRM under the Academic Free License version 3.0 |
| |
*/
class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment {
// (not used, implicit in the API, might need to convert?)
- CONST
- CHARSET = 'UFT-8';
+ const
+ CHARSET = 'UFT-8';
/**
* We only need one instance of this object. So we use the singleton
/*
* Constructor
*
- * @param string $mode the mode of operation: live or test
+ * @param string $mode
+ * The mode of operation: live or test.
*
* @return void
*/
* @param $mode
* @param $paymentProcessor
*/
- function __construct($mode, &$paymentProcessor) {
+ public function __construct($mode, &$paymentProcessor) {
// live or test
$this->_mode = $mode;
$this->_paymentProcessor = $paymentProcessor;
$this->_processorName = ts('Payflow Pro');
}
- /**
- * Singleton function used to manage this object
- *
- * @param string $mode the mode of operation: live or test
- *
- * @param object $paymentProcessor
- *
- * @return object
- * @static
- */
- static function &singleton($mode, &$paymentProcessor) {
- $processorName = $paymentProcessor['name'];
- if (self::$_singleton[$processorName] === NULL) {
- self::$_singleton[$processorName] = new CRM_Core_Payment_PayflowPro($mode, $paymentProcessor);
- }
- return self::$_singleton[$processorName];
- }
-
/*
* This function sends request and receives response from
* the processor. It is the main function for processing on-server
* This function collects all the information from a web/api form and invokes
* the relevant payment processor specific functions to perform the transaction
*
- * @param array $params assoc array of input parameters for this transaction
+ * @param array $params
+ * Assoc array of input parameters for this transaction.
*
- * @return array the result in an nice formatted array (or an error object)
+ * @return array
+ * the result in an nice formatted array (or an error object)
* @abstract
*/
- function doDirectPayment(&$params) {
+ public function doDirectPayment(&$params) {
if (!defined('CURLOPT_SSLCERT')) {
CRM_Core_Error::fatal(ts('PayFlowPro requires curl with SSL support'));
}
case '2 weeks':
$params['next_sched_contribution_date'] = mktime(0, 0, 0, date("m"), date("d") + 14, date("Y"));
- $params['end_date'] = mktime(0, 0, 0, date("m"), date("d") + (14 * $payflow_query_array['TERM'])
- , date("Y ")
+ $params['end_date'] = mktime(0, 0, 0, date("m"), date("d") + (14 * $payflow_query_array['TERM']), date("Y ")
);
$payflow_query_array['START'] = date('mdY', $params['next_sched_contribution_date']);
$payflow_query_array['PAYPERIOD'] = "BIWK";
case '4 weeks':
$params['next_sched_contribution_date'] = mktime(0, 0, 0, date("m"), date("d") + 28, date("Y")
);
- $params['end_date'] = mktime(0, 0, 0, date("m"), date("d") + (28 * $payflow_query_array['TERM'])
- , date("Y")
+ $params['end_date'] = mktime(0, 0, 0, date("m"), date("d") + (28 * $payflow_query_array['TERM']), date("Y")
);
$payflow_query_array['START'] = date('mdY', $params['next_sched_contribution_date']);
$payflow_query_array['PAYPERIOD'] = "FRWK";
break;
case '3 months':
- $params['next_sched_contribution_date'] = mktime(0, 0, 0, date("m") + 3, date("d")
- , date("Y")
+ $params['next_sched_contribution_date'] = mktime(0, 0, 0, date("m") + 3, date("d"), date("Y")
);
$params['end_date'] = mktime(0, 0, 0, date("m") +
(3 * $payflow_query_array['TERM']),
(6 * $payflow_query_array['TERM']),
date("d"), date("Y")
);
- $payflow_query_array['START'] = date('mdY', $params['next_sched_contribution_date'
- ]
+ $payflow_query_array['START'] = date('mdY', $params['next_sched_contribution_date']
);
$payflow_query_array['PAYPERIOD'] = "SMYR";
$params['frequency_unit'] = "month";
* the cvv check, the avs check. This is stored in
* CiviCRM as part of the transact
* but not further processing is done. Business rules would need to be defined
-
*******************************************************/
$params['trxn_id'] = $nvpArray['PNREF'] . $nvpArray['TRXPNREF'];
//'trxn_id' is varchar(255) field. returned value is length 12
/**
* Checks to see if invoice_id already exists in db
*
- * @param int $invoiceId The ID to check
+ * @param int $invoiceId
+ * The ID to check.
*
- * @return bool True if ID exists, else false
+ * @return bool
+ * True if ID exists, else false
*/
- function _checkDupe($invoiceId) {
+ public function _checkDupe($invoiceId) {
//copied from Eway but not working and not really sure it should!
$contribution = new CRM_Contribute_DAO_Contribution();
$contribution->invoice_id = $invoiceId;
*
* @return object
*/
- function &errorExit($errorCode = NULL, $errorMessage = NULL) {
+ public function &errorExit($errorCode = NULL, $errorMessage = NULL) {
$e = CRM_Core_Error::singleton();
if ($errorCode) {
$e->push($errorCode, 0, NULL, $errorMessage);
*
* @throws Exception
*/
- function doTransferCheckout(&$params, $component) {
+ public function doTransferCheckout(&$params, $component) {
CRM_Core_Error::fatal(ts('This function is not implemented'));
}
* NOTE: Called by Events and Contribute to check config params are set prior to trying
* register any credit card details
*
- * @param string $mode the mode we are operating in (live or test) - not used
+ * @param string $mode
+ * The mode we are operating in (live or test) - not used.
*
* returns string $errorMsg if any errors found - null if OK
- *
*/
// function checkConfig( $mode ) // CiviCRM V1.9 Declaration
- // CiviCRM V2.0 Declaration
/**
+ * CiviCRM V2.0 Declaration
* This function checks to see if we have the right config values
*
* @internal param string $mode the mode we are operating in (live or test)
*
- * @return string the error message if any
- * @public
+ * @return string
+ * the error message if any
*/
- function checkConfig() {
+ public function checkConfig() {
$errorMsg = array();
if (empty($this->_paymentProcessor['user_name'])) {
$errorMsg[] = ' ' . ts('ssl_merchant_id is not set for this payment processor');
*
* @return array|string
*/
- function convert_to_nvp($payflow_query_array) {
+ public function convert_to_nvp($payflow_query_array) {
foreach ($payflow_query_array as $key => $value) {
$payflow_query[] = $key . '[' . strlen($value) . ']=' . $value;
}
* Submit transaction using CuRL
* @submiturl string Url to direct HTTPS GET to
* @payflow_query value string to be posted
- *
*/
/**
* @param $submiturl
*
* @return mixed|object
*/
- function submit_transaction($submiturl, $payflow_query) {
+ public function submit_transaction($submiturl, $payflow_query) {
/*
* Submit transaction using CuRL
*/
$errorDesc = curl_error($ch);
//Paranoia - in the unlikley event that 'curl' errno fails
- if ($errorNum == 0)
- $errorNum = 9005;
+ if ($errorNum == 0) {
+ $errorNum = 9005;
+ }
// Paranoia - in the unlikley event that 'curl' error fails
- if (strlen($errorDesc) == 0)
- $errorDesc = "Connection to payment gateway failed";
+ if (strlen($errorDesc) == 0) {
+ $errorDesc = "Connection to payment gateway failed";
+ }
if ($errorNum = 60) {
return self::errorExit($errorNum, "Curl error - " . $errorDesc .
" Try this link for more information http://curl.haxx.se/d
*
* @throws Exception
*/
- function getRecurringTransactionStatus($recurringProfileID, $processorID) {
+ public function getRecurringTransactionStatus($recurringProfileID, $processorID) {
if (!defined('CURLOPT_SSLCERT')) {
CRM_Core_Error::fatal(ts('PayFlowPro requires curl with SSL support'));
}
//$recurringProfileID = "RT0000000001";
// c $trythis = $this->getRecurringTransactionStatus($recurringProfileID,17);
-
/*
*Create the array of variables to be sent to the processor from the $params array
* passed into this function
//RT0000000001
}
}
-