question

benv avatar image
benv asked benv answered

Merchant.getID() returns null in sandbox

In an AsyncTask:

@Override
protected Merchant doInBackground(Context... context) {
    ctx = context[0];
    Account account = CloverAccount.getAccount(ctx);
    AppsConnector ac = new AppsConnector(ctx, account);
    Merchant m;
    try {
        m = ac.getApp().getMerchant();
    } catch (RemoteException | ServiceException | ClientException | BindingException e) {
        m = null;
        e.printStackTrace();
    }
    return m != null ? m : new Merchant();
}
Merchant object is (by inspection in the debugger) not null, and yet getID() returns null when called from a Sandbox app.
Merchant
3 comments
10 |2000

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

Miguel avatar image Miguel commented ·

Is there a reason you're using AppsConnector to try to get merchant info? Have you tried using MerchantConnector? It seems like the AppConnector is mainly for sending messages to your app.

1 Like 1 ·
benv avatar image benv Miguel commented ·

That was it, miguel! Thanks a million.

0 Likes 0 ·
benv avatar image benv commented ·

bump bump bump

0 Likes 0 ·

1 Answer

benv avatar image
benv answered
Per @miguel 's suggestion, the correct thing to do is use a MerchantConnector in this scenario.
10 |2000

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