question

jaimel avatar image
jaimel asked jaimel answered

Permissions needed

try {
    Order order = orderConnector.createOrder(new Order().setManualTransaction(true));

    Object obj = new JSONParser().parse(transdata);
    JSONObject jo = (JSONObject) obj;
    org.json.simple.JSONArray detailitemsres = (org.json.simple.JSONArray) jo.get("items");
    List<LineItem> lineItems = new ArrayList<LineItem>();;
    for (int i = 0; i < detailitemsres.size(); i++) {

        org.json.simple.JSONObject jobjectfromsale = (org.json.simple.JSONObject) detailitemsres.get(i);
        LineItem customLineItem = new LineItem().setName((String)jobjectfromsale.get("name")).setAlternateName("").setPrice((long)jobjectfromsale.get("price"));
        customLineItem = orderConnector.addCustomLineItem(order.getId(), customLineItem, false);
        lineItems.add(customLineItem);
    }
    order.setLineItems(lineItems);
    SaleRequest pendingSale = setupSaleRequestByID(order.getId(), amount);
    paymentConnector.sale(pendingSale);
    //return orderConnector.getOrder(order.getId());
} catch (Exception e) {
    Log.i(e.toString(), "create order failed", e);
}

The above code works in the test sandbox, but is does not work in the production environment, I have requested order read/write as permissions, I create the order as manual so I can add items that are not within the existing items list.

Do I need additional permissions like inventory read/write to be able to add items to a manual order?

Orders
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image
David Marginian Deactivated answered David Marginian Deactivated edited

What is the exception that is being caught? In a production app you should do a bit more than just log when an exception occurs, what you have now is not very robust (you should have an analytics/logging service set-up so that you can have insight into your applications logs). Your app should request the same permissions in production that you have tested in sandbox. Did you originally request orders read/write in production (when your app was created) or did you just add those permissions? If you just added them the request needs to be approved and then you need to uninstall/reinstall your app to have the permissions take affect.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jaimel avatar image
jaimel answered

David, I requested the same permissions, I did not requested anything new, this is all working in the sandbox, since I don't have access to local logs on the terminal, it is very difficult for me to give you any feedback as for the exception.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jaimel avatar image
jaimel answered David Marginian Deactivated edited

is there anyway that you can see the logs on the terminal?, or the rights assigned to the app?

1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image David Marginian ♦♦ commented ·

The app appears to have orders read/write. I would suggest testing your app in sandbox with the exact same data set to ensure it is working correctly as the error could be anything (for example that json parsing you are doing is suspect). In production you need insight into your app (logs, exceptions, etc.) relying on us to dump logs and provide them to you is not a sustainable path.

0 Likes 0 ·
jaimel avatar image
jaimel answered

David, I send the logs as you requested.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community