Class AddressControl
java.lang.Object
com.samsung.android.sdk.samsungpay.v2.payment.sheet.SheetControl
com.samsung.android.sdk.samsungpay.v2.payment.sheet.AddressControl
- All Implemented Interfaces:
android.os.Parcelable
This class provides AddressControl on custom payment sheet.
AddressControl is used for displaying billing address or shipping address
on custom payment sheet from "My Info" menu option on Samsung Pay app.
Caution: AddressControl must be returned in onResult() on SheetUpdatedListener to remove progress bar on custom payment sheet.
AddressControl is used for displaying billing address or shipping address
on custom payment sheet from "My Info" menu option on Samsung Pay app.
Caution: AddressControl must be returned in onResult() on SheetUpdatedListener to remove progress bar 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
ConstructorDescriptionAddressControl
(String controlId, SheetItemType sheetItemType) Constructor to create AddressControl. -
Method Summary
Modifier and TypeMethodDescriptionAPI to get address.API to get address title.API to get address type.int
API to get display option ofSheetItemType.SHIPPING_ADDRESS
on custom payment sheet.int
API to get error code of the AddressControl.void
setAddress
(CustomSheetPaymentInfo.Address address) API to set address.void
setAddressTitle
(String title) API to set address title.void
setDisplayOption
(int displayOption) API to set display option ofSheetItemType.SHIPPING_ADDRESS
on custom payment sheet.void
setErrorCode
(int errorCode) API to set error code of the AddressControl.void
setSheetUpdatedListener
(SheetUpdatedListener sheetUpdatedListener) API to register a callback which is invoked when AddressControl is updated.Methods inherited from class com.samsung.android.sdk.samsungpay.v2.payment.sheet.SheetControl
getControlId, getControltype
-
Constructor Details
-
AddressControl
Constructor to create AddressControl.
// For billing address private AddressControl makeBillingAddressControl() { AddressControl billingAddressControl = new AddressControl(BILLING_ADDRESS_ID, SheetItemType.BILLING_ADDRESS); billingAddressControl.setAddressTitle("Billing Address [control]"); //This callback is received when Controls are updated. billingAddressControl.setSheetUpdatedListener(new SheetUpdatedListener() { @Override public void onResult(String updatedControlId, CustomSheet customSheet) { Log.d(TAG,"onResult billingAddressControl updatedControlId: " + updatedControlId); AddressControl addressControl = (AddressControl)customSheet.getSheetControl(updatedControlId); CustomSheetPaymentInfo.Address billAddress = addressControl.getAddress(); //Validate only zipcode or billing address. And set errorCode if needed. if(addressControl.sheetItem.sheetItemType == SheetItemType.ZIP_ONLY_ADDRESS) int errorCode = validateZipcodeBillingAddress(billAddress.postalCode) Log.d(TAG, "onResult updateSheetBilling errorCode: " + errorCode) addressControl.setErrorCode(errorCode) customSheet.updateControl(addressControl) } else{ int errorCode = validateBillingAddress(billAddress); Log.d(TAG, "onResult updateSheetBilling errorCode: " + errorCode); addressControl.setErrorCode(errorCode); customSheet.updateControl(addressControl); } AmountBoxControl amountBoxControl = (AmountBoxControl) customSheet.getSheetControl(AMOUNT_CONTROL_ID); amountBoxControl.updateValue(PRODUCT_ITEM_ID, 1000); amountBoxControl.updateValue(PRODUCT_TAX_ID, 50); amountBoxControl.updateValue(PRODUCT_SHIPPING_ID, 10); amountBoxControl.updateValue(PRODUCT_FUEL_ID, 0, "Pending"); amountBoxControl.setAmountTotal(1060, AmountConstants.FORMAT_TOTAL_PRICE_ONLY); customSheet.updateControl(amountBoxControl); // Call updateSheet() API method with AmountBoxControl. This is mandatory. paymentManager.updateSheet(customSheet); } }); return billingAddressControl;
// For Shipping address from merchant private AddressControl makeShippingAddressControl() { AddressControl shippingAddressControl = new AddressControl(SHIPPING_ADDRESS_ID, SheetItemType.SHIPPING_ADDRESS); shippingAddressControl.setAddressTitle("Shipping Address [control]"); CustomSheetPaymentInfo.Address shippingAddress = new CustomSheetPaymentInfo.Address.Builder() .setAddressee("name") .setAddressLine1("addLine1") .setAddressLine2("addLine2") .setCity("city") .setState("state") .setCountryCode("USA") .setPostalCode("zip") .setPhoneNumber("123-1234-1234") .build(); shippingAddressControl.setAddress(shippingAddress); int displayOption_val = AddressConstants.DISPLAY_OPTION_ADDRESSEE; // Addressee is mandatory displayOption_val += AddressConstants.DISPLAY_OPTION_ADDRESS; displayOption_val += AddressConstants.DISPLAY_OPTION_PHONE_NUMBER; displayOption_val += AddressConstants.DISPLAY_OPTION_EMAIL; shippingAddressControl.setDisplayOption(displayOption_val); return shippingAddressControl; } }- Parameters:
controlId
- Unique ID to represent the AddressControl. This ID is used to compare and identify the other SheetControls.sheetItemType
- SheetItemType represents billing address or shipping address.
The possible values are:
SheetItemType.BILLING_ADDRESS
SheetItemType.ZIP_ONLY_ADDRESS
SheetItemType.SHIPPING_ADDRESS
It is possible to show only one billing AddressControl and one shipping AddressControl.- Throws:
IllegalArgumentException
- Thrown if controlId is null or empty.IllegalArgumentException
- Thrown if sheetItemType is notSheetItemType.BILLING_ADDRESS
orSheetItemType.ZIP_ONLY_ADDRESS
orSheetItemType.SHIPPING_ADDRESS
.- Since:
- API Level 1.3
-
-
Method Details
-
setSheetUpdatedListener
API to register a callback which is invoked when AddressControl is updated.
SheetUpdatedListener.onResult(String, CustomSheet)
is invoked when AddressControl is updated.- Parameters:
sheetUpdatedListener
- The callback that will run.- Since:
- API Level 1.3
-
getAddress
API to get address.- Returns:
- The address of the AddressControl.
- Since:
- API Level 1.3
-
setAddress
API to set address.- Parameters:
address
- Address to be set.
The possible values are:
SheetItemType.BILLING_ADDRESS
SheetItemType.SHIPPING_ADDRESS
- Since:
- API Level 1.3
- See Also:
-
getAddressType
API to get address type.- Returns:
- SheetItemType of the AddressControl.
The returned value can be one of the following SheetItemTypes:
SheetItemType.BILLING_ADDRESS
SheetItemType.SHIPPING_ADDRESS
- Since:
- API Level 1.3
-
setAddressTitle
API to set address title.- Parameters:
title
- Title of the AddressControl.
If title is empty like "", then default title is displayed.- Throws:
NullPointerException
- Thrown if title is null.- Since:
- API Level 1.3
-
getAddressTitle
API to get address title.- Returns:
- Title of the AddressControl.
- Since:
- API Level 1.3
-
getErrorCode
public int getErrorCode()API to get error code of the AddressControl.- Returns:
- The error code.
The returned value can be one of the following error codes:
PaymentManager.ERROR_BILLING_ADDRESS_INVALID
PaymentManager.ERROR_BILLING_ADDRESS_NOT_EXIST
PaymentManager.ERROR_SHIPPING_ADDRESS_INVALID
PaymentManager.ERROR_SHIPPING_ADDRESS_UNABLE_TO_SHIP
PaymentManager.ERROR_SHIPPING_ADDRESS_NOT_EXIST
- Since:
- API Level 1.3
-
setErrorCode
public void setErrorCode(int errorCode) API to set error code of the AddressControl.- Parameters:
errorCode
-
The possible values are:
PaymentManager.ERROR_BILLING_ADDRESS_INVALID
PaymentManager.ERROR_BILLING_ADDRESS_NOT_EXIST
PaymentManager.ERROR_SHIPPING_ADDRESS_INVALID
PaymentManager.ERROR_SHIPPING_ADDRESS_UNABLE_TO_SHIP
PaymentManager.ERROR_SHIPPING_ADDRESS_NOT_EXIST
- Since:
- API Level 1.3
-
setDisplayOption
public void setDisplayOption(int displayOption) API to set display option ofSheetItemType.SHIPPING_ADDRESS
on custom payment sheet.- Parameters:
displayOption
- Display option for shipping address on custom payment sheet
If displayOption is not set, then default addressControl is displayed on custom payment sheet.
The possible value is combination of below constants:
AddressConstants.DISPLAY_OPTION_ADDRESSEE
AddressConstants.DISPLAY_OPTION_ADDRESS
AddressConstants.DISPLAY_OPTION_PHONE_NUMBER
AddressConstants.DISPLAY_OPTION_EMAIL
int displayOption_val = AddressConstants.DISPLAY_OPTION_ADDRESSEE; // Addressee is mandatory displayOption_val += AddressConstants.DISPLAY_OPTION_ADDRESS; displayOption_val += AddressConstants.DISPLAY_OPTION_PHONE_NUMBER; displayOption_val += AddressConstants.DISPLAY_OPTION_EMAIL; shippingAddressControl.setDisplayOption(displayOption_val);
- Throws:
IllegalArgumentException
- Thrown ifSheetItemType.SHIPPING_ADDRESS
is not set in constructor.- Since:
- API Level 1.5
-
getDisplayOption
public int getDisplayOption()API to get display option ofSheetItemType.SHIPPING_ADDRESS
on custom payment sheet.- Returns:
- Current display option of shipping address on custom payment sheet
The returned value will be a combination of below constants:
AddressConstants.DISPLAY_OPTION_ADDRESSEE
AddressConstants.DISPLAY_OPTION_ADDRESS
AddressConstants.DISPLAY_OPTION_PHONE_NUMBER
AddressConstants.DISPLAY_OPTION_EMAIL
- Since:
- API Level 1.5
-
Samsung Electronics.
Samsung Pay SDK 2.19.00 - Jun 12 2024