-
Notifications
You must be signed in to change notification settings - Fork 191
Donation Form Lifecycle
Donation Form Lifecycle Visual.pdf
Our donation form is a react application. On the server, we construct a form schema using our Fields API, which is later converted to JSON for the front-end to consume. In GiveWP 3.0+ we build our forms using our visual form builder, storing our blocks and settings in the database as JSON. The form schema is generated based on these blocks and settings from the form builder. The final rendering process in the browser uses a unique cascading scripts approach, utilizing our form template API.
Script loading order:
- Dependencies like React from WordPress
- Our donation form registrar scripts (including gateways and form templates)
- Form design layout scripts (classic, multi-step, etc.)
- Form extension scripts (fee recovery, form field manager, etc.)
- Payment gateway scripts
- Donation form app
/**
* This is the entry point for the donation form schema, after it was built from blocks via the visual form builder.
*
* @param Give\Framework\FieldsAPI\DonationForm $form
* @param int $formId
* @param array $blockNodeRelationships
*/
do_action('givewp_donation_form_schema', $form, $formId, $blockNodeRelationships);
/**
* This is the entry point for enqueuing scripts into the GiveWP donation form rendering process using the native WordPress wp_enqueue_script.
* This is typically used for creating a custom field template
*/
do_action('givewp_donation_form_enqueue_scripts');
/**
* This filter is for converting a custom form builder block into a Fields API Node.
*
* @param Give\Framework\FieldsAPI\Contracts\Node|null $customField The custom field.
* @param Give\Framework\Blocks\BlockModel $block The block model.
* @param int $blockIndex The block index.
* @param int $formId The form ID.
* @return Give\Framework\FieldsAPI\Contracts\Node|null
*/
$customField = apply_filters(
"givewp_donation_form_block_render_{$blockName}",
$customField,
$block,
$blockIndex,
$formId
);
/**
* Fires before the donation confirmation receipt view is rendered.
*
* @param Give\Donations\Models\Donation $donation
*/
do_action('givewp_donation_confirmation_receipt_viewing', $donation);
When a donation form has been submitted, it goes through a series of processing steps.
- Validate the form request (including all fields). Exit with errors if anything is not valid.
- Determine the donor associated with the form request. Either retrieve an existing donor or create a new one.
- Determine if donation type is one-time or subscription (recurring)
- Create a donation model (and subscription model if donation type is subscription) with status(es) of pending
- Persist custom fields and field api scopes
- Request moves to the Payment Gateway including the following data: donation model, subscription model (if applicable), and gateway data
- Payment gateway processes the donation and/or subscription using their API and is responsible for completing the form request. Some gateways need to finish their request via a webhook and will mark the donation in a processing status until then.
- When completed successfully, the donation form will navigate to the donation confirmation view.
/**
* Fires at the start of donation form processing, before any data is processed.
*
* @param Give\DonationForms\DataTransferObjects\DonateControllerData $formData
* @param string $gatewayId
*/
do_action('givewp_donation_form_processing_start', $formData, $gatewayId);
/**
* Fires after a donation is created during donation form processing.
*
* @param Give\Donations\Models\Donation $donation
* @param Give\Subscriptions\Models\Subscription|null $subscription
*/
do_action('givewp_donation_form_processing_donation_created', $donation, $subscription);
/**
* Fires after a subscription is created during donation form processing.
*
* @param Give\Subscriptions\Models\Subscription $subscription
* @param Give\Donations\Models\Donation $donation
*/
do_action('givewp_donation_form_processing_subscription_created', $subscription, $donation);
/**
* Fires after a donor is created during donation form processing.
*
* @param Give\Donors\Models\Donor $donor
* @param int $formId
*/
do_action('givewp_donation_form_processing_donor_created', $donor, $formId);
/**
* Fires after custom fields have been stored/processed
*
* @param Give\DonationForms\Models\DonationForm $form
* @param array $customFields
* @param Give\Donations\Models\Donation $donation
* @param Give\Subscriptions\Models\Subscription|null $subscription
*/
do_action('givewp_donation_form_processing_custom_fields_stored', $form, $customFields, $donation, $subscription)
This Wiki is focused on GiveWP development. For help using our WordPress plugin, head over to our website where you'll find Plugin Documentation and Support.