IntroductionEnable Delayed Payment SupportDefine a Custom LabelFull ExamplePerform a Custom Action When a Feed is DelayedParameters
Introduction
There are times when users will want to use multiple add-ons with the same form; one of those could be a payment add-on such as PayPal Standard or Stripe when configured to use Stripe Checkout. As payment is not captured during submission the user may want the option to delay processing of other add-on feeds until payment has been sucesfully captured. The GFFeedAddOn class has built-in support for this; all you need to do is enable it in your add-on.
Enable Delayed Payment Support
It』s very easy to enable; all you need to do is add one line to your add-ons init() method. Here』s an example:
$this->add_delayed_payment_support( array() );
That will add a checkbox to the payment add-on feed with the label 「Process $_short_title feed only when payment is received.」
Define a Custom Label
When enabling delayed payment support you can define your own custom label for the checkbox. Here』s an example:
$this->add_delayed_payment_support(
array(
'option_label' => esc_html__( 'Subscribe contact to ActiveCampaign only when payment is received.', 'gravityformsactivecampaign' )
)
);
Full Example
/**
* Plugin starting point. Handles hooks, loading of language files, and delayed payment support.
*/
public function init() {
parent::init();
$this->add_delayed_payment_support(
array(
'option_label' => esc_html__( 'Subscribe contact to ActiveCampaign only when payment is received.', 'gravityformsactivecampaign' )
)
);
}
Perform a Custom Action When a Feed is Delayed
If you want to perform a custom action when a feed is delayed you can do that by overriding the delay_feed() method:
public function delay_feed( $feed, $entry, $form ) {
// do something when the feed is being delayed
}
Parameters
$feed Feed Object
The feed which has been delayed.
$form Form Object
The form which is currently being processed.
$entry Entry Object
The entry which is currently being processed.