java.lang.Object
com.aoapps.payments.TransactionRequest
- All Implemented Interfaces:
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 Summary
Modifier and TypeFieldDescriptionstatic final int
The default number of seconds for duplication detection. -
Constructor Summary
ConstructorDescriptionCreates an empty TransactionRequest.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. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Gets the amount of the transaction.Gets the currency for this transaction.Gets the customer IP.Gets the merchant-assigned description.int
Gets the duplicate detection window in seconds.Gets the duty charges of the transaction.boolean
Gets the flag indicating if the customer will be emailed directly by the payment gateway.Gets the merchant-assigned invoice number.Gets the merchant email address that will be emailed a copy of the customer email directly by the payment gateway.Gets the unique order number.Gets the purchase order number.Gets the shipping amount of the transaction.Gets the shipping city.Gets the company name of the recipient.Gets the shipping two-digit ISO 3166-1 alpha-2 country code.Gets the first name of the recipient.Gets the last name of the recipient.Gets the shipping postal code.Gets the shipping state/province/prefecture.Gets the shipping street address (first line).Gets the shipping street address (second line).Gets the tax amount of the transaction.boolean
Gets the tax exempt flag.boolean
Gets the test mode for this transaction.Adds-up all amounts into a total amount.static BigDecimal
getTotalAmount
(BigDecimal amount, BigDecimal taxAmount, BigDecimal shippingAmount, BigDecimal dutyAmount) Adds-up all amounts into a total amount.void
setAmount
(BigDecimal amount) Sets the amount of the transaction.void
setCurrency
(Currency currency) Sets the currency code for this transaction.void
setCustomerIp
(String customerIp) Sets the customer IP.void
setDescription
(String description) Sets the merchant-assigned description.void
setDuplicateWindow
(int duplicateWindow) Sets the duplicate detenction window in seconds.void
setDutyAmount
(BigDecimal dutyAmount) Sets the duty charges of the transaction.void
setEmailCustomer
(boolean emailCustomer) Sets the flag indicating if the customer will be emailed directly by the payment gateway.void
setInvoiceNumber
(String invoiceNumber) Sets the merchant-assigned invoice number.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.void
setOrderNumber
(String orderNumber) Sets the unique order number.void
setPurchaseOrderNumber
(String purchaseOrderNumber) Sets the purchase order number.void
setShippingAmount
(BigDecimal shippingAmount) Sets the shipping amount of the transaction.void
setShippingCity
(String shippingCity) Trims and sets the shipping city.void
setShippingCompanyName
(String shippingCompanyName) Trims and sets the company name of the recipient.void
setShippingCountryCode
(String shippingCountryCode) Trims, converts to upper case, and sets the shipping two-digit ISO 3166-1 alpha-2 country code.void
setShippingFirstName
(String shippingFirstName) Trims and sets the first name of the recipient.void
setShippingLastName
(String shippingLastName) Trims and sets the last name of the recipient.void
setShippingPostalCode
(String shippingPostalCode) Trims and sets the shipping postal code.void
setShippingState
(String shippingState) Trims and sets the shipping state/province/prefecture.void
setShippingStreetAddress1
(String shippingStreetAddress1) Trims and sets the shipping street address (first line).void
setShippingStreetAddress2
(String shippingStreetAddress2) Trims and sets the shipping street address (second line).void
setTaxAmount
(BigDecimal taxAmount) Sets the tax amount of the transaction.void
setTaxExempt
(boolean taxExempt) Set the tax exempt flag.void
setTestMode
(boolean testMode) Sets the test mode for this transaction.
-
Field Details
-
DEFAULT_DUPLICATE_WINDOW
public static final int DEFAULT_DUPLICATE_WINDOWThe 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 classObject
- 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
Gets the customer IP. -
setCustomerIp
Sets the customer IP. -
getDuplicateWindow
public int getDuplicateWindow()Gets the duplicate detection window in seconds. Defaults toDEFAULT_DUPLICATE_WINDOW
seconds. -
setDuplicateWindow
public void setDuplicateWindow(int duplicateWindow) Sets the duplicate detenction window in seconds. -
getOrderNumber
Gets the unique order number. -
setOrderNumber
Sets the unique order number. -
getCurrency
Gets the currency for this transaction. -
setCurrency
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
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
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
- ifamount <= 0
or is incorrectly formatted for the currency.
-
getTaxAmount
Gets the tax amount of the transaction. -
setTaxAmount
Sets the tax amount of the transaction.The amount is normalized to the proper number of decimal places for the selected currency.
- Throws:
IllegalArgumentException
- iftaxAmount < 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
Gets the shipping amount of the transaction. -
setShippingAmount
Sets the shipping amount of the transaction.The amount is normalized to the proper number of decimal places for the selected currency.
- Throws:
IllegalArgumentException
- ifshippingAmount < 0
or is incorrectly formatted for the currency.
-
getDutyAmount
Gets the duty charges of the transaction. -
setDutyAmount
Sets the duty charges of the transaction.The amount is normalized to the proper number of decimal places for the selected currency.
- Throws:
IllegalArgumentException
- ifdutyAmount < 0
or is incorrectly formatted for the currency.
-
getTotalAmount
Adds-up all amounts into a total amount.- Returns:
- amount + tax + shipping + duty
-
getShippingFirstName
Gets the first name of the recipient. -
setShippingFirstName
Trims and sets the first name of the recipient. -
getShippingLastName
Gets the last name of the recipient. -
setShippingLastName
Trims and sets the last name of the recipient. -
getShippingCompanyName
Gets the company name of the recipient. -
setShippingCompanyName
Trims and sets the company name of the recipient. -
getShippingStreetAddress1
Gets the shipping street address (first line). -
setShippingStreetAddress1
Trims and sets the shipping street address (first line). -
getShippingStreetAddress2
Gets the shipping street address (second line). -
setShippingStreetAddress2
Trims and sets the shipping street address (second line). -
getShippingCity
Gets the shipping city. -
setShippingCity
Trims and sets the shipping city. -
getShippingState
Gets the shipping state/province/prefecture. -
setShippingState
Trims and sets the shipping state/province/prefecture. -
getShippingPostalCode
Gets the shipping postal code. -
setShippingPostalCode
Trims and sets the shipping postal code. -
getShippingCountryCode
Gets the shipping two-digit ISO 3166-1 alpha-2 country code. -
setShippingCountryCode
Trims, converts to upper case, and sets the shipping two-digit ISO 3166-1 alpha-2 country code.- 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
Gets the merchant email address that will be emailed a copy of the customer email directly by the payment gateway. -
setMerchantEmail
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
Gets the merchant-assigned invoice number. -
setInvoiceNumber
Sets the merchant-assigned invoice number. -
getPurchaseOrderNumber
Gets the purchase order number. -
setPurchaseOrderNumber
Sets the purchase order number. -
getDescription
Gets the merchant-assigned description. -
setDescription
Sets the merchant-assigned description.
-