(MSC Pilot) Manage service charges for Android apps
Learn how to use the Android APIs to manage multiple service charges (MSC) for Android apps.
This topic describes the Android API endpoints you can use to manage multiple service charges (MSC) for Android apps. The endpoints are organized into two sections for merchant-level and order-level endpoints:
Android APIs to manage service charges | |
---|---|
Merchant-level Android API endpoints | Use to Get all order fees associated with a merchant. |
Order level Android API endpoints | Use to: - Apply a service charge to an order - Remove a service charge from an order - Get order fees associated with an order - Get line items without service charges |
NOTE
For complete REST API reference documentation for the MSC endpoints, see the (MSC Pilot) REST API Index.
Merchant-level Android API endpoints
1. Get service charges associated with a merchant
1.1 Get all service charges associated with a merchant
Use either of the following methods from the InventoryConnector
class to retrieve all service charges from the OrderFee
objects associated with a merchant.
public List<OrderFee> getOrderFees() throws ClientException, ServiceException, BindingException, RemoteException {
return execute(IInventoryService::getOrderFees);
}
public void getOrderFees(Callback<List<OrderFee>> callback) {
execute(IInventoryService::getOrderFees, callback);
}
1.2 Get a specific service charge associated with a merchant
Use either of the following methods from the InventoryConnector
class to retrieve a specific service charge from an OrderFee
object.
public OrderFee getOrderFee(final String orderFeeId) throws ClientException, ServiceException, BindingException, RemoteException {
return execute((service, status) -> {
return service.getOrderFee(orderFeeId, status);
});
}
public void getOrderFee(final String orderFeeId, Callback<OrderFee> callback) {
execute((service, status) -> service.getOrderFee(orderFeeId, status), callback);
}
Order-level Android API endpoints
1. Apply a service charge to an order
Use the addOrderFee
method from the OrderV31Connector
class to apply a service charge to an order.
public Order addOrderFee(final String orderId, final String orderFeeId) throws RemoteException, ClientException, ServiceException, BindingException {
return execute((service, status) -> {
return getValue(service.addOrderFee(orderId, orderFeeId, status));
});
}
2. Remove a service charge from an order
Use the deleteOrderFee
method from the OrderV31Connector
class to remove a service charge from an order.
public Order deleteOrderFee(final String orderId, final String orderFeeLineItemId) throws RemoteException, ClientException, ServiceException, BindingException {
return execute((service, status) -> {
return getValue(service.deleteOrderFee(orderId, orderFeeLineItemId, status));
});
}
3. Get service charges applied to an order
Use the following method to get a list of service charges applied to a current order.
public static List<LineItem> getServiceChargesFromOrder(Order order) {
List<LineItem> serviceCharges = new ArrayList<LineItem>();
if (order.isNotNullLineItems()) {
for (LineItem lineItem : order.getLineItems()) {
if (lineItem.isNotNullIsOrderFee() && lineItem.getIsOrderFee()) {
serviceCharges.add(
lineItem
);
}
}
}
return serviceCharges;
}
4. Get a list of line items without service charges
You can get a list of regular line items without service charges when these line items are associated with an order.
4.1 Get a list of regular line items without service charges associated with an order
Use this method to get a list of regular line items without service charges from an Order
object.
public static List<LineItem> getLineItemsWithoutServiceCharges(Order order) {
return getLineItemsWithoutServiceCharges(order.getLineItems());
}
4.2 Get a list of regular line items without service charges from a list of line items
Use this method to get a list of regular line items without service charges from a LineItem
object.
public static List<LineItem> getLineItemsWithoutServiceCharges(List<LineItem> lineItems) {
List<LineItem> lineItemsWithoutServiceCharges = null;
if (lineItems != null) {
for (LineItem lineItem : lineItems) {
if (!lineItem.getIsOrderFee()) {
lineItemsWithoutServiceCharges.add(lineItem);
}
}
}
return lineItemsWithoutServiceCharges;
}
Updated 5 days ago