bookmark_borderCreate a customer in Stripe without capturing payment

You can create a customer in your Stripe.com dashboard, including their payment details, without actually charging the customer. The method you use to do this will depend on which version of the Stripe add-on you are using:

Version 2.1+

  1. Go to Form Settings > Stripe > Add New.
  2. Give the new feed a name and for the transaction type select Product and Services.
  3. The payment amount can be set to either the form total or a product field, it doesn’t matter which as long as the amount is greater than zero, the customer won’t actually be charged.
  4. Map the Stripe Receipt setting to the form field which contains the customers email address.
  5. Add the following code snippets to your theme functions.php file, replacing feed name goes here with the actual name of your feed.
add_filter( 'gform_stripe_customer_id', function ( $customer_id, $feed, $entry, $form ) {
	if ( rgars( $feed, 'meta/transactionType' ) == 'product' && rgars( $feed, 'meta/feedName' ) == 'feed name goes here' ) {
		$customer_meta = array();

		$email_field = rgars( $feed, 'meta/receipt_field' );
		if ( ! empty( $email_field ) && strtolower( $email_field ) !== 'do not send receipt' ) {
			$customer_meta['email'] = gf_stripe()->get_field_value( $form, $entry, $email_field );
		}

		$customer = gf_stripe()->create_customer( $customer_meta, $feed, $entry, $form );

		return $customer->id;
	}

	return $customer_id;
}, 10, 4 );

add_filter( 'gform_stripe_charge_authorization_only', function ( $authorization_only, $feed ) {
	if ( rgars( $feed, 'meta/feedName' ) == 'feed name goes here' ) {
		return true;
	}

	return $authorization_only;
}, 10, 2 );

When the form is submitted and passes validation the customer will be created in your Stripe account. A charge will also be created based on how the feed is configured but it will not be captured when the entry is saved. Please note that Stripe will automatically expire the authorized charges if not captured within seven days.

Older versions

  1. Go to Form Settings > Stripe > Add New.
  2. Give the new feed a name and for the transaction type select Subscription.
  3. The recurring amount can be set to either the form total or a product field, it doesn’t matter which as long as the amount is greater than zero, the customer won’t actually be charged.
  4. The billing cycle can be left to the default setting of 1 week, again the customer won’t actually be charged so the billing cycle doesn’t really matter.
  5. Enable the Trial and enter any number greater than 1, this is what delays the payment being charged.
  6. Map the customer email.
  7. Add the following code snippet to your theme functions.php file, replacing feed name goes here with the actual name of your feed.
// cancel a Stripe subscription, leaving the customer payment details in Stripe so they can be charged later
add_action( 'gform_post_subscription_started', function ( $entry ) {
    $stripe    = gf_stripe();
    $feed      = $stripe->get_payment_feed( $entry );
    $feed_name = rgars( $feed, 'meta/feedName' );
    if ( $feed_name == 'feed name goes here' ) { // update this line only.
        $result = $stripe->cancel( $entry, $feed );
        $stripe->log_debug( "gform_post_subscription_started: Cancelling subscription (feed #{$feed['id']} - {$feed_name}) for entry #{$entry['id']}. Result: " . print_r( $result, 1 ) );
    }
} );

When the form is submitted and the feed processed the customer will be created in your Stripe.com dashboard, the above hook will then run cancelling the subscription. The customer, including payment details, will remain in your Stripe.com dashboard so you can manually create payments for that customer when you are ready.