Class AmountBoxControl
java.lang.Object
com.samsung.android.sdk.samsungpay.v2.payment.sheet.SheetControl
com.samsung.android.sdk.samsungpay.v2.payment.sheet.AmountBoxControl
- All Implemented Interfaces:
android.os.Parcelable
This class provides AmountBoxControl on custom payment sheet.
AmountBoxControl is used for displaying amount information on custom payment sheet.
AmountBoxControl is used for displaying amount information on custom payment sheet.
- Since:
- API Level 1.3
-
Nested Class Summary
Nested classes/interfaces inherited from class com.samsung.android.sdk.samsungpay.v2.payment.sheet.SheetControl
SheetControl.Controltype
-
Field Summary
Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
-
Constructor Summary
ConstructorDescriptionAmountBoxControl
(String controlId, String currencyCode) Constructor to create AmountBoxControl. -
Method Summary
Modifier and TypeMethodDescriptionvoid
API to add item in specific location.void
API to add item.boolean
API to check the item is existing or not.API to return the currency code.
ISO 4217 currency code (example: USD, KRW, EUR, and so on).double
API to get value for ID.void
removeItem
(String id) API to remove item.void
setAmountTotal
(double price, String displayOption) API to set the amount total.void
setCurrencyCode
(String currencyCode) API to set the currency code.void
updateTitle
(String id, String title) API to update item title.void
updateValue
(String id, double price) API to update price.
currencyCode + price will appear on custom payment sheet.
If price is set, then extraPrice is initialized empty value, because extraPrice appear if extraPrice is not empty.void
updateValue
(String id, double price, String extraPrice) API to update price and extraPrice.Methods inherited from class com.samsung.android.sdk.samsungpay.v2.payment.sheet.SheetControl
getControlId, getControltype
-
Constructor Details
-
AmountBoxControl
Constructor to create AmountBoxControl.
// Construct AmountControlBox. AmountBoxControl amountBoxControl = new AmountBoxControl("id_amount", "USD"); // set each item. amountBoxControl.addItem("id_item", "Item", 1000, ""); amountBoxControl.addItem("id_tax", "Tax", 10, ""); amountBoxControl.addItem("id_shipping", "Shipping", 20, ""); amount.setAmountTotal(1030, AmountConstants.FORMAT_TOTAL_PRICE_ONLY); // Update sheetControl sheet.updateControl(amountBoxControl); // Call updateSheet() API method with AmountBoxControl. This is mandatory. paymentManager.updateSheet(sheet);
- Parameters:
controlId
- Unique ID to represent the AmountBoxControl. This ID is used to compare and identify the other SheetControls.currencyCode
- Currency code to be used by Payment Gateway for payment.
ISO 4217 currency code (example: USD, KRW, EUR, and so on / All uppercase).- Throws:
IllegalArgumentException
- Thrown if controlId is null or empty.NullPointerException
- Thrown if currencyCode is null.IllegalArgumentException
- Thrown if currencyCode is invalid.- Since:
- API Level 1.3
-
-
Method Details
-
getValue
API to get value for ID.- Parameters:
id
- Unique ID to get value.- Returns:
- double value
- Throws:
NullPointerException
- Thrown if the ID is null.IllegalArgumentException
- Thrown if the ID is invalid.- Since:
- API Level 1.3
-
existItem
API to check the item is existing or not.- Parameters:
id
- Unique ID to be checked.- Returns:
- true or false
- Throws:
NullPointerException
- Thrown if ID is null.- Since:
- API Level 1.3
-
addItem
API to add item.- Parameters:
id
- Unique ID to be set.title
- Title to be displayed.price
- Price to be set.extraPrice
- If extraPrice is set, extraPrice is displayed instead of price on custom payment sheet.- Throws:
NullPointerException
- Thrown if ID or title is null.IllegalArgumentException
- Thrown if the same ID is used in other SheetControl.- Since:
- API Level 1.3
-
addItem
public void addItem(int location, String id, String title, double price, @Nullable String extraPrice) API to add item in specific location.AmountBoxControl amountBoxControl = (AmountBoxControl) sheet.getSheetControl("amount"); amountBoxControl.updateValue("item", 1000); amountBoxControl.updateValue("tax", 10); amountBoxControl.updateValue("shipping", 20); if (!amountBoxControl.existItem("fuel")) { amountBoxControl.addItem(3, "fuel", "FUEL", 0, "Amount pending"); } else { amountBoxControl.updateValue("fuel", 0, "Amount pending"); } amountBoxControl.setAmountTotal(1030.00, AmountConstants.FORMAT_TOTAL_PRICE_ONLY); // Update sheetControl sheet.updateControl(amountBoxControl); // Call updateSheet() API method with AmountBoxControl. This is mandatory. paymentManager.updateSheet(sheet);
- Parameters:
location
- Location to be displayed in AmountBoxControl on custom payment sheet.id
- Unique ID to be set.title
- Title to be displayed.price
- Price to be set.extraPrice
- If extraPrice is set, extraPrice is displayed instead of price on custom payment sheet.- Throws:
NullPointerException
- Thrown if ID or title is null.IllegalArgumentException
- Thrown if location is invalid or the same ID is used in other SheetControls.- Since:
- API Level 1.3
-
setAmountTotal
API to set the amount total.AmountBoxControl amount = new AmountBoxControl("amount", "USD"); amount.addItem("item", "Item", 1000, null); amount.addItem("tax", "Tax", 10, null); amount.addItem("shipping", "Shipping", 20, null); amount.setAmountTotal(1030.00, AmountConstants.FORMAT_TOTAL_PRICE_ONLY);
- Parameters:
price
- Price to be set.
This amount is for online payment transaction.displayOption
- Amount total display option. Merchant must set one of the predefined formats to display total.
The possible values are:
AmountConstants.FORMAT_TOTAL_PRICE_ONLY
AmountConstants.FORMAT_TOTAL_ESTIMATED_AMOUNT
AmountConstants.FORMAT_TOTAL_ESTIMATED_CHARGE
AmountConstants.FORMAT_TOTAL_ESTIMATED_FARE
AmountConstants.FORMAT_TOTAL_FREE_TEXT_ONLY
AmountConstants.FORMAT_TOTAL_AMOUNT_PENDING
AmountConstants.FORMAT_TOTAL_AMOUNT_PENDING_TEXT_ONLY
AmountConstants.FORMAT_TOTAL_PENDING
AmountConstants.FORMAT_TOTAL_PENDING_TEXT_ONLY
AmountConstants.FORMAT_TOTAL_UP_TO_AMOUNT
- Throws:
IllegalArgumentException
- Thrown if displayOption is null or empty.- Since:
- API Level 1.3
-
removeItem
API to remove item.amountBoxControl.updateValue("id_tax", 30); if (amountBoxControl.existItem("id_fuel")) { amountBoxControl.removeItem("id_fuel"); } amountBoxControl.updateValue("id_total", 1040);
- Parameters:
id
- ID of item to remove.- Throws:
NullPointerException
- Thrown if the ID is null.IllegalArgumentException
- Thrown if the ID is invalid.- Since:
- API Level 1.3
-
updateValue
API to update price.
currencyCode + price will appear on custom payment sheet.
If price is set, then extraPrice is initialized empty value, because extraPrice appear if extraPrice is not empty.- Parameters:
id
- Unique ID of item to update.price
- Price to be set.- Throws:
NullPointerException
- Thrown if the ID is null.IllegalArgumentException
- Thrown if there are no items associated with the ID.- Since:
- API Level 1.3
-
updateValue
API to update price and extraPrice. If extraPrice(String) is set, then extraPrice will appear instead of price.- Parameters:
id
- Unique ID of item to update.price
- Price to be set.extraPrice
- ExtraPrice to be set.- Throws:
NullPointerException
- Thrown if the ID is null.IllegalArgumentException
- Thrown if there are no items associated with the ID.- Since:
- API Level 1.3
-
updateTitle
API to update item title.- Parameters:
id
- Unique ID of item to update.title
- Title to be set.- Throws:
NullPointerException
- Thrown if the ID is null.IllegalArgumentException
- Thrown if there are no items associated with the ID.- Since:
- API Level 1.3
-
getCurrencyCode
API to return the currency code.
ISO 4217 currency code (example: USD, KRW, EUR, and so on).- Returns:
- Currency code.
- Since:
- API Level 1.3
-
setCurrencyCode
API to set the currency code.- Parameters:
currencyCode
- Currency code to be used by Payment Gateway for payment.
ISO 4217 currency code (example: USD, KRW, EUR, and so on / All uppercase).- Throws:
IllegalArgumentException
- If the currency code is invalid.NullPointerException
- If the currency code is null.- Since:
- API Level 1.3
-
Samsung Electronics.
Samsung Pay SDK 2.19.00 - Jun 12 2024