Forms

class polaris.integrations.TransactionForm[source]

A base class for collecting transaction information. Developers must define subclasses to collect additional information and apply additional validation.

This form assumes the amount collected is in units of a Stellar Asset. If the amount of an OffChainAsset must be collected, create a different form.

Note that Polaris’ base UI treats the amount field on this form and its subclasses differently than other forms. Specifically, Polaris automatically adds the asset’s symbol to the input field, adds a placeholder value of 0, makes the fee table visible (by default), and uses the amount entered to update the fee table on each change.

If you do not want the fee table to be displayed when TransactionForm is rendered, set "show_fee_table" to False in the dict returned from content_for_template().

Fee calculation within the UI is done using the asset’s fixed and percentage fee values saved to the database. If those values are not present, Polaris makes calls to the anchor’s /fee endpoint and displays the response value to the user. If your /fee endpoint requires a type parameter, add a TransactionForm.type attribute to the form. Polaris will detect the attribute’s presence on the form and include it in /fee requests.

The amount field is validated with the clean_amount() function, which ensures the amount is within the bounds for the asset type.

class polaris.integrations.CreditCardForm[source]

A generic form for collecting credit or debit card information.

Ensures card_number is valid, but does not validate the expiration or cvv. Subclass this form for additional validation.