bookmark_borderHow to add Delayed Payment Support to a Feed Add-On

Introduction

There are times when users will want to use multiple add-ons with the same form, one of those could be the PayPal Payments Standard Add-On. 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 PayPal 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 PayPal 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

    The form which is currently being processed.

  • $entry Entry Object

    The entry which is currently being processed.