Adding Stripe PHP Snippet To GF

First time posting to the forum. Forgive me if I fall astray or if I’m miscategorized.

I’m having a difficult time customizing GF & GF Stripe Add On to allow ONLY card data to be captured on a client’s site. The previous dev did some mumbo jumbo and it’s charging everybody $1 and on top of that he had all of the forms as Subscriptions. So on top of charging my clients’ customers they’re also being adding to automatic subscription payments for that $1.

I spent the day talking to Stripe and they offered this page but had no advice to offer on GF.

Has anybody ever integrated the PHP snippet into GF?
https://stripe.com/docs/saving-cards Can we add this to an HTML Block in GF?

    // Set your secret key: remember to switch to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    \Stripe\Stripe::setApiKey('sk_test_dDh0MpMVuG1XBAyQIVoRSX6I');

    // Create a Customer:
     $customer = \Stripe\Customer::create([
    'source' => 'tok_mastercard',
    'email' => 'paying.user@example.com',
    ]);

    // Charge the Customer instead of the card:
    $charge = \Stripe\Charge::create([
    'amount' => 1000,
    'currency' => 'usd',
    'customer' => $customer->id,
    ]);

     // YOUR CODE: Save the customer ID and other info in a database for later.

    // When it's time to charge the customer again, retrieve the customer ID.
    $charge = \Stripe\Charge::create([
    'amount' => 1500, // $15.00 this time
    'currency' => 'usd',
    'customer' => $customer_id, // Previously stored, then retrieved
    ]);

Is there an easier way to simply capture the customer’s name and card data without charging them anything? My client wants to come back in later and charge them for their total.

Is there an easier process maybe? Like invoicing?

Thanks in advance.

Hello. You should not need any of that code. You can use this method:

1 Like

Chris, thank you. I had that in there before. It still charges $1. Or so it says.

I did a test again just 5 mins ago. I also noticed that some other dev had commented out my snippet I had in there. My bank shows a pending $1 charge. Now will that fall off in 7 days I’m not sure.

I do see that I was created as a customer though. Which is ultimately what we’re trying to do here. I guess we need to have the $1 though for Stripe rules, banking rules.

The $1 is authorization only and will never be charged. It’s a temporary hold to ensure the card information is valid.

That’s what I tried explaining to the client and they keep refunding their customers. Ugh.

I just hope they do fall off because some banks don’t see them as an authorization. That I learned from Stripe.

Thanks again Chris

1 Like
© 2008 - 2019. Gravity Forms is a project by Rocketgenius Inc.