How do I get Stripe to automatically create new customers from each payment?

Hi there,

I use Gravity forms Stripe add-on to process transactions as a purchase (not subscription) and I notice that this does not create a new customer record in stripe.

I have added the following code to my functions.php:

add_filter( 'gform_stripe_customer_id', 'create_stripe_customer', 10, 4 );
function create_stripe_customer( $customer_id, $feed, $entry, $form ) {
    if ( empty( $customer_id ) ) {
        $customer_params = array();
 
        if ( rgars( $feed, 'meta/transactionType' ) === 'subscription' ) {
            $customer_params['email'] = gf_stripe()->get_field_value( $form, $entry, rgar( $feed['meta'], 'customerInformation_email' ) );
        } else {
            $email_field = rgars( $feed, 'meta/receipt_field' );
            if ( ! empty( $email_field ) && strtolower( $email_field ) !== 'do not send receipt' ) {
                $customer_params['email'] = gf_stripe()->get_field_value( $form, $entry, $email_field );
            }
        }
 
        $customer    = gf_stripe()->create_customer( $customer_params, $feed, $entry, $form );
        $customer_id = $customer->id;
        gf_stripe()->log_debug( 'gform_stripe_customer_id: Returning Customer ID: ' . $customer_id );
    }
 
    return $customer_id;
}

as advised on this page: https://docs.gravityforms.com/gform_stripe_customer_id/#2-create-new-customer

However the new customer is not pulling through any customer details so my new customer in Stripe is a totally blank record.

I have set up metadata in the gravity forms feed to pull through email and name, but it is not taking that metadata into the new customer record.

The main purpose of this is to be able to charge customer cards at a later date when they request additional products or services, without them having to complete the payment form again.

What would the code need to be to pull through customer email and their payment method so that I can go into stripe and charge the stored payment method from the first transaction?

This is how it worked when I used a 3rd party stripe plugin to process payments, and it made it for a friction-free process when customers would come back and ask for extras or ask to upgrade their order.

Thanks

1 Like

Hi @mobilejo - I recommend opening a support ticket for this complex issue, if you have not already: