I want to create orders from admin on behalf of a customer by using REST API. I have created cart and added items by using the below code.
$userData = array("username" => "admin", "password" => "admin123");
$baseUrl = 'http://test.com/';
$ch = curl_init($baseUrl."rest/V1/integration/admin/token");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($userData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Content-Lenght: " . strlen(json_encode($userData))));
$token = curl_exec($ch);
/* Create empty cart for the guest customer */
$ch = curl_init($baseUrl."rest/V1/guest-carts/");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: Bearer " . json_decode($token)));
$result = curl_exec($ch);
$cartId = json_decode($result);
How can I assign customer to this cart,assign address and place the order? Please help me