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)
-   -   Exception when placing order with custom payment method (https://forum.x-cart.com/showthread.php?t=78155)

hieudm 02-20-2021 02:31 AM

Exception when placing order with custom payment method
 
I'm working on a custom payment method on X-cart 5, when placing order I got this exception in log file:


Code:

[20-Feb-2021 10:05:05] Error (code: 0): Serialization of 'SimpleXMLElement' is not allowed
Server API: apache2handler;
Request method: POST;
URI: /?;
Backtrace:
#0 /public_html/var/run/classes/XLite/Model/Payment/TransactionAbstract.php(952): serialize()
#1 /public_html/var/run/classes/XLite/Model/Payment/TransactionAbstract.php(443): registerTransactionInOrderHistory()
#2 /public_html/var/run/classes/XLite/Controller/Customer/CheckoutAbstract.php(389): handleCheckoutAction()
#3 /public_html/var/run/classes/XLite/Module/CDev/Paypal/Controller/Customer/Checkout.php(297): doPayment()
#4 /public_html/var/run/classes/XLite/Module/XC/NotFinishedOrders/Controller/Customer/Checkout.php(70): doPayment()
#5 /public_html/var/run/classes/XLite/Module/XC/MailChimp/Controller/Customer/Checkout.php(41): doPayment()
#6 /public_html/var/run/classes/XLite/Controller/Customer/CheckoutAbstract.php(325): doPayment()
#7 /public_html/var/run/classes/XLite/Module/CDev/Paypal/Controller/Customer/Checkout.php(411): doActionCheckout()
#8 /public_html/var/run/classes/XLite/Controller/AControllerAbstract.php(1639): doActionCheckout()
#9 /public_html/var/run/classes/XLite/Controller/Customer/CartAbstract.php(54): callAction()
#10 /public_html/var/run/classes/XLite/Module/XC/MailChimp/Controller/Customer/Checkout.php(31): callAction()
#11 /public_html/var/run/classes/XLite/Controller/AControllerAbstract.php(1658): callAction()
#12 /public_html/var/run/classes/XLite/Module/XC/MailChimp/Controller/AController.php(21): run()
#13 /public_html/var/run/classes/XLite/Controller/AControllerAbstract.php(611): run()
#14 /public_html/var/run/classes/XLite/Module/QSL/CloudSearch/Controller/AController.php(48): handleRequest()
#15 /public_html/var/run/classes/XLite/Controller/Customer/ACustomerAbstract.php(413): handleRequest()
#16 /public_html/var/run/classes/XLite/Module/XC/CustomerAttachments/Controller/Customer/ACustomer.php(29): handleRequest()
#17 /public_html/var/run/classes/XLite/Module/QSL/CallForPrice/Controller/Customer/Cart.php(66): handleRequest()
#18 /public_html/var/run/classes/XLite/Controller/Customer/CheckoutAbstract.php(89): handleRequest()
#19 /public_html/var/run/classes/XLiteAbstract.php(624): handleRequest()
#20 /public_html/var/run/classes/XLiteAbstract.php(653): runController()
#21 /public_html/var/run/classes/XLite/Module/XC/MailChimp/XLite.php(21): processRequest()
#22 /public_html/var/run/classes/XLiteAbstract.php(671): processRequest()
#23 /public_html/cart.php(16): runCustomerZone()



This exception happens when transaction is sucess.



Here is the simplified version of the processor:


Code:

<?php

class NabXML extends \XLite\Model\Payment\Base\CreditCard
{
    protected function doInitialPayment()
    {       
        $txnID = time();
        $this->transaction->setStatus($this->transaction::STATUS_SUCCESS);
        $this->setDetail('transId', $txnID, 'Transaction ID');

        return static::COMPLETED;
    }
}



install.yaml file:


Code:

XLite\Model\Payment\Method:
  - service_name: Nab XML
    class: Module\SydneyEcommerce\NabXML\Model\Payment\Processor\NabXML
    type: C
...



I have multiple questions:
- Where can I find a document about developing a custom payment method?
- How can I debug and fix above exception?
- Is there a way for dev like me get full X-Cart code for self-hosting and developing stuffs?

Ed B. 03-11-2021 01:51 AM

Re: Exception when placing order with custom payment method
 
First point: links like https://devs.x-cart.com/webinars_and_video_tutorials/webinar_3_-_21_aug_2014_-_payment_gateway_creation.html and https://devs.x-cart.com/changing_store_logic/creating_a_settings_page_for_a_payment_method.html can help, maybe?


Second: try to dump any relevant variables.




Third: x-cart's source code used to be downloadable...


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

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