Class TransactionBuilder

java.lang.Object
com.commercetools.api.models.payment.TransactionBuilder
All Implemented Interfaces:
Builder<Transaction>

public class TransactionBuilder extends Object implements Builder<Transaction>
TransactionBuilder
Example to create an instance using the builder pattern

     Transaction transaction = Transaction.builder()
             .id("{id}")
             .type(TransactionType.AUTHORIZATION)
             .amount(amountBuilder -> amountBuilder)
             .state(TransactionState.INITIAL)
             .build()
 
  • Constructor Details

    • TransactionBuilder

      public TransactionBuilder()
  • Method Details

    • id

      public TransactionBuilder id(String id)

      Unique identifier of the Transaction.

      Parameters:
      id - value to be set
      Returns:
      Builder
    • timestamp

      public TransactionBuilder timestamp(@Nullable ZonedDateTime timestamp)

      Date and time (UTC) the Transaction took place.

      Parameters:
      timestamp - value to be set
      Returns:
      Builder
    • type

      public TransactionBuilder type(TransactionType type)

      Type of the Transaction. For example, Authorization.

      Parameters:
      type - value to be set
      Returns:
      Builder
    • amount

      Money value of the Transaction.

      Parameters:
      builder - function to build the amount value
      Returns:
      Builder
    • withAmount

      Money value of the Transaction.

      Parameters:
      builder - function to build the amount value
      Returns:
      Builder
    • amount

      public TransactionBuilder amount(CentPrecisionMoney amount)

      Money value of the Transaction.

      Parameters:
      amount - value to be set
      Returns:
      Builder
    • interactionId

      public TransactionBuilder interactionId(@Nullable String interactionId)

      Identifier used by the interface that manages the Transaction (usually the PSP). If a matching interaction was logged in the interfaceInteractions array, the corresponding interaction can be found with this ID.

      Parameters:
      interactionId - value to be set
      Returns:
      Builder
    • state

      public TransactionBuilder state(TransactionState state)

      State of the Transaction.

      Parameters:
      state - value to be set
      Returns:
      Builder
    • custom

      Custom Fields defined for the Transaction.

      Parameters:
      builder - function to build the custom value
      Returns:
      Builder
    • withCustom

      Custom Fields defined for the Transaction.

      Parameters:
      builder - function to build the custom value
      Returns:
      Builder
    • custom

      public TransactionBuilder custom(@Nullable CustomFields custom)

      Custom Fields defined for the Transaction.

      Parameters:
      custom - value to be set
      Returns:
      Builder
    • getId

      public String getId()

      Unique identifier of the Transaction.

      Returns:
      id
    • getTimestamp

      @Nullable public ZonedDateTime getTimestamp()

      Date and time (UTC) the Transaction took place.

      Returns:
      timestamp
    • getType

      public TransactionType getType()

      Type of the Transaction. For example, Authorization.

      Returns:
      type
    • getAmount

      public CentPrecisionMoney getAmount()

      Money value of the Transaction.

      Returns:
      amount
    • getInteractionId

      @Nullable public String getInteractionId()

      Identifier used by the interface that manages the Transaction (usually the PSP). If a matching interaction was logged in the interfaceInteractions array, the corresponding interaction can be found with this ID.

      Returns:
      interactionId
    • getState

      public TransactionState getState()

      State of the Transaction.

      Returns:
      state
    • getCustom

      @Nullable public CustomFields getCustom()

      Custom Fields defined for the Transaction.

      Returns:
      custom
    • build

      public Transaction build()
      builds Transaction with checking for non-null required values
      Specified by:
      build in interface Builder<Transaction>
      Returns:
      Transaction
    • buildUnchecked

      public Transaction buildUnchecked()
      builds Transaction without checking for non-null required values
      Returns:
      Transaction
    • of

      public static TransactionBuilder of()
      factory method for an instance of TransactionBuilder
      Returns:
      builder
    • of

      public static TransactionBuilder of(Transaction template)
      create builder for Transaction instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder