Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Correct way to modify a Payment .php file in XC5

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 06-26-2015, 12:42 PM
  RichieRich's Avatar 
RichieRich RichieRich is offline
 

X-Adept
  
Join Date: Sep 2004
Location: London, England
Posts: 750
 

Default 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.
__________________
Richard


Ultimate 5.4 testing
Reply With Quote
  #2  
Old 06-29-2015, 06:28 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default 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.
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
  #3  
Old 06-29-2015, 06:44 AM
  RichieRich's Avatar 
RichieRich RichieRich is offline
 

X-Adept
  
Join Date: Sep 2004
Location: London, England
Posts: 750
 

Default 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.
__________________
Richard


Ultimate 5.4 testing
Reply With Quote
  #4  
Old 07-06-2015, 05:21 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default 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
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
  #5  
Old 07-06-2015, 06:04 AM
  RichieRich's Avatar 
RichieRich RichieRich is offline
 

X-Adept
  
Join Date: Sep 2004
Location: London, England
Posts: 750
 

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

Which file should this go in? In a new module Main.php ?
__________________
Richard


Ultimate 5.4 testing
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 06:07 PM.

   

 
X-Cart forums © 2001-2020