Bukimedia / PrestaSharp

CSharp .Net client library for the PrestaShop API via web service
GNU General Public License v3.0
154 stars 151 forks source link

exception when add an order #281

Closed amysticool closed 5 years ago

amysticool commented 7 years ago

Hello all,

i'm trying to perform an order with the following code but i have an exception and don't know why. i give the infromation around the exception below may be it can help someone to help me. THAANNKS

` var productFactory = new ProductFactory(BaseUrl, Account, Password); var product = productFactory.GetAll().First();

        var cartFactory = new CartFactory(BaseUrl, Account, Password);

        Currentcart.id_currency = 2; // euro (a configurer par l'user dans une interface de paramétrage)
        Currentcart.id_lang = 2; // Francais (a configurer par l'user dans une interface de paramétrage)
        Currentcart.associations.cart_rows = new List<cart_row>() { new cart_row { id_product = product.id, quantity = 3, id_address_delivery = 1, id_product_attribute = 1 } };
        MessageBox.Show(product.price.ToString());

        Currentcart = cartFactory.Add(Currentcart); // <-- THIS WORKS AS EXPECTED!

`

and

` var order = new order(); order.id_address_delivery = 7; order.id_address_invoice = 7; MessageBox.Show(Currentcart.id.ToString()); order.id_cart = Currentcart.id; order.id_currency = 2; // euro order.id_lang = 2; // english order.id_customer = 5; // zaid order.id_carrier = 3; // pick up at store order.module = "ps_checkpayment"; order.payment = "Chèque"; double price = 25.00; order.total_paid = product.price; order.total_paid_real = 0; order.total_products = product.price; order.total_products_wt = product.price; order.total_discounts_tax_excl = product.price; order.total_discounts_tax_incl = product.price; order.conversion_rate = 1; order.valid = 0; orderFactory.Add(order); // <--- I GET THE AN EXCEPTION HERE, NO IDEA WHERE EXACTLY IT ORIGINATED

        Currentcart = null;`

the debug mode of prestashop give the following error but don't know how to use the following information.

`System.Exception : 'Prestashop failed to serve XML response instead got text: Fatal error: Uncaught exception 'PrestaShopException' with message 'Fatal error' in /opt/bitnami/apps/prestashop/htdocs/classes/Tools.php:964 Stack trace:

0 /opt/bitnami/apps/prestashop/htdocs/classes/PaymentModule.php(236): ToolsCore::displayError()

1 /opt/bitnami/apps/prestashop/htdocs/classes/order/Order.php(1628): PaymentModuleCore->validateOrder('31', '11', '25', 'Ch\xC3\xA8que', NULL, Array, NULL, false, '75be46b4cb3404c...')

2 /opt/bitnami/apps/prestashop/htdocs/classes/webservice/WebserviceRequest.php(1485): OrderCore->addWs()

3 /opt/bitnami/apps/prestashop/htdocs/classes/webservice/WebserviceRequest.php(1299): WebserviceRequestCore->saveEntityFromXml(201)

4 /opt/bitnami/apps/prestashop/htdocs/classes/webservice/WebserviceRequest.php(526): WebserviceRequestCore->executeEntityPost()

5 /opt/bitnami/apps/prestashop/htdocs/webservice/dispatcher.php(87): WebserviceRequestCore->fetch('3QA69NFF4AI8FKI...', 'POST', 'orders', Array, false, '\n<o...')

6 {main}

thrown in /opt/bitnami/apps/prestashop/htdocs/classes/Tools.php on line 964 '`

Thanks

mauriziozito commented 5 years ago

i have the same error

System.Exception HResult=0x80131500 Messaggio=Prestashop failed to serve XML response instead got text: Fatal error: Uncaught PrestaShopException: Errore fatale in /home/luxuryp6/public_html/luxurypetshop.eu/classes/Tools.php:1109 Stack trace:

0 /home/luxuryp6/public_html/luxurypetshop.eu/classes/PaymentModule.php(254): ToolsCore::displayError()

1 /home/luxuryp6/public_html/luxurypetshop.eu/classes/order/Order.php(1687): PaymentModuleCore->validateOrder('32', '11', '54.000000', 'Contrassegno', NULL, Array, NULL, false, 'f0c818714fe02d8...')

2 /home/luxuryp6/public_html/luxurypetshop.eu/classes/webservice/WebserviceRequest.php(1566): OrderCore->addWs()

3 /home/luxuryp6/public_html/luxurypetshop.eu/classes/webservice/WebserviceRequest.php(1370): WebserviceRequestCore->saveEntityFromXml(201)

4 /home/luxuryp6/public_html/luxurypetshop.eu/classes/webservice/WebserviceRequest.php(565): WebserviceRequestCore->executeEntityPost()

5 /home/luxuryp6/public_html/luxurypetshop.eu/webservice/dispatcher.php(87): WebserviceRequestCore->fetch('ZD4VAMTN2UQR99G...', 'POST', 'orders', Array, false, '\n<o...')

6 {main}

thro in /home/luxuryp6/public_html/luxurypetshop.eu/classes/Tools.php on line 1109

Origine=Bukimedia.PrestaSharp Analisi dello stack: in Bukimedia.PrestaSharp.Deserializers.PrestaSharpTextErrorDeserializer.Deserialize[T](IRestResponse response) in C:\Users\mauri\Downloads\PrestaSharp-master\PrestaSharp-master\Deserializers\PrestaSharpTextErrorDeserializer.cs: riga 11 in RestSharp.RestClient.Deserialize[T](IRestRequest request, IRestResponse raw)

mowcixo commented 5 years ago

Hello @mauriziozito, it seems to be an error with your version of PrestaShop, not with PrestaSharp, see the comment below:

Hello, Please, check these links: https://www.prestashop.com/forums/topic/493410-error-on-order-status-change/ PrestaShop/PrestaShop@34ad2f5 Regards.

I recommend you to upgrade your prestashop version if you can.

Originally posted by @mowcixo in https://github.com/Bukimedia/PrestaSharp/issues/163#issuecomment-495984881

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.