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

Reached's avatar
Level 11

Attach metadata to cashier subscription

Hi guys,

Im trying to add some metadata to my cashier subscriptions, the subscription is successful however nothing is added to the Stripe customer object, what am I doing wrong here?

$user->newSubscription('main', $chosenPlan)->create($creditCardToken, [
            'metadata' => [
                'id' => $user->id,
                'email' => $user->email,
                'name' => $user->name
            ]
        ]);
0 likes
5 replies
Mick79's avatar

@tomfordweb Could you show an example of how to add metadata when my call looks like this?

$user->newSubscription('main', 'sbus')->create($token);

would be much appreciated.

junaid's avatar

For those who are still searching:

$user->newSubscription($user->id . '_' . $property->id, 'default')
     ->trialDays($trial)
     ->withMetadata(['property_id' => $property->id])
     ->add(); 
3 likes

Please or to participate in this conversation.