TenderModule
as of: August 13, 2013
Tender modules may be attached to one or more tenders. Tender modules
can impose error conditions, set up session variables, or display
prompts for the cashier. All modules should inherit from TenderModule.
TenderModules have the following properties. The base class constructor
will populate these proprties. Be careful if you choose to override that
function.
string tender_code (corresponds to opdata.tenders.TenderCode)
string name_string (corresponds to opdata.tenders.TenderName)
string change_type (corresponds to opdata.tenders.TenderType)
string change_string (corresponds to opdata.tenders.ChangeMessage)
number min_limit (corresponds to opdata.tenders.MinAmount)
number max_limit (corresponds to opdata.tenders.MaxAmount)
mixed amount the number entered or boolean False if no number was provided.
TenderModules have the following methods:
- mixed ErrorCheck()
This checks the transaction and returns an error if there is any reason the
tender cannot be used. It returns an HTML string describing the problem or
boolean True if no error is found. Note that the base class version of
ErrorCheck() is always called. It's not necessary to duplicate those checks
in subclasses.
- mixed PreReqCheck()
This sets up any necessary session variables and optionally directs the cashier
to another page. Typically redirects are to get a confirmation before continuing
with the tender. It returns a URL string to redirect or boolean True if no
redirect is necessary. Note that the base class version of PreReqCheck()
is always called. It's not necessary to duplicate any of that functionality in
subclasses.
- [none] Add()
Add a tender record to the transaction. Not usually overridden.
- string ChangeType()
Returns the tender code that should be used for the change record (if there is one).
The default is simply the object's change_type property.
- boolean AllowDefault()
Allow the tender to be used without specifying an amount.
The default is True.
- number DefaultTotal()
The value to use for an amount if none has been specified.
The default is the session variable runningTotal.
- string DefaultPrompt()
Sets up session variables then returns a URL for the prompt page.
Override to alter the prompt text, go to a different page, add
additional actions like check endorsing, etc.
- string DisabledPrompt()
Returns an HTML error message when an amount is required but
none was provided. Override to alter the message.
I'm not going to sketch out an illustrative example. Something that tried
to use all the methods at once would be really contrived. I suggest looking
at GiftCardTender.php for a nice example of using ErrorCheck()
and PreReqCheck. GiftCertificateTender.php is a fairly
straightforward example of overriding DefaultPrompt().