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

public class AddressControl extends SheetControl implements 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.
Since:
API Level 1.3
  • Constructor Details

    • AddressControl

      public AddressControl(String controlId, SheetItemType sheetItemType)
      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);
      
                      // Validate billing address and set errorCode if needed.
                      AddressControl addressControl = (AddressControl)customSheet.getSheetControl(updatedControlId);
                      CustomSheetPaymentInfo.Address billAddress = addressControl.getAddress();
                      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.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 not SheetItemType.BILLING_ADDRESS or SheetItemType.SHIPPING_ADDRESS.
      Since:
      API Level 1.3
  • Method Details