Example #1
0
 /**
  * Get payment data for SERVER and DIRECT
  *
  * @param boolean $statusOk
  *
  * @return array
  */
 protected function getPaymentResultData($statusOk = false)
 {
     $result = array();
     if (filter_input(INPUT_GET, 'vtx')) {
         $payment = new ModelPayment();
         $result = $payment->getByVendorTxCode(filter_input(INPUT_GET, 'vtx'));
     }
     if (empty($result)) {
         $this->helperError('Transaction code is invalid: this can happen if you try to pay for multiple baskets at the same time. ' . 'Please contact [your customer service details] to check the status of your order.', url(array('server')));
     }
     $items = array();
     $basket = $this->getBasketFromProducts();
     if ($basket) {
         foreach ($basket->getItems() as $item) {
             $items[] = array('quantity' => $item->getQuantity(), 'urlImage' => $this->getProductUrlImage($item->getDescription()), 'description' => $item->getDescription());
         }
     }
     $errorMessage = '';
     if (!$statusOk) {
         switch ($result['status']) {
             case 'REJECTED':
                 $errorMessage = 'Your order did not meet our minimum fraud screening requirements.';
                 break;
             case 'ABORT':
                 $errorMessage = 'You chose to Cancel your order on the payment pages.';
                 break;
             default:
                 $errorMessage = 'ERROR.';
         }
     }
     return array('env' => $this->sagepayConfig->getEnv(), 'vendorName' => $this->sagepayConfig->getVendorName(), 'integrationType' => $this->integrationType, 'basket' => array('items' => $items), 'ord' => $result, 'stOk' => $statusOk, 'errorMessage' => $errorMessage);
 }
Example #2
0
    /**
     * Populate data that is read from configurations
     */
    protected function addConfiguredValues()
    {
        $data = array(
            'Vendor' => $this->config->getVendorName(),
            'VPSProtocol' => $this->config->getProtocolVersion(),
            'Currency' => $this->config->getCurrency(),
            'TxType' => $this->config->getTxType(),
            'SendEMail' => $this->config->getSendEmail(),
            'VendorEMail' => $this->config->getVendorEmail(),
            'Apply3DSecure' => $this->config->getApply3dSecure(),
            'ApplyAVSCV2' => $this->config->getApplyAvsCv2(),
        );

        $partnerId = $this->config->getPartnerId();
        if (!empty($partnerId))
        {
            $data['ReferrerID'] = $partnerId;
        }
        if ($data['SendEMail'] == 1)
        {
            $data['eMailMessage'] = $this->config->getEmailMessage();
        }
        $allowGiftAid = $this->config->getAllowGiftAid();
        if (!isset($this->data['AllowGiftAid']))
        {
            $data['AllowGiftAid'] = $allowGiftAid;
        }

        $this->updateData($data);
    }
Example #3
0
 /**
  * Remove token from Sagepay Service
  *
  * @param  string  $token Token GUID provided by Sagepay service on card registration
  *
  * @return boolean
  */
 public function remove($token)
 {
     $data = $this->_prepareRemoveData($token);
     $ttl = $this->_config->getRequestTimeout();
     $caCert = $this->_config->getCaCertPath();
     $response = SagepayCommon::requestPost($this->_removeUrl, $data, $ttl, $caCert);
     return ($response['Status'] == SAGEPAY_REMOTE_STATUS_OK);
 }
 /**
  * Logging the debugging information to "debug.log"
  *
  * @param  string  $message
  * @return boolean
  */
 static public function log($message)
 {
     $settings = SagepaySettings::getInstance();
     if ($settings->getLogError())
     {
         $filename = SAGEPAY_SDK_PATH . '/debug.log';
         $line = '[' . date('Y-m-d H:i:s') . '] :: ' . $message;
         try
         {
             $file = fopen($filename, 'a+');
             fwrite($file, $line . PHP_EOL);
             fclose($file);
         } catch (Exception $ex)
         {
             return false;
         }
     }
     return true;
 }
Example #5
0
<?php

/**
 * Start new or resume existing session
 */
session_start();
define('DEMO_PATH', dirname(__FILE__));
define('BASE_PATH', substr($_SERVER['SCRIPT_NAME'], 0, strlen($_SERVER['SCRIPT_NAME']) - 9));
require_once DEMO_PATH . '/bootstrap.php';
HelperSetup::checkDependencies();
// Is required for initialiize the the SagePay Api
$config = SagepaySettings::getInstance();
new App($config);
Example #6
0
 /**
  * Get instance of settings
  * 
  * @param array $config
  * @param boolean $loadFileConfig
  * @return SagepaySettings
  */
 static public function getInstance(array $config = array(), $loadFileConfig = true) 
 {
     if (self::$_instance === null)
     {
         self::$_instance = new SagepaySettings($config, $loadFileConfig);
     }
     return self::$_instance;
 }