Fundraising tech/Form variants

In DonationInterface, one can alter the appearance or behavior of the payment forms by sending in a 'variant' querystring variable.

The variant is stored in session and so is 'sticky' - we need this so that variant behavior specified on the initial querystring from banners is applied all throughout the donation process, including when a donor returns from a payment process. At that point the variant will no longer be on the querystring but we want it to continue changing the form behavior, for example to show a post-payment request for the donor to add a monthly donation. This stickiness can make testing confusing. Testers can either test in a fresh browser or incognito session, or clear payments-wiki cookies to ensure that they are seeing non-variant behavior.

The 'variant' mechanism allows replacement of any of the yaml files in a gateway's DonationInterface config subdirectory. Each variant corresponds to a subdirectory of the 'form_variants' top-level directory. Under each variant subdirectory, there is a subdirectory for each gateway that can be altered by the variant. Yaml files in these subdirectories replace identically-named files in the gateway's own config folder.

For example, under ingenico_gateway/config, the ui_modules.yaml file specifies a single resourceloader module to be loaded on all ingenico-related forms: scripts: - ext.donationInterface.ingenico-hosted

The 'employer' variant overrides that because the file form_variants/employer/ingenico/ui_modules.yaml exists. It specifies both the standard ingenico scripts and an additional script. The standard module is specified because yaml files are entirely replaced rather than inherited and overridden (as happens in cascading SmashPig configuration). scripts: - ext.donationInterface.ingenico-hosted - ext.donationInterface.employerAutoComplete

TODO: variant-related config variables + other common yaml files to replace (message_replacements, country_fields) Whole new page for monthly convert as it can be activated independent of the variant mechanism.