mercredi 22 avril 2015

Create order prestashop api php

i'm trying to create an order using Prestashop rest api but i always have this error : 400 Bad Request. I found a many topics about this problem but still no solution. I need this for my mobile app. this is my php code

$psXML = <<<XML

<prestashop>

<order>
<id/>
<id_address_delivery>11</id_address_delivery>
<id_address_invoice>11</id_address_invoice>
<id_cart>29</id_cart>
<id_currency>1</id_currency>
<id_lang>1</id_lang>
<id_customer>4</id_customer>
<id_carrier>2</id_carrier>
<current_state>11</current_state>
<module>paypal</module>
<invoice_number/>
<invoice_date/>
<delivery_number/>
<delivery_date/>
<valid/>
<date_add/>
<date_upd/>
<shipping_number/>
<id_shop_group>1</id_shop_group>
<id_shop>1</id_shop>
<secure_key>5c42fc9716c397e39275f2f60e243f4d</secure_key>
<payment>PayPal</payment>
<recyclable/>
<gift/>
<gift_message/>
<mobile_theme/>
<total_discounts/>
<total_discounts_tax_incl/>
<total_discounts_tax_excl/>
<total_paid/>
<total_paid_tax_incl/>
<total_paid_tax_excl/>
<total_paid_real/>
<total_products/>
<total_products_wt/>
<total_shipping/>
<total_shipping_tax_incl/>
<total_shipping_tax_excl/>
<carrier_tax_rate/>
<total_wrapping/>
<total_wrapping_tax_incl/>
<total_wrapping_tax_excl/>
<conversion_rate/>
<reference></reference>
<associations>
<order_rows>
<order_rows>
<id/>
<product_id>7</product_id>
<product_attribute_id>34</product_attribute_id>
<product_quantity>1</product_quantity>
<product_name>Robe de soie imprimée - Couleur : Jaune, Taille : S</product_name>
<product_reference>demo_7</product_reference>
<product_ean13/>
<product_upc/>
<product_price>20.501236</product_price>
<unit_price_tax_incl/>
<unit_price_tax_excl/>
</order_rows>
</order_rows>
</associations>
</order>
</prestashop>

XML;



try {
$webService = new PrestaShopWebservice($serverUrl, $serverApiKey, true);
$xml = new SimpleXMLElement($psXML);

$opt = array( 'resource' => 'orders' );
$opt['postXml'] = $xml->asXML();

$xml = $webService->add( $opt );
}
catch (PrestaShopWebserviceException $ex)
{
    echo 'Other error: <br />' . $ex->getMessage();
}

Aucun commentaire:

Enregistrer un commentaire