Toine Seiter
Toine Seiter

Reputation: 447

create an order on Prestashop API : error with module name

I'm trying to create an order through the Prestashop API (v1.6.1.13). I havn't written any module, my goal is just to use its API without installing anything on the prestashop.

Creating an order requires a module name. If I leave it blank I get the error:

Validation error: "Property Order->module is empty"

If I write a fake name it says :

Validation error: "Property Order->module is not valid"

What should I do ? While I have the same issue with the payment field ?

Here is what I'm sending :

<prestashop>
<order>
  <id_address_delivery>1299</id_address_delivery>
  <id_address_invoice>1300</id_address_invoice>
  <id_cart>218</id_cart>
  <id_currency>1</id_currency>
  <id_lang>2</id_lang>
  <id_customer>214</id_customer>
  <id_carrier>2</id_carrier>
  <current_state>2</current_state>
  <module></module>
  <invoice_number>0</invoice_number>
  <delivery_number>0</delivery_number>
  <valid>1</valid>
  <date_add>2017-06-27 23:00:46</date_add>
  <date_upd>2017-06-28 11:50:13</date_upd>
  <id_shop_group>1</id_shop_group>
  <id_shop>1</id_shop
  <payment>MyPayment</payment>
  <recyclable>0</recyclable>
  <gift>0</gift>
  <mobile_theme>0</mobile_theme>
  <total_discounts>0</total_discounts>
  <total_discounts_tax_incl>0</total_discounts_tax_incl>
  <total_discounts_tax_excl>0</total_discounts_tax_excl>
  <total_paid>27</total_paid>
  <total_paid_tax_incl>27</total_paid_tax_incl>
  <total_paid_tax_excl>27</total_paid_tax_excl>
  <total_paid_real>27</total_paid_real>
  <total_products>27</total_products>
  <total_products_wt>27</total_products_wt>
  <total_shipping>0</total_shipping>
  <total_shipping_tax_incl>0</total_shipping_tax_incl>
  <total_shipping_tax_excl>0</total_shipping_tax_excl>
  <carrier_tax_rate>0</carrier_tax_rate>
  <total_wrapping>0</total_wrapping>
  <total_wrapping_tax_incl>0</total_wrapping_tax_incl>
  <total_wrapping_tax_excl>0</total_wrapping_tax_excl>
  <conversion_rate>1</conversion_rate>
  <reference>170627369</reference>
  <associations>
    <order_rows>
      <order_row>
        <product_id>2</product_id>
        <product_attribute_id>7</product_attribute_id>
        <product_quantity>2</product_quantity>
        <product_name>Blouse</product_name>
        <product_reference>demo_2</product_reference>
        <product_ean13>0</product_ean13>
        <product_price>27</product_price>
        <unit_price_tax_incl>27</unit_price_tax_incl>
        <unit_price_tax_excl>27</unit_price_tax_excl>
      </order_row>
    </order_rows>
  </associations>
</order>
</prestashop>

Any help/idea would be greatly appreciate, thanks !

Upvotes: 1

Views: 1693

Answers (2)

Shubham
Shubham

Reputation: 41

You need Enable the payment options(like payment by check) in prestashop admin side and then need to add the module with prefix ps_moduleName without any space. I did like this, $xml->order->module= "ps_".strtolower(str_replace(' ', '', $order_data['payment_method'])); You can try this if there is any error or If you have any better solution then it me know. Thanks.

Upvotes: 0

Toine Seiter
Toine Seiter

Reputation: 447

After some debug steps in the payment module I found the solution. The module should be a valid module name (I use "bankwire") and payment can be wathever you want (the name of the external source for example).

I was testing an address which country was disabled... Enabling the country fix the issue.

What a pity Prestashop doesn't respond the reason on the API call... Even if activating the DEV mode of prestashop and DEBUG of the PaymentModule.

Thanks for your help sarcom !

Upvotes: 2

Related Questions