I've seen that is possible to create a Money Suite Order entity type (https://www.drupal.org/project/moneysuite) via Services.

Actually I've created a custom script that is almost working, but something is missing: the order is created without the correct data passed.

Here's my code:

$order_info = array(
	'uid' => $uid,
        'order_type' => 'cart',
   	'status' => $status,
   	'gateway' => $gateway,
   	'currency' => 'EUR',
	'created' => $order_created_date,
  );
  
  $order_data_query = http_build_query($order_info);
  $request_url = '<em>mysite</em>/<em>endpoint</em>/ms_order/create.json';

  $ch = curl_init($request_url);
  curl_setopt_array($ch, array(
    CURLOPT_USERAGENT => $agent,
    CURLOPT_HTTPHEADER => array('Accept: application/x-www-form-urlencoded',$token,$cookie_session),
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_POST => TRUE,
    CURLOPT_POSTFIELDS => $order_info,
    CURLOPT_HEADER => FALSE,
    CURLOPT_COOKIE =>  $cookie,
    CURLOPT_VERBOSE => TRUE,
    CURLOPT_FOLLOWLOCATION => TRUE,
    CURLOPT_FAILONERROR => TRUE,
  ));
  
  $response = curl_exec($ch);
  curl_close($ch);

What i'm sending are the basic data for the order, user uid, type, status, gateway ecc....

As i said the order is created, but whitout any of this data, this is what I get on the log data

stdClass Object
(
    [success] => 1
    [message] => Order created successfully.
    [order] => MsOrder Object
        (
            [oid] => 1
            [uid] => Array
                (
                    [uid] => 4
                    [order_type] => cart
                    [status] => completed
                    [gateway] => paypal
                    [currency] => EUR
                    [created] => 1585735303
                )

            [order_key] => M1F2N97
            [order_type] => Array
                (
                    [uid] => 4543
                    [order_type] => cart
                    [status] => completed
                    [gateway] => paypal
                    [currency] => EUR
                    [created] => 1585735303
                )

            [status] => checkout
            [gateway] => 
            [amount] => 0
            [total] => 0
            [currency] => EUR
            [title] => 
            [order_number] => 
 ....

The uid data and the order_type contains all the values as a nested array.

Is it something wrong with my code? Or maybe a wrong data reading?

Comments

MarcoPBazz created an issue. See original summary.

marcopbazz’s picture

Assigned: marcopbazz » Unassigned
tyler.frankenstein’s picture

I'd recommend asking the MoneySuite maintainers how to create an order programmatically and attach the "data". Then just create/adjust a custom Service Resource that your client application can use to create an order.