Class TransactionRequest

java.lang.Object
com.aoapps.payments.TransactionRequest
All Implemented Interfaces:
Cloneable

public class TransactionRequest extends Object implements Cloneable
Encapsulates the details about a specific transaction request, which will be sent to either sale or authorize.
Author:
AO Industries, Inc.
See Also:
  • Field Details

    • DEFAULT_DUPLICATE_WINDOW

      public static final int DEFAULT_DUPLICATE_WINDOW
      The default number of seconds for duplication detection.
      See Also:
  • Constructor Details

    • TransactionRequest

      public TransactionRequest()
      Creates an empty TransactionRequest. The values should be set using the appropriate setter methods.
    • TransactionRequest

      public TransactionRequest(boolean testMode, String customerIp, int duplicateWindow, String orderNumber, Currency currency, BigDecimal amount, BigDecimal taxAmount, boolean taxExempt, BigDecimal shippingAmount, BigDecimal dutyAmount, String shippingFirstName, String shippingLastName, String shippingCompanyName, String shippingStreetAddress1, String shippingStreetAddress2, String shippingCity, String shippingState, String shippingPostalCode, String shippingCountryCode, boolean emailCustomer, String merchantEmail, String invoiceNumber, String purchaseOrderNumber, String description)
      Creates a TransactionRequest providing all of the details.
      Throws:
      IllegalArgumentException - if anything not valid
  • Method Details

    • getTotalAmount

      public static BigDecimal getTotalAmount(BigDecimal amount, BigDecimal taxAmount, BigDecimal shippingAmount, BigDecimal dutyAmount)
      Adds-up all amounts into a total amount.
      Returns:
      amount + tax + shipping + duty
    • clone

      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException
    • getTestMode

      public boolean getTestMode()
      Gets the test mode for this transaction.
    • setTestMode

      public void setTestMode(boolean testMode)
      Sets the test mode for this transaction.
    • getCustomerIp

      public String getCustomerIp()
      Gets the customer IP.
    • setCustomerIp

      public void setCustomerIp(String customerIp)
      Sets the customer IP.
    • getDuplicateWindow

      public int getDuplicateWindow()
      Gets the duplicate detection window in seconds. Defaults to DEFAULT_DUPLICATE_WINDOW seconds.
    • setDuplicateWindow

      public void setDuplicateWindow(int duplicateWindow)
      Sets the duplicate detenction window in seconds.
    • getOrderNumber

      public String getOrderNumber()
      Gets the unique order number.
    • setOrderNumber

      public void setOrderNumber(String orderNumber)
      Sets the unique order number.
    • getCurrency

      public Currency getCurrency()
      Gets the currency for this transaction.
    • setCurrency

      public void setCurrency(Currency currency)
      Sets the currency code for this transaction. The currency should be set before the monetary amounts in order to properly scale the amounts. If the currency is reset, the amounts will be scaled. This may result in an ArithmentException.
    • getAmount

      public BigDecimal getAmount()
      Gets the amount of the transaction. This amount should not include any tax, shipping charges, or duty. Thus the total amount of the transaction is the amount + taxAmount + shippingAmount + dutyAmount.
      See Also:
    • setAmount

      public void setAmount(BigDecimal amount) throws IllegalArgumentException
      Sets the amount of the transaction. This amount should not include any tax, shipping charges, or duty. Thus the total amount of the transaction is the amount + taxAmount + shippingAmount + dutyAmount.

      The amount is normalized to the proper number of decimal places for the selected currency.

      Throws:
      IllegalArgumentException - if amount <= 0 or is incorrectly formatted for the currency.
    • getTaxAmount

      public BigDecimal getTaxAmount()
      Gets the tax amount of the transaction.
    • setTaxAmount

      public void setTaxAmount(BigDecimal taxAmount)
      Sets the tax amount of the transaction.

      The amount is normalized to the proper number of decimal places for the selected currency.

      Throws:
      IllegalArgumentException - if taxAmount < 0 or is incorrectly formatted for the currency.
    • getTaxExempt

      public boolean getTaxExempt()
      Gets the tax exempt flag.
    • setTaxExempt

      public void setTaxExempt(boolean taxExempt)
      Set the tax exempt flag.
    • getShippingAmount

      public BigDecimal getShippingAmount()
      Gets the shipping amount of the transaction.
    • setShippingAmount

      public void setShippingAmount(BigDecimal shippingAmount)
      Sets the shipping amount of the transaction.

      The amount is normalized to the proper number of decimal places for the selected currency.

      Throws:
      IllegalArgumentException - if shippingAmount < 0 or is incorrectly formatted for the currency.
    • getDutyAmount

      public BigDecimal getDutyAmount()
      Gets the duty charges of the transaction.
    • setDutyAmount

      public void setDutyAmount(BigDecimal dutyAmount)
      Sets the duty charges of the transaction.

      The amount is normalized to the proper number of decimal places for the selected currency.

      Throws:
      IllegalArgumentException - if dutyAmount < 0 or is incorrectly formatted for the currency.
    • getTotalAmount

      public BigDecimal getTotalAmount()
      Adds-up all amounts into a total amount.
      Returns:
      amount + tax + shipping + duty
    • getShippingFirstName

      public String getShippingFirstName()
      Gets the first name of the recipient.
    • setShippingFirstName

      public void setShippingFirstName(String shippingFirstName)
      Trims and sets the first name of the recipient.
    • getShippingLastName

      public String getShippingLastName()
      Gets the last name of the recipient.
    • setShippingLastName

      public void setShippingLastName(String shippingLastName)
      Trims and sets the last name of the recipient.
    • getShippingCompanyName

      public String getShippingCompanyName()
      Gets the company name of the recipient.
    • setShippingCompanyName

      public void setShippingCompanyName(String shippingCompanyName)
      Trims and sets the company name of the recipient.
    • getShippingStreetAddress1

      public String getShippingStreetAddress1()
      Gets the shipping street address (first line).
    • setShippingStreetAddress1

      public void setShippingStreetAddress1(String shippingStreetAddress1)
      Trims and sets the shipping street address (first line).
    • getShippingStreetAddress2

      public String getShippingStreetAddress2()
      Gets the shipping street address (second line).
    • setShippingStreetAddress2

      public void setShippingStreetAddress2(String shippingStreetAddress2)
      Trims and sets the shipping street address (second line).
    • getShippingCity

      public String getShippingCity()
      Gets the shipping city.
    • setShippingCity

      public void setShippingCity(String shippingCity)
      Trims and sets the shipping city.
    • getShippingState

      public String getShippingState()
      Gets the shipping state/province/prefecture.
    • setShippingState

      public void setShippingState(String shippingState)
      Trims and sets the shipping state/province/prefecture.
    • getShippingPostalCode

      public String getShippingPostalCode()
      Gets the shipping postal code.
    • setShippingPostalCode

      public void setShippingPostalCode(String shippingPostalCode)
      Trims and sets the shipping postal code.
    • getShippingCountryCode

      public String getShippingCountryCode()
      Gets the shipping two-digit ISO 3166-1 alpha-2 country code.

      See https://wikipedia.org/wiki/ISO_3166-1_alpha-2

    • setShippingCountryCode

      public void setShippingCountryCode(String shippingCountryCode)
      Trims, converts to upper case, and sets the shipping two-digit ISO 3166-1 alpha-2 country code.

      See https://wikipedia.org/wiki/ISO_3166-1_alpha-2

      Throws:
      IllegalArgumentException - if not a two-character code (after trimming).
    • getEmailCustomer

      public boolean getEmailCustomer()
      Gets the flag indicating if the customer will be emailed directly by the payment gateway.
    • setEmailCustomer

      public void setEmailCustomer(boolean emailCustomer)
      Sets the flag indicating if the customer will be emailed directly by the payment gateway.
    • getMerchantEmail

      public String getMerchantEmail()
      Gets the merchant email address that will be emailed a copy of the customer email directly by the payment gateway.
    • setMerchantEmail

      public void setMerchantEmail(String merchantEmail)
      Trims and sets the merchant email address that will be emailed a copy of the customer email directly by the payment gateway.
      Throws:
      IllegalArgumentException - if the address does is not in the proper format
    • getInvoiceNumber

      public String getInvoiceNumber()
      Gets the merchant-assigned invoice number.
    • setInvoiceNumber

      public void setInvoiceNumber(String invoiceNumber)
      Sets the merchant-assigned invoice number.
    • getPurchaseOrderNumber

      public String getPurchaseOrderNumber()
      Gets the purchase order number.
    • setPurchaseOrderNumber

      public void setPurchaseOrderNumber(String purchaseOrderNumber)
      Sets the purchase order number.
    • getDescription

      public String getDescription()
      Gets the merchant-assigned description.
    • setDescription

      public void setDescription(String description)
      Sets the merchant-assigned description.