# Adding Stripe PHP Snippet To GF

**URL:** <https://community.gravityforms.com/t/adding-stripe-php-snippet-to-gf/3914>\
**Category:** Get Help\
**Tags:** custom, stripe\
**Created:** [February 13, 2020, 7:15pm UTC](https://community.gravityforms.com/t/adding-stripe-php-snippet-to-gf/3914 "2020-02-13T19:15:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![BarkManager](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/barkmanager/32/1385_2.png) [@BarkManager](https://community.gravityforms.com/u/BarkManager)\
**Post date:** [February 13, 2020, 7:15pm UTC](https://community.gravityforms.com/t/adding-stripe-php-snippet-to-gf/3914/1 "2020-02-13T19:15:07Z")

</div>

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](https://stripe.com/docs/saving-cards) Can we add this to an HTML Block in GF?

```auto
    // 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.

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [February 13, 2020, 7:32pm UTC](https://community.gravityforms.com/t/adding-stripe-php-snippet-to-gf/3914/2 "2020-02-13T19:32:36Z")

</div>

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

> **[Creating a Stripe Customer Without Payment - Gravity Forms](https://docs.gravityforms.com/create-customer-stripe-without-payment/)**
>
> Capturing a Stripe customer through your form is easy with Gravity Forms, even if you're not charging them yet. You can create a customer in your Stripe.com dashboard, including their payment details, without actually charging the customer using this...

---

<div class="post-metadata">

**Author:** ![BarkManager](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/barkmanager/32/1385_2.png) [@BarkManager](https://community.gravityforms.com/u/BarkManager)\
**Post date:** [February 13, 2020, 7:47pm UTC](https://community.gravityforms.com/t/adding-stripe-php-snippet-to-gf/3914/3 "2020-02-13T19:47:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [February 13, 2020, 7:49pm UTC](https://community.gravityforms.com/t/adding-stripe-php-snippet-to-gf/3914/4 "2020-02-13T19:49:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![BarkManager](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/barkmanager/32/1385_2.png) [@BarkManager](https://community.gravityforms.com/u/BarkManager)\
**Post date:** [February 13, 2020, 8:23pm UTC](https://community.gravityforms.com/t/adding-stripe-php-snippet-to-gf/3914/5 "2020-02-13T20:23:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![richardw8k](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/richardw8k/32/2354_2.png) [@richardw8k](https://community.gravityforms.com/u/richardw8k)\
**Post date:** [January 5, 2022, 8:53am UTC](https://community.gravityforms.com/t/adding-stripe-php-snippet-to-gf/3914/6 "2022-01-05T08:53:29Z")

</div>

Closed on January 5, 2022, 8:53am UTC


