i'm struggling at creating a new order, i pass every single data that the documentation tell us to, but it can't create. Every time i try to send the JSON, the fields i put info they're just empty, and i don't know what can i do to make it work.
thats my code:
``public static void main(String[] args) throws JSONException {
// Setup client
OAuthConfig config = new OAuthConfig("https://theoriginal-linkishere.com.br",
"chave ck",
"chave cs"); // on original code this infos are correctly set
WooCommerce wooCommerce;
wooCommerce = new WooCommerceAPI(config, ApiVersionType.V3);
//Dizendo os campos e dando os valores
Map <String, Object> orderInfo = new HashMap<>();
orderInfo.put("payment_method", "bacs");
orderInfo.put("payment_method_title", "Direct Bank Transfer");
orderInfo.put("first_name", "Joe");
orderInfo.put("last_name", "Doe");
orderInfo.put("address_1", "969 Market");
orderInfo.put("address_2", "");
orderInfo.put("city", "San Francisco");
orderInfo.put("state", "CA");
orderInfo.put("postcode", "94103");
orderInfo.put("country", "US");
orderInfo.put("email", "[email protected]");
orderInfo.put("phone", "(555) 555-5555");
orderInfo.put("first_name", "Joe");
orderInfo.put("last_name", "Doe");
orderInfo.put("address_1", "969 Market");
orderInfo.put( "address_2", "");
orderInfo.put("city", "San Francisco");
orderInfo.put("state", "CA");
orderInfo.put("postcode", "94103");
orderInfo.put("country", "US");
//mapeando os pedidos
Map order = wooCommerce.create(EndpointBaseType.ORDERS.getValue(),orderInfo);
System.out.println(order.get("id"));
Map <String,String> params = new HashMap<>();
params.put("per_page", "100");
params.put("offset", "0");
List products = wooCommerce.getAll(EndpointBaseType.ORDERS.getValue(), params);
System.out.println(products.size());
}``
and it's returning this:
{ "id": 3104, "parent_id": 0, "status": "pending", "currency": "BRL", "version": "5.9.0", "prices_include_tax": false, "date_created": "2021-12-27T14:12:53", "date_modified": "2021-12-27T14:12:53", "discount_total": "0.00", "discount_tax": "0.00", "shipping_total": "0.00", "shipping_tax": "0.00", "cart_tax": "0.00", "total": "0.00", "total_tax": "0.00", "customer_id": 0, "order_key": "wc_order_ufiuvHMWQacPl", "billing": { "first_name": "", "last_name": "", "company": "", "address_1": "", "address_2": "", "city": "", "state": "", "postcode": "", "country": "", "email": "", "phone": "" }, "shipping": { "first_name": "", "last_name": "", "company": "", "address_1": "", "address_2": "", "city": "", "state": "", "postcode": "", "country": "", "phone": "" }, "payment_method": "bacs", "payment_method_title": "Direct Bank Transfer", "transaction_id": "", "customer_ip_address": "", "customer_user_agent": "", "created_via": "rest-api", "customer_note": "", "date_completed": null, "date_paid": null, "cart_hash": "", "number": "3104", "meta_data": [], "line_items": [], "tax_lines": [], "shipping_lines": [], "fee_lines": [], "coupon_lines": [], "refunds": [], "date_created_gmt": "2021-12-27T14:12:53", "date_modified_gmt": "2021-12-27T14:12:53", "date_completed_gmt": null, "date_paid_gmt": null, "currency_symbol": "R$", "_links": { "self": [ { "href": "https://catalogo.rfldesigner.com.br/wp-json/wc/v3/orders/3104" } ], "collection": [ { "href": "https://catalogo.rfldesigner.com.br/wp-json/wc/v3/orders" } ] } }
That's the issue. If you know any exemple of what could i do to make it work using Java, please let me know.