Need help with REST API (webservivice) to check woocommerce

How can I write a webservice for verification, including payment methods using the REST Woocommerce API. Is this available in the Woocommerce REST API? I am new to Woocommerce REST API. Any help is appreciated.

+4
source share
2 answers

You can refer to the REST Woocommerce API documentation for the development of the Woocommerce REST API.

For payment gateways, see the URL below:
http://woocommerce.imtqy.com/woocommerce-rest-api-docs/#payment-gateways

For reference. See URL below: WooCommerce API: Creating Order and Validation

Hope this helps.

+1

, . woocommerce checkout webservice, -

 /*** Just Copy & Paste and change your varriables **/

    //do your initial stuff 
    header('Content-type: application/json');
    $json_file=file_get_contents('php://input');
    $jsonvalue= json_decode($json_file,true);

     $user_id = $jsonvalue['user_id']; 
     $product_id = $jsonvalue['product_id']; 
     $quantity = $jsonvalue['quantity'];    

 //start order data 
 $orderData = array(    
     "order" => array(
     'payment_method' => 'paypal',
     'payment_method_title' => 'Paypal',
     'set_paid' => true,
    "billing_address" => array(
                                    "first_name" => "bfname",
                                    "last_name" => "blname",
                                    "company" => "testcompanybilling",
                                    "address_1" => "sec8",
                                    "address_2" => "e32",
                                    "city" => "noida",
                                    "state" => "Noida",
                                    "postcode" => "99999",
                                    "country" => "IN",
                                    "email" => "test@gmail.com",
                                    "phone" => "888899999999"

                            ),
      "shipping_address" => array(
                                    "first_name" => "sfname",
                                    "last_name" => "slname",
                                    "company" =>  "testcompanyshipping",
                                    "address_1" => "shakkarpur",
                                    "address_2" => "laxminigar",
                                    "city" => "New Delhi",
                                    "state" => "Delhi",
                                    "postcode" => "110092",
                                    "country" => "IN",
                                    "email" => "testsh@gmail.com",
                                    "phone" => "11009999"   
                              ),
    "customer_id" => $user_id,
    "line_items" => array( 
        array(
            "product_id" => $product_id, 
            "quantity" => $quantity
        ) 
      )
   )
);

//Create order usind order data
 $data =  $client->orders->create($orderData);
//echo '<pre>';
 //print_r($data);
$result['success']='true';
$result['error']="0";
$result['msg']='Your order has been successfully placed.';  
$result['data']=$data;  

 echo json_encode($result); `

!!!

+1

Source: https://habr.com/ru/post/1675769/


All Articles