question

Bejoy Nair avatar image
Bejoy Nair asked ·

Service Charge and Discount through Clover SDK

How to fetch already created Service charge and Discount using SDK into the application? I want to fetch the Service charge and Discount which is already created by Merchant in the Clover. I have gone through the "ServiceCharge" and "Discount" classes defined in SDK, they are only allowing to create a service charge and discount. Not providing any method to fetch already defined from Clover account.

Discounts
10 |2000 characters needed characters left characters exceeded

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

1 Answer

Mark Mullan avatar image
Mark Mullan answered ·

InventoryConnector.getDiscounts() for pre-existing discounts the Merchant has already created. Sample code below.

I'll get back to you on the Service Charge...

    private class FetchDiscountsAsyncTask extends AsyncTask<Void, Void, List<Discount>> {
    @Override
    protected final List<Discount> doInBackground(Void... params) {
        try {
            return mInventoryConnector.getDiscounts();
        } catch (RemoteException | ClientException | ServiceException | BindingException e) {
            e.printStackTrace();
        }
        return null;
    }

    protected final void onPostExecute(List<Discount> discounts) {
        TextView textView = (TextView) findViewById(R.id.discounts);
        textView.setText(discounts.toString());
    }
6 comments Share
10 |2000 characters needed characters left characters exceeded

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

Confirmed with engineering that the Merchant-created Service Charge is not accessible through the SDK. Your best bet is to access the REST endpoint GET /v3/merchants/{mId}/default_service_charge, which has the desired information.

0 Likes 0 · ·

I am not getting an option in the clover to create the discounts. Could you guide me on this?

0 Likes 0 · ·

Yep, you'll want to...

0 Likes 0 · ·

I've created some sample code and put it into this Pastebin. I would call new createDiscountAsyncTask().execute(); in order to actually execute the code written.

0 Likes 0 · ·

There is an option in Setup of Merchant to create service charge. Is something similar there in Clover to create Discount? You have given me solution for creating the Discount programatically.

0 Likes 0 · ·
Show more comments

Welcome to the
Clover Developer Community