Class UpdatePaymentRequest
- All Implemented Interfaces:
VersionedRequest
,Serializable
- Direct Known Subclasses:
SystemUpdatePaymentRequest
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
boolean
Optional<javax.money.MonetaryAmount>
The payment's adjustments (a.k.a discounts) total, usually excluding shipping/fulfillment discounts.Optional<javax.money.MonetaryAmount>
The amount for which the payment is allotted.Map to capture any additional information about the paymentThe billing address associated with this payment.General use map to capture any display properties for this PaymentGets the version that the client is aware of.Optional<javax.money.MonetaryAmount>
The payment's total fee costOptional<javax.money.MonetaryAmount>
The payment's total fulfillment costThe gateway used to process this payment.Optional<javax.money.MonetaryAmount>
The payment's total included taxgetName()
The name of this payment.The ID of the payment to update.Map to capture any information about the payment method needed to perform gateway transactionsThe id of the saved payment method that was used to build this payment object.Optional<javax.money.MonetaryAmount>
The payment's total usually excluding adjustments, tax, and shipping.Optional<javax.money.MonetaryAmount>
The payment's total tax costgetType()
The type of this payment like Credit Card or Gift Card.The version of this payment.int
hashCode()
Whether or not the underlying payment method can only be used once.void
setEntityVersion
(Integer version) Sets the version.void
setPaymentId
(String paymentId) The ID of the payment to update.Should the payment method be saved to the owning userDeprecated, for removal: This API element is subject to removal in a future version.toString()
-
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 ofshouldSavePaymentForFutureUse()
to support owning user types other than a customer (i.e. account). -
shouldSavePaymentForFutureUse
Should the payment method be saved to the owning user- Returns:
- Should the payment method be saved to the owning user
-
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
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 interfaceVersionedRequest
- Returns:
- the version that the client is aware of
-
setEntityVersion
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 interfaceVersionedRequest
- Parameters:
version
- the version supplied from an alternative source
-
getPaymentId
The ID of the payment to update.- Returns:
- the payment ID this update is for
-
getName
The name of this payment. This name is typically something like "Visa ending in 1234".- Returns:
- The name of this payment.
-
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
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
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
The amount for which the payment is allotted.- Returns:
- The amount for which the payment is allotted.
-
getSubtotal
The payment's total usually excluding adjustments, tax, and shipping.- Returns:
- The payment's total usually excluding adjustments, tax, and shipping.
-
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
The payment's total fulfillment cost- Returns:
- The payment's total fulfillment cost
-
getFeesTotal
The payment's total fee cost- Returns:
- The payment's total fee cost
-
getTaxTotal
The payment's total tax cost- Returns:
- The payment's total tax cost
-
getIncludedTaxTotal
The payment's total included tax- Returns:
- The payment's total included tax
-
getBillingAddress
The billing address associated with this payment.- Returns:
- The billing address associated with this payment.
-
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
Map to capture any additional information about the payment- Returns:
- Map to capture any additional information about the payment
-
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
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
-
canEqual
-
hashCode
public int hashCode() -
toString
-
setPaymentId
The ID of the payment to update.- Parameters:
paymentId
- the payment ID this update is for
-
shouldSavePaymentForFutureUse()
to support owning user types other than a customer (i.e.