Class UpdateSavedPaymentMethodRequest

java.lang.Object
com.broadleafcommerce.paymenttransaction.web.endpoint.domain.UpdateSavedPaymentMethodRequest
All Implemented Interfaces:
VersionedRequest, Serializable

public class UpdateSavedPaymentMethodRequest extends Object implements VersionedRequest, Serializable
A request DTO used to update a SavedPaymentMethod.

It is important to note that the combined usage of @Nullable and Optional for the fields is entirely intentional.. Since there is no way to distinguish between a value not being supplied and being updated to null, this mechanism is necessary.

If the request JSON does not have a particular field's key, the field in this DTO will deserialize to null. If the request JSON does have the field's key but the value is null, the field in this DTO will deserialize to Optional.empty().

An earlier, alternate implementation relied on a single Map<String, Object> "updateFields" property to achieve the same distinction between unsupplied and null, but this approach had the flaw of not being able to take advantage of Jackson's automatic type-safe deserialization. With the current approach, Jackson can understand the declared types and automatically verify and convert the fields to the appropriate types.

Another important note is that the use of @Data and @Setter with AccessLevel#PRIVATE is intentional. This is required for getting the behavior we want from Jackson on deserialization, while still maintaining @Value-like immutability. If we were to use @Value, Jackson would always set unsupplied keys to Optional.empty(). However, when we use @Data, it seems that Jackson simply does not call the setters for the fields with unsupplied keys, which leaves them null (giving us our desired behavior).

Author:
Chad Harchar (charchar), Chris Kittrell (ckittrell), Sunny Yu
See Also:
  • Constructor Details

    • UpdateSavedPaymentMethodRequest

      public UpdateSavedPaymentMethodRequest()
  • Method Details

    • getEntityVersion

      public Integer getEntityVersion()
      Description copied from interface: VersionedRequest
      Gets the version that the client is aware of. This should be populated by the client when making a request that modifies an existing entity.
      Specified by:
      getEntityVersion in interface VersionedRequest
      Returns:
      the version that the client is aware of
    • setEntityVersion

      public void setEntityVersion(Integer version)
      Description copied from interface: VersionedRequest
      Sets the version. Typically only used for setting the version on the request body if the version came from an alternative source (e.g. cookie or header).
      Specified by:
      setEntityVersion in interface VersionedRequest
      Parameters:
      version - the version supplied from an alternative source
    • getId

      public String getId()
      The ID of the saved payment method to update.
      Returns:
      the saved payment method ID this update is for
    • getName

      @Nullable public Optional<String> getName()
      The name of this saved payment method. This name is typically something like "Visa ending in 1234".
      Returns:
      The name of this saved payment method.
    • getDefaultForOwner

      @Nullable public Optional<Boolean> getDefaultForOwner()
      Whether this saved payment method is the default payment method for the owner entity.
      Returns:
      True if this saved payment method is the default payment method for the owner, otherwise false.
    • getType

      @Nullable public Optional<String> getType()
      The type of this saved payment method like Credit Card or Gift Card.
      Returns:
      The type of this saved payment method like Credit Card or Gift Card.
      See Also:
      • DefaultPaymentTypes
    • getGatewayType

      @Nullable public Optional<String> getGatewayType()
      The gateway used to process this saved payment method. Only a SINGLE payment gateway can modify transactions on a particular payment.
      Returns:
      The gateway used to process this saved payment method.
      See Also:
      • PaymentGatewayType
    • getPaymentMethodProperties

      @Nullable public Optional<Map<String,String>> getPaymentMethodProperties()
      Map to capture any information about the payment method needed to perform gateway transactions
      Returns:
      Map to capture any information about the payment method needed to perform gateway transactions
    • getAttributes

      @Nullable public Optional<Map<String,String>> getAttributes()
      Map to capture any additional information about the saved payment method
      Returns:
      Map to capture any additional information about the saved payment method
    • getDisplayAttributes

      @Nullable public Optional<Map<String,String>> getDisplayAttributes()
      General use map to capture any display properties for this saved payment method
      Returns:
      General use map to capture any display properties for this saved payment method
    • getBillingAddress

      @Nullable public Optional<Address> getBillingAddress()
      The billing address associated with this saved payment method.
      Returns:
      The billing address associated with this saved payment method.
    • getVersion

      public Integer getVersion()
      The version of this saved payment method. Used for checking that the requested version of the payment is up-to-date before saving changes. Required for any request which results in an update being made to the payment. This should never be manually incremented/decremented.
    • getVisibleToChildren

      public Optional<String> getVisibleToChildren()
      The visibility of the payment method to child accounts
      Returns:
      The visibility of the payment method to child accounts
    • getNextAction

      @Nullable public Optional<SavedPaymentMethodNextAction> getNextAction()
      See Also:
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setId

      public void setId(String id)
      The ID of the saved payment method to update.
      Parameters:
      savedPaymentId - the saved payment method ID this update is for