java.lang.Object
com.broadleafcommerce.paymenttransaction.web.endpoint.domain.UpdatePaymentRequest
All Implemented Interfaces:
VersionedRequest, Serializable
Direct Known Subclasses:
SystemUpdatePaymentRequest

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

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)
See Also:
  • Constructor Details

    • UpdatePaymentRequest

      public UpdatePaymentRequest()
  • Method Details

    • shouldSavePaymentToCustomer

      @Deprecated(since="1.0.2", forRemoval=true) @Nullable public Optional<Boolean> shouldSavePaymentToCustomer()
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 1.0.2, in favor of shouldSavePaymentForFutureUse() to support owning user types other than a customer (i.e. account).
    • shouldSavePaymentForFutureUse

      @Nullable public Optional<Boolean> shouldSavePaymentForFutureUse()
      Should the payment method be saved to the owning user
      Returns:
      Should the payment method be saved to the owning user
    • isSingleUsePaymentMethod

      @Nullable public Optional<Boolean> isSingleUsePaymentMethod()
      Whether or not the underlying payment method can only be used once.
      Returns:
      Whether or not the underlying payment method can only be used once.
    • 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
    • getPaymentId

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

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

      @Nullable public Optional<String> getSavedPaymentMethodId()
      The id of the saved payment method that was used to build this payment object. Note: This property is only relevant if the user desires to use a saved payment method to pay for their order. Otherwise, this value should remain unset.
      Returns:
      The id of the saved payment method.
    • getType

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

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

      @Nullable public Optional<javax.money.MonetaryAmount> getAmount()
      The amount for which the payment is allotted.
      Returns:
      The amount for which the payment is allotted.
    • getSubtotal

      @Nullable public Optional<javax.money.MonetaryAmount> getSubtotal()
      The payment's total usually excluding adjustments, tax, and shipping.
      Returns:
      The payment's total usually excluding adjustments, tax, and shipping.
    • getAdjustmentsTotal

      @Nullable public Optional<javax.money.MonetaryAmount> getAdjustmentsTotal()
      The payment's adjustments (a.k.a discounts) total, usually excluding shipping/fulfillment discounts.
      Returns:
      The payment's adjustments (a.k.a discounts) total, usually excluding shipping/fulfillment discounts.
    • getFulfillmentTotal

      @Nullable public Optional<javax.money.MonetaryAmount> getFulfillmentTotal()
      The payment's total fulfillment cost
      Returns:
      The payment's total fulfillment cost
    • getTaxTotal

      @Nullable public Optional<javax.money.MonetaryAmount> getTaxTotal()
      The payment's total tax cost
      Returns:
      The payment's total tax cost
    • getBillingAddress

      @Nullable public Optional<Address> getBillingAddress()
      The billing address associated with this payment.
      Returns:
      The billing address associated with this payment.
    • 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 payment
      Returns:
      Map to capture any additional information about the payment
    • getDisplayAttributes

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

      public Integer getVersion()
      The version of this payment. 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.
    • 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
    • setPaymentId

      public void setPaymentId(String paymentId)
      The ID of the payment to update.
      Parameters:
      paymentId - the payment ID this update is for