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

rchase's avatar

Integrating Affiliate program into Spark with Stripe Metadata

I can't find any info on how to submit metadata to Stripe when creating the Stripe customer.

I feel like it should be in /src/Interactions/SubscribeTeam.php

(Add ->withMetadata()) but it doesn't work

<?php

namespace Laravel\Spark\Interactions;

use Laravel\Spark\Spark;
use Illuminate\Support\Arr;
use Laravel\Spark\Contracts\Repositories\TeamRepository;
use Laravel\Spark\Events\Teams\Subscription\TeamSubscribed;
use Laravel\Spark\Contracts\Interactions\SubscribeTeam as Contract;

class SubscribeTeam implements Contract
{
    /**
     * {@inheritdoc}
     */
    public function handle($team, $plan, $fromRegistration, array $data)
    {
        $subscription = $team->newSubscription('default', $plan->id);
        $subscription->withMetadata(['property_id' => 'test']); 
0 likes
1 reply
rchase's avatar

I found out ->withMetadata does insert the meta to Stripe, but it's under the Subscription not the Customer. As far as I could find, Cashier does not support adding metadata to the Customer, so I have to hack my own API request.

Please or to participate in this conversation.