Viewing 15 replies - 1 through 15 (of 25 total)
  • Plugin Contributor Claudio Sanches

    (@claudiosanches)

    1. this is json I am trying to send
    {“amount”:10,”code”:”new code”,”type”:”percent”}

    Not a valid data… Here a valid example:

    {"coupon": {"amount": 10, "code": "new code", "type": "percent"}}

    It doesn’t return any error but I am checking admin panel and empty result.

    Returns errors, like for example:

    {"errors":[{"code":"woocommerce_api_missing_coupon_data","message":"No coupon data specified to create coupon"}]}

    You can find more details of how create coupons using our API REST in: https://woothemes.github.io/woocommerce-rest-api-docs/?shell#create-a-coupon

    Thread Starter Goharika

    (@goharika)

    As you say Claudio Sanches, I have correct my json. but again empty, And I have got that error
    {“errors”:[{“code”:”woocommerce_api_missing_callback_param”,”message”:”Missing parameter data”}]}
    Are this all json elements required to include for getting result?

    Plugin Contributor Claudio Sanches

    (@claudiosanches)

    {“errors”:[{“code”:”woocommerce_api_missing_callback_param”,”message”:”Missing parameter data”}]}

    Still missing data in your request, please read the API docs.

    Are this all json elements required to include for getting result?

    Not, in the API docs show what parameters are required.

    Thread Starter Goharika

    (@goharika)

    Thanks,
    Error comes because of json structure.
    Now working perfect.

    Thread Starter Goharika

    (@goharika)

    Now everything is working, I can create coupons, orders and products.
    Another question about payments with none credit card.
    Here we can set order status.
    How can I organize payment with api ?
    Your some advise will be great.
    Thanks

    Plugin Contributor Claudio Sanches

    (@claudiosanches)

    You can manipulate the order status and can get paid as you want on your APP, feel free to create integration with any payment gateway that you like and once received payment can add this data on order.

    Thread Starter Goharika

    (@goharika)

    Yes I know that can change status from app.
    Just can’t imagine how payment will work with app.
    I found this https://docs.woothemes.com/document/payment-gateway-api/
    Is this mean I should create plugin to make payment work with app?

    Plugin Contributor Claudio Sanches

    (@claudiosanches)

    Is this mean I should create plugin to make payment work with app?

    Yep, better you create your own solution for it.

    hey man i am facing a one problem, when i create a customer for woocommerce in my android app i get a error missing data parameter.

    my code is here :

    AjaxCallback<JSONObject> cb = new AjaxCallback<JSONObject>() {

    @override
    public void callback(String url, JSONObject html, AjaxStatus status) {
    System.out.println(html);
    }
    };

    String data = “{\n” +
    “\t\”customer\”: {\n” +
    “\t\t\”email\”: \”[email protected]\”\n” +
    “\t}\n” +
    “}”;
    JSONObject jsonObject = null;
    try {
    jsonObject = new JSONObject(data);
    } catch (JSONException e) {
    e.printStackTrace();
    }

    cb.header(“Accept”, “application/json”);
    cb.header(“Content-Type”, “application/json”);

    Map<String, Object> params = new HashMap<String, Object>();
    params.put(AQuery.POST_ENTITY, “”);
    params.put(“data”, jsonObject);

    cb.params(params);

    aQuery.ajax(url, JSONObject.class, cb);

    Thread Starter Goharika

    (@goharika)

    Hi chandan24892,
    I have got that error because of json structure,
    My json structure is like this
    {
    “customer”: {
    “email”: “[email protected]”,
    “last_name”: “Abrahamyan”,
    “password”: “bareV2015”,
    “first_name”: “Gohar”,
    “username”: “goharika”,
    “billing_address”: {
    “last_name”: “Abrahamyan”
    },
    “shipping_address”: {
    “last_name”: “Abrahamyan”
    }
    }
    }

    I don’t know android, but may be you missing some { or ‘ ” ‘ ,
    alert your json to see what are you sending.

    thanks Goharika , i will try and get back to you.

    hi Goharika, i am chnage my json structure as you said but it is not working for me.

    Thread Starter Goharika

    (@goharika)

    Also please check if your json is valid or not
    In my case the problem was connected only with json
    Can validate here https://jsonlint.com/

    yes i already did it on this website.

    you mention in your question, you use this code in your application, so you are a IOS developer ?

Viewing 15 replies - 1 through 15 (of 25 total)
  • The topic ‘Create coupon with WP API’ is closed to new replies.