Class SavedPaymentMethod

java.lang.Object
com.broadleafcommerce.paymenttransaction.domain.SavedPaymentMethod
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.ContextStateAware, com.broadleafcommerce.data.tracking.core.policy.Owned, Serializable

public class SavedPaymentMethod extends Object implements Serializable, com.broadleafcommerce.data.tracking.core.ContextStateAware, com.broadleafcommerce.data.tracking.core.policy.Owned
This entity is designed to store customer's, account's, or other entity's saved payment methods for future use.
See Also:
  • Constructor Details

    • SavedPaymentMethod

      public SavedPaymentMethod()
  • Method Details

    • getOwnerIdentifier

      public String getOwnerIdentifier()
      Specified by:
      getOwnerIdentifier in interface com.broadleafcommerce.data.tracking.core.policy.Owned
    • getId

      public String getId()
      The id of this saved payment method.
      Returns:
      The id of this saved payment method.
    • getName

      public 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.
    • getStatus

      public String getStatus()
      The status of this saved payment method.

      This status is used to check whether this payment method is available to be used. By default, if it is equal to "AVAILABLE_TO_USE" it means that it can be used.

      If the status is DefaultSavedPaymentMethodStatus.REQUIRES_ACTION nextAction is required.

      Some payment gateways require extra verification before the saved payment method can be used. We typically expect the result of the verification to be communicated via webhook interactions using TransactionWebhookEndpoint.handleSavedPaymentMethodWebhook(java.lang.String, org.springframework.http.HttpHeaders, java.util.Map<java.lang.String, java.lang.String>, jakarta.servlet.http.HttpServletRequest)

      Returns:
      The name of this saved payment method.
      See Also:
    • isDefaultForOwner

      public boolean isDefaultForOwner()
      Whether this saved payment is the default payment method for the owner entity.
      Returns:
      True if this saved payment is the default payment method for the owner, otherwise false.
    • getOriginatingPaymentId

      public String getOriginatingPaymentId()
      The Payment.getId() that this saved payment was created from. This is typically populated when a multi-use payment token is produced by executing a transaction against a single-use token via a checkout interaction.
      Returns:
      The Payment.getId() that this saved payment was created from
    • getOwningUserType

      public String getOwningUserType()
      Describes the owning user of the saved payment method. For example, the saved payment could belong to a Broadleaf customer or an account, therefore this value might be BLC_CUSTOMER, or BLC_ACCOUNT.
      Returns:
      The type describing the owning user of the saved payment method
    • getOwningUserId

      public String getOwningUserId()
      The id of the entity that owns this saved payment method. For example, this may be a customer id, or an account id.
      Returns:
      The id of the entity that owns this saved payment method.
    • getType

      public 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.
    • getGatewayType

      public String getGatewayType()
      The gateway used to process this saved payment method. Only a SINGLE payment gateway can be used for a payment.
      Returns:
      The gateway used to process this saved payment method.
    • getPaymentMethodProperties

      public 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

      public Map<String,String> getAttributes()
      General use map to capture any additional attributes needed for this saved payment method.
      Returns:
      General use map to capture any additional attributes needed for this saved payment method
    • getDisplayAttributes

      public 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
    • getLastTransactionDateTime

      public Instant getLastTransactionDateTime()
      The timestamp of the last transaction made by this saved payment method.
      Returns:
      the last transaction date and time of the saved payment method
    • getLastTransactionResultCode

      public String getLastTransactionResultCode()
      The result code returned from the gateway on the last transaction.
      Returns:
      the result code from the last transaction for this saved payment method
    • getBillingAddress

      public Address getBillingAddress()
      The billing address of this saved payment method.
      Returns:
      the billing address of this saved payment method
    • getContextState

      public com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState getContextState()
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      getContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Returns:
      a subset of Tracking information to expose the context state for this object
    • getVersion

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

      public String getVisibleToChildren()
      The visibility of the payment method to child accounts.

      This is typically for B2B use cases where the getOwningUserType() is DefaultSavedPaymentMethodOwningUserTypes.BLC_ACCOUNT. Should be DefaultChildrenVisibilityType.NO for typical B2C use cases.

      Returns:
      The visibility of the payment method to child accounts
      See Also:
    • getGatewayReferenceId

      @Nullable public String getGatewayReferenceId()
      Returns the saved payment method ID known by the payment gateway. This value should be unique within a single tenant and can't be updated after creation. Note: if you can't guarantee uniqueness of the gateway's ID for the payment method, then we recommend generating your own unique ID to link the Broadleaf saved payment method & the gateway's payment method.

      This is an ID that is used to fetch the saved payment method that should be updated by the webhook handler.

      For example, to create the saved payment method for the ACH payments in Stripe, you have to create the SetupIntent object and after that create the saved payment method entity in the PaymentTransactionServices. It is possible that this payment method cannot be verified instantly by the customer's bank. In this case, Stripe will send the webhook event "setup_intent.succeeded" or "setup_intent.setup_failed" when it is confirmed by the customer. And to have an ability to update the correct payment method in PaymentTransactionServices we have to fetch it by this reference ID. For Stripe this value should be the SetupIntent ID.

      Returns:
      the saved payment method id known by the payment gateway
    • getNextAction

      @Nullable public SavedPaymentMethodNextAction getNextAction()
      The next action for this payment method to complete its setup. This action is required if the status is DefaultSavedPaymentMethodStatus.REQUIRES_ACTION.
      Returns:
      the next action for this payment method
    • setId

      public void setId(String id)
      The id of this saved payment method.
      Parameters:
      id - The id of this saved payment method.
    • setName

      public void setName(String name)
      The name of this saved payment method. This name is typically something like "Visa ending in 1234".
      Parameters:
      name - The name of this saved payment method.
    • setStatus

      public void setStatus(String status)
      The status of this saved payment method.

      This status is used to check whether this payment method is available to be used. By default, if it is equal to "AVAILABLE_TO_USE" it means that it can be used.

      If the status is DefaultSavedPaymentMethodStatus.REQUIRES_ACTION nextAction is required.

      Some payment gateways require extra verification before the saved payment method can be used. We typically expect the result of the verification to be communicated via webhook interactions using TransactionWebhookEndpoint.handleSavedPaymentMethodWebhook(java.lang.String, org.springframework.http.HttpHeaders, java.util.Map<java.lang.String, java.lang.String>, jakarta.servlet.http.HttpServletRequest)

      Parameters:
      name - The name of this saved payment method.
      See Also:
    • setDefaultForOwner

      public void setDefaultForOwner(boolean defaultForOwner)
      Whether this saved payment is the default payment method for the owner entity.
      Parameters:
      defaultForOwner - Whether this saved payment is the default payment method for the owner entity.
    • setOriginatingPaymentId

      public void setOriginatingPaymentId(String originatingPaymentId)
      The Payment.getId() that this saved payment was created from. This is typically populated when a multi-use payment token is produced by executing a transaction against a single-use token via a checkout interaction.
      Parameters:
      originatingPaymentId - The Payment.getId() that this saved payment was created from
    • setOwningUserType

      public void setOwningUserType(String owningUserType)
      Describes the owning user of the saved payment method. For example, the saved payment could belong to a Broadleaf customer or an account, therefore this value might be BLC_CUSTOMER, or BLC_ACCOUNT.
      Parameters:
      owningUserType - The type describing the owning user of the saved payment method
    • setOwningUserId

      public void setOwningUserId(String owningUserId)
      The id of the entity that owns this saved payment method. For example, this may be a customer id, or an account id.
      Parameters:
      owningUserId - The id of the entity that owns this saved payment method.
    • setType

      public void setType(String type)
      The type of this saved payment method like Credit Card or Gift Card.
      Parameters:
      type - The type of this saved payment method like Credit Card or Gift Card.
    • setGatewayType

      public void setGatewayType(String gatewayType)
      The gateway used to process this saved payment method. Only a SINGLE payment gateway can be used for a payment.
      Parameters:
      gatewayType - The gateway used to process this saved payment method.
    • setPaymentMethodProperties

      public void setPaymentMethodProperties(Map<String,String> paymentMethodProperties)
      Map to capture any information about the payment method needed to perform gateway transactions.
      Parameters:
      paymentMethodProperties - Map to capture any information about the payment method needed to perform gateway transactions
    • setAttributes

      public void setAttributes(Map<String,String> attributes)
      General use map to capture any additional attributes needed for this saved payment method.
      Parameters:
      attributes - General use map to capture any additional attributes needed for this payment method
    • setDisplayAttributes

      public void setDisplayAttributes(Map<String,String> displayAttributes)
      General use map to capture any display properties for this saved payment method.
      Parameters:
      displayAttributes - General use map to capture any display properties for this payment method
    • setLastTransactionDateTime

      public void setLastTransactionDateTime(Instant lastTransactionDateTime)
      The timestamp of the last transaction made by this saved payment method.
      Parameters:
      lastTransactionDateTime - the last transaction date and time of the saved payment method
    • setLastTransactionResultCode

      public void setLastTransactionResultCode(String lastTransactionResultCode)
      The result code returned from the gateway on the last transaction.
      Parameters:
      lastTransactionResultCode - the result code from the last transaction for this saved payment method
    • setBillingAddress

      public void setBillingAddress(Address billingAddress)
      The billing address of this saved payment method.
      Parameters:
      billingAddress - the billing address of this saved payment method
    • setContextState

      public void setContextState(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState)
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      setContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Parameters:
      contextState - a subset of Tracking information to expose the context state for this object
    • setVersion

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

      public void setVisibleToChildren(String visibleToChildren)
      The visibility of the payment method to child accounts.

      This is typically for B2B use cases where the getOwningUserType() is DefaultSavedPaymentMethodOwningUserTypes.BLC_ACCOUNT. Should be DefaultChildrenVisibilityType.NO for typical B2C use cases.

      Parameters:
      visibleToChildren - The visibility of the payment method to child accounts
      See Also:
    • setGatewayReferenceId

      public void setGatewayReferenceId(@Nullable String gatewayReferenceId)
      Returns the saved payment method ID known by the payment gateway. This value should be unique within a single tenant and can't be updated after creation. Note: if you can't guarantee uniqueness of the gateway's ID for the payment method, then we recommend generating your own unique ID to link the Broadleaf saved payment method & the gateway's payment method.

      This is an ID that is used to fetch the saved payment method that should be updated by the webhook handler.

      For example, to create the saved payment method for the ACH payments in Stripe, you have to create the SetupIntent object and after that create the saved payment method entity in the PaymentTransactionServices. It is possible that this payment method cannot be verified instantly by the customer's bank. In this case, Stripe will send the webhook event "setup_intent.succeeded" or "setup_intent.setup_failed" when it is confirmed by the customer. And to have an ability to update the correct payment method in PaymentTransactionServices we have to fetch it by this reference ID. For Stripe this value should be the SetupIntent ID.

      Parameters:
      gatewayReferenceId - the saved payment method id known by the payment gateway
    • setNextAction

      public void setNextAction(@Nullable SavedPaymentMethodNextAction nextAction)
      The next action for this payment method to complete its setup. This action is required if the status is DefaultSavedPaymentMethodStatus.REQUIRES_ACTION.
      Parameters:
      nextAction - the next action for this payment method
    • 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