*/
/**
- Note that in order to use FirstData / LinkPoint you need a certificate (.pem) file issued by them
- and a store number. You can configure the path to the certificate and the store number
- through the front end of civiCRM. The path is as seen by the server not the url
- -----------------------------------------------------------------------------------------------
- The basic functionality of this processor is that variables from the $params object are transformed
- into xml using a function provided by the processor. The xml is submitted to the processor's https site
- using curl and the response is translated back into an array using the processor's function.
-
- If an array ($params) is returned to the calling function it is treated as a success and the values from
- the array are merged into the calling functions array.
-
- If an result of class error is returned it is treated as a failure
-
- -----------------------------------------------------------------------------------------------
- **/
-
-/*From Payment processor documentation
-For testing purposes, you can use any of the card numbers listed below. The test card numbers
-will not result in any charges to the card. Use these card numbers with any expiration date in the
-future.
- Visa Level 2 - 4275330012345675 (replies with a referral message)
- JCB - 3566007770003510
- Discover - 6011000993010978
- MasterCard - 5424180279791765
- Visa - 4005550000000019 or 4111111111111111
- MasterCard Level 2 - 5404980000008386
- Diners - 36555565010005
- Amex - 372700997251009
-*
-***************************
-*Lines starting with CRM_Core_Error::debug_log_message output messages to files/upload/civicrm.log - you may with to comment them out once it is working satisfactorily
-
-*For live testing uncomment the result field below and set the value to the response you wish to get from the payment processor
-***************************/
+ * Note that in order to use FirstData / LinkPoint you need a certificate (.pem) file issued by them
+ * and a store number. You can configure the path to the certificate and the store number
+ * through the front end of civiCRM. The path is as seen by the server not the url
+ * -----------------------------------------------------------------------------------------------
+ * The basic functionality of this processor is that variables from the $params object are transformed
+ * into xml using a function provided by the processor. The xml is submitted to the processor's https site
+ * using curl and the response is translated back into an array using the processor's function.
+ *
+ * If an array ($params) is returned to the calling function it is treated as a success and the values from
+ * the array are merged into the calling functions array.
+ *
+ * If an result of class error is returned it is treated as a failure
+ *
+ * -----------------------------------------------------------------------------------------------
+ */
+
+/**
+ * From Payment processor documentation
+ * For testing purposes, you can use any of the card numbers listed below. The test card numbers
+ * will not result in any charges to the card. Use these card numbers with any expiration date in the
+ * future.
+ * Visa Level 2 - 4275330012345675 (replies with a referral message)
+ * JCB - 3566007770003510
+ * Discover - 6011000993010978
+ * MasterCard - 5424180279791765
+ * Visa - 4005550000000019 or 4111111111111111
+ * MasterCard Level 2 - 5404980000008386
+ * Diners - 36555565010005
+ * Amex - 372700997251009
+ *
+ * **************************
+ * Lines starting with CRM_Core_Error::debug_log_message output messages to files/upload/civicrm.log - you may with to comment them out once it is working satisfactorily
+ *
+ * For live testing uncomment the result field below and set the value to the response you wish to get from the payment processor
+ * **************************
+ */
class CRM_Core_Payment_FirstData extends CRM_Core_Payment {
# (not used, implicit in the API, might need to convert?)
const CHARSET = 'UFT-8';
* pattern and cache the instance in this variable
*
* @var object
- * @static
*/
static private $_singleton = NULL;
- /**********************************************************
+ /**
* Constructor
*
- * @param string $mode the mode of operation: live or test
+ * @param string $mode
+ * The mode of operation: live or test.
*
* @param $paymentProcessor
*
}
/**
- * Singleton function used to manage this object
- *
- * @param string $mode the mode of operation: live or test
- *
- * @param object $paymentProcessor
- *
- * @return object
- * @static
- */
- public static function &singleton($mode, &$paymentProcessor) {
- if (!empty($paymentProcessor['id'])) {
- $cacheKey = $paymentProcessor['id'];
- }
- else {
- //@todo eliminated instances of this in favour of id-specific instances.
- $cacheKey = $mode . '_' . $paymentProcessor['name'];
- }
- if (self::$_singleton[$cacheKey] === NULL) {
- self::$_singleton[$cacheKey] = new CRM_Core_Payment_FirstData($mode, $paymentProcessor);
- }
- return self::$_singleton[$cacheKey];
- }
-
- /**********************************************************
* This function is set up and put here to make the mapping of fields
* from the params object as visually clear as possible for easy editing
*
* Comment out irrelevant fields
- **********************************************************/
+ */
public function mapProcessorFieldstoParams($params) {
/*concatenate full customer name first - code from EWAY gateway
*/
return $requestFields;
}
- /**********************************************************
+ /**
* This function sends request and receives response from
* the processor
- **********************************************************/
+ */
public function doDirectPayment(&$params) {
if ($params['is_recur'] == TRUE) {
CRM_Core_Error::fatal(ts('%1 - recurring payments not implemented', array(1 => $paymentProcessor)));
$port = "1129";
$host = $this->_paymentProcessor['url_site'] . ":" . $port . "/LSGSXML";
-
//----------------------------------------------------------------------------------------------------
// Check to see if we have a duplicate before we send
//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------
$requestxml = lphp::buildXML($requestFields);
-
-
/*----------------------------------------------------------------------------------------------------
// Send to the payment information using cURL
/----------------------------------------------------------------------------------------------------
*/
-
$ch = curl_init($host);
if (!$ch) {
return self::errorExit(9004, 'Could not initiate connection to payment gateway');
}
-
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestxml);
curl_setopt($ch, CURLOPT_SSLCERT, $key);
$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/docs/sslcerts.html");
}
/**
* 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
*/
public function _checkDupe($invoiceId) {
$contribution = new CRM_Contribute_DAO_Contribution();
return $contribution->find();
}
- /**************************************************
+ /**
* Produces error message and returns from class
- **************************************************/
+ */
public function &errorExit($errorCode = NULL, $errorMessage = NULL) {
$e = CRM_Core_Error::singleton();
return $e;
}
- /**************************************************
+ /**
* NOTE: 'doTransferCheckout' not implemented
- **************************************************/
+ */
public function doTransferCheckout(&$params, $component) {
CRM_Core_Error::fatal(ts('This function is not implemented'));
}
- /********************************************************************************************
+ /**
* This public function checks to see if we have the right processor config values set
*
* NOTE: Called by Events and Contribute to check config params are set prior to trying
*
* returns string $errorMsg if any errors found - null if OK
*
- ******************************************************************************************
+ * function checkConfig( $mode ) CiviCRM V1.9 Declaration
+ * CiviCRM V2.0 Declaration
*/
- // function checkConfig( $mode ) // CiviCRM V1.9 Declaration
- // CiviCRM V2.0 Declaration
public function checkConfig() {
$errorMsg = array();