Class PaymentRequest

java.lang.Object
com.broadleafcommerce.paymentgateway.domain.PaymentRequest
All Implemented Interfaces:
Serializable

public class PaymentRequest extends Object implements Serializable

A DTO that is comprised of all the information that is sent to a Payment Gateway to complete a transaction. This DTO uses a modified builder pattern in order to provide an easy way of constructing the request. You can construct a DTO using the following notation:

IMPORTANT: note that some of the convenience methods generate a new instance of the object. (e.g. billTo, shipTo, etc...) So, if you need to modify the shipping or billing information after you have invoked requestDTO.shipTo()..., use the getShipTo() method to append more information. Otherwise, you will overwrite the shipping information with a new instance.

 
      PaymentRequest paymentRequest = new PaymentRequest()
          .orderId(referenceNumber)
          .customer()
              .customerId("1")
              .done()
          .shipTo()
              .firstName("Bill")
              .lastName("Broadleaf")
              .addressLine1("123 Test Dr.")
              .city("Austin")
              .stateRegion("TX")
              .postalCode("78759")
              .done()
          .billTo()
              .firstName("Bill")
              .lastName("Broadleaf")
              .addressLine1("123 Test Dr.")
              .city("Austin")
              .stateRegion("TX")
              .postalCode("78759")
              .done()
          .shippingTotal(0)
          .taxTotal(0)
          .orderDescription("My Order Description")
          .orderSubtotal(10.00)
          .transactionTotal(10.00)
          .lineItem()
              .name("My Product")
              .description("My Product Description")
              .shortDescription("My Product Short Description")
              .systemId("1")
              .amount(10.00)
              .quantity(1)
              .itemTotal(10.00)
              .tax(0)
              .total(10.00)
              .done();
 
 
Author:
Elbert Bautista (elbertbautista)
See Also:
  • Constructor Details

    • PaymentRequest

      public PaymentRequest()
  • Method Details

    • customer

      public GatewayCustomer<PaymentRequest> customer()
      You should only call this once, as it will create a new customer if called more than once. Use the getter if you need to append more information later.
    • creditCard

      public CreditCard<PaymentRequest> creditCard()
      You should only call this once, as it will create a new credit card if called more than once. Use the getter if you need to append more information later.
    • subscription

      public Subscription<PaymentRequest> subscription()
      You should only call this once, as it will create a new subscription if called more than once. Use the getter if you need to append more information later.
    • shipTo

      public Address<PaymentRequest> shipTo()
      You should only call this once, as it will create a new customer if called more than once. Use the getter if you need to append more information later.
    • billTo

      public Address<PaymentRequest> billTo()
      You should only call this once, as it will create a new bill to address if called more than once. Use the getter if you need to append more information later.
    • giftCard

      public GiftCard<PaymentRequest> giftCard()
      You should only call this once, as it will create a new gift card if called more than once. Use the getter if you need to append more information later.
    • customerCredit

      public CustomerCredit<PaymentRequest> customerCredit()
      You should only call this once, as it will create a new gift card if called more than once. Use the getter if you need to append more information later.
    • lineItem

      public LineItem lineItem()
    • additionalField

      public PaymentRequest additionalField(String key, Object value)
    • orderId

      @Deprecated public PaymentRequest orderId(String orderId)
      Deprecated.
      In favor of paymentOwnerType and paymentOwnerId.
      Sets the Order ID that this transaction is associated with.
      Returns:
      the PaymentRequest
    • getOrderId

      @Deprecated public String getOrderId()
      Deprecated.
      In favor of paymentOwnerType and paymentOwnerId.
      Gets the Order ID that this transaction is associated with.
      Returns:
      the Order ID that this transaction is associated with.
    • paymentOwnerType

      public PaymentRequest paymentOwnerType(String ownerType)
    • paymentOwnerId

      public PaymentRequest paymentOwnerId(String ownerId)
    • paymentId

      public PaymentRequest paymentId(String paymentId)
    • createMultiUseToken

      public PaymentRequest createMultiUseToken(boolean createMultiUseToken)
    • paymentOwnerDescription

      public PaymentRequest paymentOwnerDescription(String paymentOwnerDescription)
    • orderDescription

      public PaymentRequest orderDescription(String orderDescription)
      Deprecated.
      In favor of paymentOwnerDescription
      Sets a description of the order associated with this transaction
      Returns:
      the PaymentRequest
    • getOrderDescription

      @Deprecated public String getOrderDescription()
      Deprecated.
      In favor of paymentOwnerDescription
      Gets a description of the order associated with this transaction.
      Returns:
      a description of the order associated with this transaction.
    • orderSubtotal

      public PaymentRequest orderSubtotal(javax.money.MonetaryAmount orderSubtotal)
    • adjustmentsTotal

      public PaymentRequest adjustmentsTotal(javax.money.MonetaryAmount adjustmentsTotal)
    • shippingTotal

      public PaymentRequest shippingTotal(javax.money.MonetaryAmount shippingTotal)
    • taxTotal

      public PaymentRequest taxTotal(javax.money.MonetaryAmount taxTotal)
    • transactionTotal

      public PaymentRequest transactionTotal(javax.money.MonetaryAmount transactionTotal)
    • paymentType

      public PaymentRequest paymentType(PaymentType paymentType)
    • transactionReferenceId

      public PaymentRequest transactionReferenceId(String transactionReferenceId)
    • completeCheckoutOnCallback

      public PaymentRequest completeCheckoutOnCallback(boolean completeCheckoutOnCallback)
    • applicationId

      public PaymentRequest applicationId(String applicationId)
    • tenantId

      public PaymentRequest tenantId(String tenantId)
    • shipToPopulated

      public boolean shipToPopulated()
    • billToPopulated

      public boolean billToPopulated()
    • creditCardPopulated

      public boolean creditCardPopulated()
    • customerPopulated

      public boolean customerPopulated()
    • subscriptionPopulated

      public boolean subscriptionPopulated()
    • getAdditionalField

      public Object getAdditionalField(String key)
    • getCustomer

      public GatewayCustomer<PaymentRequest> getCustomer()
      Any customer information that relates to this transaction
      Returns:
      any customer information that relates to this transaction
    • getShipTo

      public Address<PaymentRequest> getShipTo()
      If shipping information is captured on the gateway, the values sent back will be put here
      Returns:
      the customer's shipping address
    • getBillTo

      public Address<PaymentRequest> getBillTo()
      The billing address associated with this transaction
      Returns:
      the customer's billing address
    • getCreditCard

      public CreditCard<PaymentRequest> getCreditCard()
      For sale/authorize transactions, this will be the Credit Card object that was charged. This data is useful for showing on an order confirmation screen.
      Returns:
      any relevant credit card data
    • getSubscription

      public Subscription<PaymentRequest> getSubscription()
      Any information required to execute recurring billing
      Returns:
      any relevant recurring billing data
    • getGiftCards

      public List<GiftCard<PaymentRequest>> getGiftCards()
      Any gift cards that have been processed. This data is useful for showing on an order confirmation screen
      Returns:
      any relevant gift card data
    • getCustomerCredits

      public List<CustomerCredit<PaymentRequest>> getCustomerCredits()
      Any customer credit accounts that have been processed. This data is useful for showing on an order confirmation screen
      Returns:
      any relevant customer credit data
    • getPaymentOwnerType

      public String getPaymentOwnerType()
      Describes the owner of the payment. For example, the payment could have originated with a cart or a subscription, therefore this value might be CART or SUBSCRIPTION.
      Returns:
      The type describing the owner of the payment.
    • getPaymentOwnerId

      public String getPaymentOwnerId()
      The id of the entity that owns the payment. For example, this may be a cart id, or a subscription billing cycle id.
      Returns:
      The id of the entity that owns the payment.
    • getPaymentOwnerDescription

      public String getPaymentOwnerDescription()
      A description of the payment owner associated with this transaction
      Returns:
      A description of the payment owner associated with this transaction.
    • getPaymentId

      public String getPaymentId()
      The Payment ID that this transaction is associated with
      Returns:
      the Payment ID that this transaction is associated with
    • isCreateMultiUseToken

      public boolean isCreateMultiUseToken()
      Determines whether a multi-use token should be created.
      Returns:
      true if a multi-use token should be created, otherwise false
    • getLineItems

      public List<LineItem> getLineItems()
      The items associated to the transaction's related order
      Returns:
      the items associated to the transaction's related order
    • getPaymentType

      public PaymentType getPaymentType()
      The Type of Payment that this transaction response represents
      Returns:
      the Type of Payment that this transaction response represents
      See Also:
    • getTransactionReferenceId

      public String getTransactionReferenceId()
      The transaction reference that is passed to the payment gateway. This reference can be used to link the request to the gateway's record of the transaction in the case that the calling application does not receive a response from the gateway.
      Returns:
      The transaction reference that is passed to the payment gateway.
    • getOrderSubtotal

      public javax.money.MonetaryAmount getOrderSubtotal()
      The order's total usually excluding adjustments, tax, and shipping.
      Returns:
      The order's total usually excluding adjustments, tax, and shipping.
    • getAdjustmentsTotal

      public javax.money.MonetaryAmount getAdjustmentsTotal()
      The order's adjustments (a.k.a discounts) total, usually excluding shipping/fulfillment discounts.
      Returns:
      The order's adjustments (a.k.a discounts) total, usually excluding excluding shipping/fulfillment discounts.
    • getShippingTotal

      public javax.money.MonetaryAmount getShippingTotal()
      The order's total shipping cost
      Returns:
      The order's total shipping cost
    • getTaxTotal

      public javax.money.MonetaryAmount getTaxTotal()
      The order's total tax cost
      Returns:
      The order's total tax cost
    • getTransactionTotal

      public javax.money.MonetaryAmount getTransactionTotal()
      The order's total cost including tax & shipping charges
      Returns:
      The order's total cost including tax & shipping charges
    • isCompleteCheckoutOnCallback

      public boolean isCompleteCheckoutOnCallback()

      Sets whether or not this module should complete checkout on callback. In most Credit Card gateway implementation, this should be set to 'TRUE' and should not be configurable as the gateway expects it to tbe the final step in the checkout process.

      In gateways where it does not expect to be the last step in the checkout process, for example BLC Gift Card Module, PayPal Express Checkout, etc... The callback from the gateway can be configured whether or not to complete checkout.

    • getSiteBaseUrl

      public String getSiteBaseUrl()
      The base url of the site that is making this payment request. This value will most commonly be used to help define a "return url" or "cancel url" that is used by the payment gateway to communicate information back to our server. This is most applicable in a multi-tenant context where the site context may vary (www.site1.com vs www.site2.com), but the relative return path (/payment-gateway/return) and cancel path (/payment-gateway/cancel) remains the same.
      Returns:
      The base url of the site that is making this payment request.
    • getAdditionalFields

      public Map<String,Object> getAdditionalFields()
      Any extra properties needed to define the requested transaction
      Returns:
      Any extra properties needed to define the requested transaction
    • getTenantId

      public String getTenantId()
      The tenant id associated with the current request.
    • getApplicationId

      public String getApplicationId()
      The application id associated with the current request.