question

Bejoy Nair avatar image
Bejoy Nair asked Mark Mullan Deactivated commented

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

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 Deactivated answered Mark Mullan Deactivated commented

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
10 |2000

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

Mark Mullan avatar image Mark Mullan commented ·

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 ·
Bejoy Nair avatar image Bejoy Nair commented ·

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

0 Likes 0 ·
Mark Mullan avatar image Mark Mullan commented ·

Yep, you'll want to...

  • Instantiate a Discount locally
  • Set name (required)
  • Set amount (must be < 0) or percentage (must be > 0)
  • Commit to Clover via InventoryConnector.createDiscount()
0 Likes 0 ·
Mark Mullan avatar image Mark Mullan commented ·

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 ·
Bejoy Nair avatar image Bejoy Nair commented ·

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