X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Correct way to modify a Payment .php file in XC5 (https://forum.x-cart.com/showthread.php?t=72352)

RichieRich 06-26-2015 12:42 PM

Correct way to modify a Payment .php file in XC5
 
I want to comment out a couple of lines in the SagePayForm.php file in XC5, can you advise the correct method.

Can I just overwrite this file with the commented out lines? Or do I need some other method.

tony_sologubov 06-29-2015 06:28 AM

Re: Correct way to modify a Payment .php file in XC5
 
It is better to use decoration in order to apply such changes:
http://kb.x-cart.com/display/XDD/Step+3+-+applying+logic+changes

because it will allow your changes to live through upgrades.

Richard, could you please let me know what lines exactly you would like to comment out?

Tony

Quote:

Originally Posted by RichieRich
I want to comment out a couple of lines in the SagePayForm.php file in XC5, can you advise the correct method.

Can I just overwrite this file with the commented out lines? Or do I need some other method.


RichieRich 06-29-2015 06:44 AM

Re: Correct way to modify a Payment .php file in XC5
 
Quote:

'CustomerEMail' => $this->getProfile()->getLogin(),
'VendorEMail' => \XLite\Core\Config::getInstance()->Company->orders_department,
'SendEMail' => 1,


I had this commented out also in XC4, the reason for me, is that I do not need to receive Sagepay Success/Failure e-mails, and also the customer does not need this. I prefer just my order confirmation e-mails.

Could you please let me know the completed way to implement this.

tony_sologubov 07-06-2015 05:21 AM

Re: Correct way to modify a Payment .php file in XC5
 
The good way to achieve it is to decorate this class and define the new version of the getCrypt() method as follows there:

PHP Code:

protected function getCrypt()
    {
        
$currency $this->transaction->getCurrency();

        
$shippingAddress $this->getProfile()->getShippingAddress();
        if (
null === $shippingAddress) {
            
$shippingAddress $this->getProfile()->getBillingAddress();
        }

        
$fields = array(
            
'VendorTxCode'      => $this->getTransactionId(),
            
'ReferrerID'        => '653E8C42-AD93-4654-BB91-C645678FA97B',
            
'Amount'            => round($this->transaction->getValue(), 2),
            
'Currency'          => strtoupper($currency->getCode()),
            
'Description'       => 'Your Cart',

            
'SuccessURL'        => $this->getReturnURL(nulltrue),
            
'FailureURL'        => $this->getReturnURL(nulltruetrue),

            
'CustomerName'      => $this->getProfile()->getBillingAddress()->getFirstname()
                . 
' '
                
$this->getProfile()->getBillingAddress()->getLastname(),
            
'BillingSurname'    => $this->getProfile()->getBillingAddress()->getLastname(),
            
'BillingFirstnames' => $this->getProfile()->getBillingAddress()->getFirstname(),
            
'BillingAddress1'   => $this->getProfile()->getBillingAddress()->getStreet(),
            
'BillingCity'       => $this->getProfile()->getBillingAddress()->getCity(),
            
'BillingPostCode'   => $this->getProfile()->getBillingAddress()->getZipcode(),
            
'BillingCountry'    => strtoupper($this->getProfile()->getBillingAddress()->getCountry()->getCode()),

            
'DeliverySurname'    => $shippingAddress->getLastname(),
            
'DeliveryFirstnames' => $shippingAddress->getFirstname(),
            
'DeliveryAddress1'   => $shippingAddress->getStreet(),
            
'DeliveryCity'       => $shippingAddress->getCity(),
            
'DeliveryPostCode'   => $shippingAddress->getZipcode(),
            
'DeliveryCountry'    => strtoupper($shippingAddress->getCountry()->getCode()),

            
'Basket'             => $this->getBasket(),
            
'AllowGiftAid'       => 0,
            
'ApplyAVSCV2'        => 0,
            
'Apply3DSecure'      => 0,
        );

        if (
'US' === $fields['BillingCountry']) {
            
$fields['BillingState'] = $this->getProfile()->getBillingAddress()->getState()->getCode();
        }

        if (
'US' === $fields['DeliveryCountry']) {
            
$fields['DeliveryState'] = $shippingAddress->getState()->getCode();
        }

        
$cryptedFields = array();
        foreach (
$fields as $key => $value) {
            
$cryptedFields[] = $key '=' $value;
        }

        return 
$this->encryptAndEncode(implode('&'$cryptedFields));
    } 


Please, let me know if it helps.

Tony

RichieRich 07-06-2015 06:04 AM

Re: Correct way to modify a Payment .php file in XC5
 
Which file should this go in? In a new module Main.php ?


All times are GMT -8. The time now is 06:48 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.