Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shanedasilva's avatar

Cashier subscription is create a duplicate

I'm having trouble figuring out why I'm seeing two identical subscriptions in my Stripe dashboard for a user on account creation in my app.

I've also done logging to be sure I know that the method is only run once.

protected function registerUser(\App\Models\User $user, CreateUserRequest $request)
    {
        $user
            ->subscription($request->get('subscription'))
            ->create($request->get('stripeToken'), [
                'email'  => $user->email,
                'plan'   => $request->get('subscription'),
                'source' => [
                    'object'    => 'card',
                    'number'    => $request->get('cc-number'),
                    'exp_month' => $request->get('cc-exp-month'),
                    'exp_year'  => $request->get('cc-exp-year'),
                    'name'      => $request->get('name')
                ]
            ]);
    }
0 likes
5 replies
jekinney's avatar

Your not using stripes JavaScript? Why are you getting users c/c data?

2 likes
shanedasilva's avatar

Hi Jekinny, I am using the Stripe Javascript. I'm using the stripe.js library to generate my token which is stored in my example as $request->get('stripeToken');

I've removed CVC from my example.

MikeHopley's avatar
Level 17

Are the subscriptions identical -- i.e. they have the same Stripe reference number? Or are they just duplicates -- i.e. the user subscribed twice?

Hi Jekinny, I am using the Stripe Javascript. I'm using the stripe.js library to generate my token which is stored in my example as $request->get('stripeToken');

I think you missed the very important point that @jekinney was making.

Looking at your code, it seems that you are sending the credit card information to your server: $request->get('cc-number'), etc.

The credit card fields in your form should not even have a name attribute. You should ensure that the card data is never sent to your server -- not even for a single request, let alone for storage!

You need to read the Stripe documentation. Follow these instructions carefully.

shanedasilva's avatar

Ah yes, this makes sense now. I've removed everything but email and I'm getting only one of the two subscriptions now as expected. I misunderstood the use-case of the additional parameters. Thanks for the help!

Please or to participate in this conversation.