Esempio n. 1
0
 /**
  * @param $url
  * @param $data
  * @param int $ttl
  * @param string $caCertPath
  * @return array
  */
 public static function requestPost($url, $data, $ttl = 30, $caCertPath = '')
 {
     set_time_limit(60);
     $output = array();
     $curlSession = curl_init();
     curl_setopt($curlSession, CURLOPT_URL, $url);
     curl_setopt($curlSession, CURLOPT_HEADER, 0);
     curl_setopt($curlSession, CURLOPT_POST, 1);
     curl_setopt($curlSession, CURLOPT_POSTFIELDS, SagepayUtil::arrayToQueryString($data, '&', true));
     curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($curlSession, CURLOPT_TIMEOUT, $ttl);
     curl_setopt($curlSession, CURLOPT_SSL_VERIFYHOST, 2);
     if (!empty($caCertPath)) {
         curl_setopt($curlSession, CURLOPT_SSL_VERIFYPEER, 1);
         curl_setopt($curlSession, CURLOPT_CAINFO, $caCertPath);
     } else {
         curl_setopt($curlSession, CURLOPT_SSL_VERIFYPEER, 0);
     }
     $rawresponse = curl_exec($curlSession);
     if (curl_getinfo($curlSession, CURLINFO_HTTP_CODE) !== 200) {
         $output['Status'] = "FAIL";
         $output['StatusDetails'] = "Server Response: " . curl_getinfo($curlSession, CURLINFO_HTTP_CODE);
         $output['Response'] = $rawresponse;
         return $output;
     }
     if (curl_error($curlSession)) {
         $output['Status'] = "FAIL";
         $output['StatusDetail'] = curl_error($curlSession);
         $output['Response'] = $rawresponse;
         return $output;
     }
     curl_close($curlSession);
     $response = SagepayUtil::queryStringToArray($rawresponse, "\r\n");
     return array_merge($output, $response);
 }
Esempio n. 2
0
/**
 * Exception handler function
 * 
 * @param Exception $ex
 */
function sagepayExceptionHandler(Exception $ex)
{
    SagepayUtil::log("Exception:" . $ex->getMessage() . PHP_EOL . $ex->getTraceAsString());
    if ($ex instanceof SetupException) {
        include_once DEMO_PATH . '/setup-error.php';
    } else {
        include_once DEMO_PATH . '/error.php';
    }
}
Esempio n. 3
0
 /**
  * Get all tokens by customer ID
  *
  * @param array $customerId
  *
  * @return array
  */
 public function getAllTokensByCustomerId($customerId)
 {
     $query = 'SELECT * FROM `' . $this->table . '` WHERE customer_id = ?';
     try {
         return $this->dbHelper->execute($query, array($customerId))->fetchAll(PDO::FETCH_ASSOC);
     } catch (Exception $ex) {
         SagepayUtil::log($ex->getMessage());
         return array();
     }
 }
Esempio n. 4
0
 /**
  *
  */
 public function before_process()
 {
     global $messageStack;
     $sagepay_return_data = SagepayUtil::decodeAndDecrypt($_GET['crypt'], MODULE_PAYMENT_SAGEPAY_ZC_FORM_PASSWORD);
     $this->errorLog(array(array('title' => 'Response Data', 'content' => $sagepay_return_data)));
     $this->sagepayResponse = SagepayUtil::getResponseTokens($sagepay_return_data);
     $status = $this->sagepayResponse['Status'];
     if (in_array($status, array('OK', 'REGISTERED', 'AUTHENTICATED'))) {
         return;
     }
     $error_message = $this->getResponseErrorMessage($this->sagepayResponse['Status']);
     $payment_error_return = 'ERROR ' . sprintf($error_message, $this->sagepayResponse['StatusDetail']);
     $this->errorLog(array(array('title' => 'Response Values', 'content' => implode("\n", $this->sagepayResponse))));
     $messageStack->add_session('checkout_payment', $payment_error_return, 'error');
     zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false));
 }
Esempio n. 5
0
 /**
  * Add surcharge by details
  * @uses SagepayUtil::cardTypes List of cards
  *
  * @param string $paymentType
  * @param float $percentage
  * @param float $fixed
  *
  * @return boolean
  */
 public function addSurchargeDetails($paymentType, $percentage = null, $fixed = null)
 {
     if (!in_array(strtolower($paymentType), SagepayUtil::cardTypes())) {
         return false;
     }
     $surcharge = array('paymentType' => $paymentType);
     if (!empty($percentage)) {
         $surcharge['percentage'] = $percentage;
         $this->_addSurcharge($surcharge);
         return true;
     }
     if (!empty($fixed)) {
         $surcharge['fixed'] = $fixed;
         $this->_addSurcharge($surcharge);
         return true;
     }
     return false;
 }
Esempio n. 6
0
 /**
  * Return data for result query
  *
  * @param boolean $isSuccess
  * @return array
  * @throws SagepayApiException
  */
 private function _resultData($isSuccess = false)
 {
     $formPassword = $this->sagepayConfig->getFormPassword();
     $env = $this->sagepayConfig->getEnv();
     $crypt = filter_input(INPUT_GET, 'crypt');
     $decrypt = SagepayUtil::decryptAes($crypt, $formPassword[$env]);
     $decryptArr = SagepayUtil::queryStringToArray($decrypt);
     if (!$decrypt || empty($decryptArr)) {
         throw new SagepayApiException('Invalid crypt input');
     }
     $helperMessage = new HelperMessage();
     $basket = $this->getBasketFromProducts();
     $items = array();
     // Get products from basket
     if ($basket) {
         foreach ($basket->getItems() as $item) {
             $items[] = array('productUrlImage' => $this->getProductUrlImage($item->getDescription()), 'description' => $item->getDescription(), 'quantity' => $item->getQuantity());
         }
     }
     return array('env' => $env, 'vendorName' => $this->sagepayConfig->getVendorName(), 'integrationType' => $this->integrationType, 'basket' => array('items' => $items), 'decrypt' => $decryptArr, 'currency' => $this->sagepayConfig->getCurrency(), 'isSuccess' => $isSuccess, 'message' => $helperMessage->getMessage($decryptArr['Status']), 'res' => array('vpsTxId' => $decryptArr['VPSTxId'], 'txAuthNo' => isset($decryptArr['TxAuthNo']) ? $decryptArr['TxAuthNo'] : '', 'Surcharge' => isset($decryptArr['Surcharge']) ? $decryptArr['Surcharge'] : '', 'BankAuthCode' => isset($decryptArr['BankAuthCode']) ? $decryptArr['BankAuthCode'] : '', 'DeclineCode' => isset($decryptArr['DeclineCode']) ? $decryptArr['DeclineCode'] : '', 'GiftAid' => isset($decryptArr['GiftAid']) && $decryptArr['GiftAid'] == 1, 'avsCv2' => isset($decryptArr['AVSCV2']) ? $decryptArr['AVSCV2'] : '', 'addressResult' => isset($decryptArr['AddressResult']) ? $decryptArr['AddressResult'] : '', 'postCodeResult' => isset($decryptArr['PostCodeResult']) ? $decryptArr['PostCodeResult'] : '', 'cv2Result' => isset($decryptArr['CV2Result']) ? $decryptArr['CV2Result'] : '', '3DSecureStatus' => isset($decryptArr['3DSecureStatus']) ? $decryptArr['3DSecureStatus'] : '', 'CAVV' => isset($decryptArr['CAVV']) ? $decryptArr['CAVV'] : '', 'cardType' => isset($decryptArr['CardType']) ? $decryptArr['CardType'] : '', 'last4Digits' => isset($decryptArr['Last4Digits']) ? $decryptArr['Last4Digits'] : '', 'expiryDate' => isset($decryptArr['ExpiryDate']) ? $decryptArr['ExpiryDate'] : '', 'addressStatus' => isset($decryptArr['AddressStatus']) ? $decryptArr['AddressStatus'] : '', 'payerStatus' => isset($decryptArr['PayerStatus']) ? $decryptArr['PayerStatus'] : ''));
 }
Esempio n. 7
0
 /**
  * Redirect to location
  *
  * @param string $controller
  * @param string $action
  * @param array $query
  */
 protected function redirect($controller, $action = 'index', $query = array())
 {
     $queryStr = '';
     // Check if query is not empty
     if (count($query) > 0) {
         $queryStr = '?' . SagepayUtil::arrayToQueryString($query, '&', true);
     }
     if ($controller == 'index') {
         $args = array('');
     } else {
         $args = array($controller, $action);
     }
     header('Location: ' . url($args) . $queryStr);
     exit;
 }
Esempio n. 8
0
 /**
  * Action authorise the transaction
  */
 public function actionAuthorise()
 {
     $errorMessage = '';
     // Check if form was submitted
     if (filter_input(INPUT_POST, 'origVtx')) {
         $payment = new ModelPayment();
         $paymentTxOrig = $payment->getByVendorTxCode(filter_input(INPUT_POST, 'origVtx'));
         $data = array('VPSProtocol' => $this->sagepayConfig->getProtocolVersion(), 'TxType' => SAGEPAY_TXN_AUTHORISE, 'Vendor' => $this->sagepayConfig->getVendorName(), 'VendorTxCode' => filter_input(INPUT_POST, 'VendorTxCode'), 'Amount' => filter_input(INPUT_POST, 'Amount'), 'Description' => filter_input(INPUT_POST, 'Description'), 'RelatedVPSTxID' => $paymentTxOrig['vpsTxId'], 'RelatedVendorTxCode' => filter_input(INPUT_POST, 'origVtx'), 'RelatedSecurityKey' => $paymentTxOrig['securityKey'], 'ApplyAVSCV2' => filter_input(INPUT_POST, 'ApplyAvsCv2'));
         $errorMessage = $this->validateAuthoriseAction($paymentTxOrig, $data);
         // Check if authorise was failed
         if (!$errorMessage) {
             $response = SagepayCommon::requestPost($this->sagepayConfig->getSharedUrl('authorise'), $data);
             if ($response['Status'] == SAGEPAY_REMOTE_STATUS_OK) {
                 $paymentTxOrig['CapturedAmount'] = $paymentTxOrig['capturedAmount'] + filter_input(INPUT_POST, 'Amount');
                 $paymentTxOrig['Status'] = SAGEPAY_REMOTE_STATUS_AUTHENTICATED;
                 $payment->update(filter_input(INPUT_POST, 'origVtx'), $paymentTxOrig);
                 $paymentTxOrig = $this->ucFirstFields($paymentTxOrig);
                 $paymentTx = array_merge($paymentTxOrig, $data, $response);
                 $paymentTx['StatusDetail'] = SAGEPAY_TXN_AUTHORISE . ' transaction taken through Order Admin area.';
                 $paymentTx['CapturedAmount'] = filter_input(INPUT_POST, 'Amount');
                 $payment->insert($paymentTx);
             }
             $query = array('requestBody' => SagepayUtil::arrayToQueryString($data), 'resultBody' => SagepayUtil::arrayToQueryString($response), 'status' => $response['Status'], 'command' => SAGEPAY_TXN_AUTHORISE);
             $this->redirect($this->integrationType, 'admin_result', $query);
         }
     } else {
         if (filter_input(INPUT_GET, 'origVtx')) {
             $payment = new ModelPayment();
             $paymentTxOrig = $payment->getByVendorTxCode(filter_input(INPUT_GET, 'origVtx'));
         } else {
             $this->redirect($this->integrationType, 'admin');
         }
     }
     $view = new HelperView('admin/authorise');
     $view->setData(array('env' => $this->sagepayConfig->getEnv(), 'vendorName' => $this->sagepayConfig->getVendorName(), 'integrationType' => $this->integrationType, 'result' => $paymentTxOrig, 'val' => array('ok' => true), 'newVtx' => SagepayCommon::vendorTxCode(time(), SAGEPAY_TXN_AUTHORISE, $this->sagepayConfig->getVendorName()), 'actionUrl' => url(array($this->integrationType, 'authorise')) . '?origVtx=' . filter_input(INPUT_GET, 'origVtx'), 'error' => $errorMessage ? true : false, 'message' => $errorMessage));
     $view->render();
 }
Esempio n. 9
0
function eme_sagepay_notification()
{
    $sagepay_demo = get_option('eme_sagepay_demo');
    if ($sagepay_demo == 1) {
        $sagepay_pwd = get_option('eme_sagepay_test_pwd');
    } else {
        $sagepay_pwd = get_option('eme_sagepay_live_pwd');
    }
    require_once 'payment_gateways/sagepay/eme-sagepay-util.php';
    $decrypt = SagepayUtil::decryptAes($crypt, $sagepay_pwd);
    $decryptArr = SagepayUtil::queryStringToArray($decrypt);
    if ($decrypt && !empty($decryptArr)) {
        if ($decryptArr['Status'] == 'OK') {
            $payment_id = $decryptArr['VendorTxCode'];
            eme_update_payment_payed($payment_id);
        }
    }
}
Esempio n. 10
0
 /**
  * Return urlencoded string based on data
  *
  * @uses SagepayUtil::arrayToQueryString
  * @return string
  */
 public function getQueryData()
 {
     // Replace after implemeting right View content
     return SagepayUtil::arrayToQueryString($this->data);
 }
Esempio n. 11
0
 /**
  * @return array
  */
 protected function buildStandardTransactionDetails()
 {
     global $order, $currencies, $customer_id, $products;
     $sagepayCurrency = $this->getSagepayCurrency();
     $us_state_codes = SagepayUtil::getUsStateCodes();
     $entries = array();
     $entries['VPSProtocol'] = self::SP_PROTOCOL_VERSION;
     $entries['ApplyAVSCV2'] = (int) $this->getAvsSetting();
     $entries['Apply3DSecure'] = (int) $this->get3dSecureSetting();
     $entries['VendorTxCode'] = date('YmdHis') . $customer_id;
     $entries['Amount'] = number_format($order->info['total'] * $currencies->get_value($sagepayCurrency), $currencies->get_decimal_places($sagepayCurrency));
     $entries['Currency'] = $sagepayCurrency;
     $entries['Description'] = "Goods from " . STORE_NAME;
     $entries['CustomerName'] = $order->billing['firstname'] . ' ' . $order->billing['lastname'];
     $entries['CustomerEmail'] = $order->customer['email_address'];
     $VendorEmailAddress = $this->getModuleDefineValue('_VENDOR_EMAIL');
     if ($VendorEmailAddress == '') {
         $VendorEmailAddress = STORE_OWNER_EMAIL_ADDRESS;
     }
     $entries['VendorEMail'] = $VendorEmailAddress;
     $entries['SendEMail'] = $this->getEmailSendSettings();
     $entries['eMailMessage'] = $this->getModuleDefineValue('_EMAILMSG');
     $billingEntries = sagepayCustomer::setBillingEntries($order, $us_state_codes);
     if ($this->getModuleDefineValue('_TEST_STATUS') == 'test') {
         $billingEntries['BillingAddress1'] = '88';
         $billingEntries['BillingPostCode'] = '412';
     }
     $deliveryEntries = sagepayCustomer::setDeliveryEntries($order, $us_state_codes);
     $entries = array_merge($entries, $billingEntries, $deliveryEntries);
     if ($this->getModuleDefineValue('_SHOPCART') == 'true') {
         $entries['Basket'] = sagepayBasket::getCartContents($order);
     }
     return $entries;
 }
Esempio n. 12
0
 /**
  * Action register page for direct payment
  */
 public function actionRegister()
 {
     $api = $this->buildApi();
     $card = HelperCommon::getStore('card');
     $siteFqdn = $this->sagepayConfig->getSiteFqdn();
     // Check cardType
     if ($card['cardType'] == 'PAYPAL') {
         $api->setIntegrationMethod(SAGEPAY_PAYPAL);
         $this->sagepayConfig->setPaypalCallbackUrl(url('direct/paypal-response', $siteFqdn));
     }
     $account = HelperCommon::getStore('account');
     $api->setPaneValues($card + $account);
     $api->setVpsDirectUrl($this->purchaseUrl);
     $response = $api->createRequest();
     $data = $api->getData();
     $data += $response;
     // Insert in database
     $payment = new ModelPayment();
     $payment->insert($data);
     // Redirect
     $vtxQuery = array('vtx' => $data['VendorTxCode']);
     if ($response['Status'] == SAGEPAY_REMOTE_STATUS_PAYPAL_REDIRECT) {
         header('Location: ' . $response['PayPalRedirectURL']);
         exit;
     } else {
         if ($response['Status'] == "3DAUTH") {
             $threeDSecure = array('MD' => $response['MD'], 'ACSURL' => $response['ACSURL'], 'PaReq' => $response['PAReq'], 'TermUrl' => url(array('direct', 'three-d-secure-result'), $siteFqdn) . '?' . SagepayUtil::arrayToQueryString($vtxQuery));
             HelperCommon::setStore('3DAUTH', $threeDSecure);
             $this->redirect('direct', 'three-d-secure', $vtxQuery);
         } else {
             if (in_array($response['Status'], array(SAGEPAY_REMOTE_STATUS_OK, SAGEPAY_REMOTE_STATUS_REGISTERED))) {
                 if ($data['TxType'] == SAGEPAY_REMOTE_STATUS_PAYMENT) {
                     $surcharge = isset($response['Surcharge']) ? floatval($response['Surcharge']) : 0.0;
                     $paymentTx = array('CapturedAmount' => floatval($data['Amount']) + $surcharge, 'Amount' => floatval($data['Amount']) + $surcharge);
                     $payment->update($data['VendorTxCode'], $paymentTx);
                 }
                 $this->redirect('direct', 'success', $vtxQuery);
             }
         }
     }
     $this->redirect('direct', 'failure', $vtxQuery);
 }
Esempio n. 13
0
 /**
  * Encrypt the order details ready to send to SagePay Server.
  *
  * @param SagepayAbstractApi $request   The request instance.
  * @throws SagepayApiException
  *
  * @return array|string  Returns a String for Form integration method or an array for Server / Direct.
  */
 public static function encryptedOrder(SagepayAbstractApi $request)
 {
     $settings = $request->getConfig();
     $basket = $request->getBasket();
     $address = $request->getAddressList();
     $integrationMethod = $request->getIntegrationMethod();
     $paneValues = $request->getPaneValues();
     // Determine the transaction type based on the payment gateway settings.
     $txType = $settings->getTxType();
     $billingAddress = $address[0];
     $deliveryAddress = isset($address[1]) ? $address[1] : null;
     $query = array('VPSProtocol' => $settings->getProtocolVersion(), 'Vendor' => $settings->getVendorName(), 'VendorTxCode' => self::vendorTxCode($basket->getId(), $txType, $settings->getVendorName()), 'Amount' => number_format($basket->getAmount(), 2, '.', ''), 'Currency' => $settings->getCurrency(), 'Description' => $basket->getDescription(), 'CustomerName' => $billingAddress->firstname . ' ' . $billingAddress->lastname, 'CustomerEMail' => $billingAddress->email, 'VendorEMail' => $settings->getVendorEmail(), 'SendEMail' => $settings->getSendEmail(), 'eMailMessage' => $settings->getEmailMessage(), 'BillingSurname' => $billingAddress->lastname, 'BillingFirstnames' => $billingAddress->firstname, 'BillingAddress1' => $billingAddress->address1, 'BillingAddress2' => $billingAddress->address2, 'BillingCity' => $billingAddress->city, 'BillingPostCode' => $billingAddress->getPostCode(), 'BillingCountry' => $billingAddress->country, 'BillingPhone' => $billingAddress->phone, 'ApplyAVSCV2' => $settings->getApplyAvsCv2(), 'Apply3DSecure' => $settings->getApply3dSecure(), 'AllowGiftAid' => $settings->getAllowGiftAid(), 'BillingAgreement' => $settings->getBillingAgreement());
     $query += $request->getData();
     $customer = $request->getCustomer();
     if ($customer instanceof SagepayCustomer) {
         $query += self::_setAuxValue($query, 'CustomerXML', $customer->export());
     }
     $query += self::_setAuxValue($query, 'VendorData', $settings->getVendorData());
     $query += self::_setAuxValue($query, 'ReferrerID', $settings->getPartnerId());
     $query += self::_setAuxValue($query, 'Language', $settings->getLanguage());
     // Add check for state for US addresses only.
     if ($billingAddress->country == 'US') {
         $query['BillingState'] = $billingAddress->state;
     }
     //Override with supplied delivery address if we have one .
     $query += self::_populateDeliveryDetails($billingAddress, $deliveryAddress);
     if (isset($paneValues['cardType']) && empty($paneValues['cardType'])) {
         $integrationMethod = SAGEPAY_TOKEN;
     }
     // Check if we need to encode cart.
     if (!$settings->basketAsXmlDisabled()) {
         $query['BasketXML'] = $basket->exportAsXml();
     } else {
         $query['Basket'] = $basket->exportAsXml(false);
     }
     if (count($settings->getSurcharges()) > 0) {
         $surcharges = new SagepaySurcharge();
         $surcharges->setSurcharges($settings->getSurcharges());
         $query['SurchargeXML'] = $surcharges->export();
     }
     switch ($integrationMethod) {
         case SAGEPAY_FORM:
             // Unset unused values
             unset($query['VPSProtocol']);
             unset($query['Vendor']);
             unset($query['TxType']);
             $env = $settings->getEnv();
             $query['SuccessURL'] = $settings->getFullFormSuccessUrl();
             $query['FailureURL'] = $settings->getFullFormFailureUrl();
             $request->setData($query);
             $queryStr = SagepayUtil::arrayToQueryString($query);
             $formValues = array();
             $formValues['Vendor'] = $settings->getVendorName();
             $formValues['VPSProtocol'] = $settings->getProtocolVersion();
             $formValues['TxType'] = $txType;
             $formValues['Crypt'] = SagepayUtil::encryptAes($queryStr, $settings->getFormEncryptionPassword($env));
             // Encrypt order details using base64 and the secret key from the settings.
             return $formValues;
         case SAGEPAY_SERVER:
             $query['NotificationURL'] = $settings->getFullServerNotificationUrl();
             $query['TxType'] = $txType;
             $query['Profile'] = $settings->getServerProfile();
             $query['StoreToken'] = 1;
             $query += self::_setAuxValue($query, 'AccountType', $settings->getAccountType());
             return $query;
         case SAGEPAY_DIRECT:
             $query = array_merge($query, self::_getCardDetails($paneValues));
             $query['TxType'] = $txType;
             $query['CardHolder'] = $billingAddress->firstname . ' ' . $billingAddress->lastname;
             // Add 3D Secure flag only if the 3d Secure module is enabled for DIRECT.
             $query['Apply3DSecure'] = $settings->getApply3dSecure();
             $query += self::_setAuxValue($query, 'AccountType', $settings->getAccountType());
             return $query;
         case SAGEPAY_PAYPAL:
             $query['TxType'] = $txType;
             $query['CardType'] = 'PAYPAL';
             $query['PayPalCallbackURL'] = $settings->getPaypalCallbackUrl() . '?vtx=' . $query['VendorTxCode'];
             return $query;
         case SAGEPAY_TOKEN:
             $query['TxType'] = $txType;
             $query['Token'] = $paneValues['token'];
             $query['CV2'] = $paneValues['cv2'];
             $query['AllowGiftAid'] = $paneValues['giftAid'] ? 1 : 0;
             $query += self::_setAuxValue($query, 'AccountType', $settings->getAccountType());
             $query['StoreToken'] = 1;
             $query['ApplyAVSCV2'] = 2;
             return $query;
         default:
             throw new SagepayApiException('Invalid integration type');
     }
 }
Esempio n. 14
0
 /**
  * Notify page, used for server ONLY
  */
 public function actionNotify()
 {
     $payment = new ModelPayment();
     $result = $payment->getByVendorTxCode(filter_input(INPUT_POST, 'VendorTxCode'));
     $siteFqdn = $this->sagepayConfig->getSiteFqdn();
     SagepayUtil::log('NOTIFY:' . PHP_EOL . json_encode(filter_input_array(INPUT_POST)));
     $vtxData = filter_input_array(INPUT_POST);
     if (in_array(filter_input(INPUT_POST, 'Status'), array(SAGEPAY_REMOTE_STATUS_OK, SAGEPAY_REMOTE_STATUS_AUTHENTICATED, SAGEPAY_REMOTE_STATUS_REGISTERED))) {
         $surcharge = floatval(filter_input(INPUT_POST, 'Surcharge', FILTER_VALIDATE_FLOAT));
         $vtxData['Amount'] = $result['amount'] + $surcharge;
         if (filter_input(INPUT_POST, 'TxType') == SAGEPAY_REMOTE_STATUS_PAYMENT) {
             $vtxData['CapturedAmount'] = $vtxData['Amount'];
         }
         $data = array("Status" => SAGEPAY_REMOTE_STATUS_OK, "RedirectURL" => $siteFqdn . 'server/success?vtx=' . filter_input(INPUT_POST, 'VendorTxCode'), "StatusDetail" => 'The transaction was successfully processed.');
     } else {
         $data = array("Status" => SAGEPAY_REMOTE_STATUS_OK, "RedirectURL" => $siteFqdn . 'server/failure?vtx=' . filter_input(INPUT_POST, 'VendorTxCode'), "StatusDetail" => filter_input(INPUT_POST, 'StatusDetail'));
     }
     $vtxData['AllowGiftAid'] = filter_input(INPUT_POST, 'GiftAid');
     $payment->update(filter_input(INPUT_POST, 'VendorTxCode'), $vtxData);
     echo SagepayUtil::arrayToQueryString($data, "\n");
 }