Class ReceiptSvc

java.lang.Object
com.avoka.tm.svc.ReceiptSvc

public class ReceiptSvc extends Object
Provides a PDF Receipt service which supports rendering PDF receipts on demand. Furthermore, a receipt could be rendered in various modes (deliver, email or web) by specific receipt render service.

Examples

The example below ensures the form PDF receipt has been generated.

 import com.avoka.tm.query.*
 import com.avoka.tm.svc.*
 import com.avoka.tm.vo.*

 // Get the transaction object
 Txn txn = ...

 // Ensure PDF receipt has been rendered
 new ReceiptSvc()
     .setTxn(txn)
     .renderReceipt()

 // Re-query Txn and fetch PDF receipt data
 txn = new TxnQuery()
     .setTxn(txn)
     .withReceiptPdf()
     .firstValue()

 byte[] receiptPdf = txn.receiptPdf 

The example render Web mode PDF receipt with specific service by txn, service name and service version. Note service should be with the same client as the txn.

 import com.avoka.tm.query.*
 import com.avoka.tm.svc.*
 import com.avoka.tm.vo.*

 // Get the transaction object
 Txn txn = ...

 // Render receipt with that service
 byte[] receiptPdf = new ReceiptSvc()
                          .setTxn(txn)
                          .setSvcName('My Receipt Render Service Name')
                          .setSvcVersion('1.2.3')
                          .setReceiptMode(ReceiptMode.WEB)
                          .renderReceipt() 
Since:
5.0.1
  • Constructor Details

    • ReceiptSvc

      public ReceiptSvc()
  • Method Details

    • setForceUpdate

      public ReceiptSvc setForceUpdate(boolean forceUpdate)
      Set the forceUpdate flag for receipt rendering
      Parameters:
      forceUpdate - the forceUpdate flag
       Setting to false will return the receipt data if exists, otherwise trigger render receipt, when calling renderReceipt() method
       Setting to true will force re-render receipt if Receipt status is yet "Completed" when calling renderReceipt() method, which
       in turn return the new receipt PDF bytes data if there are changes on the form since last receipt render.
       
      Returns:
      the receipt service
      Since:
      24.4.0
    • setTxn

      public ReceiptSvc setTxn(Txn txn)
      Set the transaction parameter.
      Parameters:
      txn - the transaction to set (required)
      Returns:
      the receipt service
    • setSvcName

      public ReceiptSvc setSvcName(String srvName)
      Set the receipt service definition name to render.
      Parameters:
      srvName - the receipt service definition name to render
      Returns:
      the receipt service
      Since:
      19.11.0
    • setSvcVersion

      public ReceiptSvc setSvcVersion(String svcVersion)
      Set the receipt service definition version to invoke. If not specified, then the current one will be used
      Parameters:
      svcVersion - receipt service definition version number to invoke
      Returns:
      the receipt service
      Since:
      19.11.0
    • setReceiptMode

      public ReceiptSvc setReceiptMode(ReceiptSvc.ReceiptMode receiptMode)
      Set the receipt mode (default is DELIVERY).
      Parameters:
      receiptMode - the receipt mode
      Returns:
      the receipt service
      Since:
      19.11.0
    • renderReceipt

      public byte[] renderReceipt()
      Render the transaction PDF receipt and return the PDF bytes data.
      Returns:
      the rendered PDF data