#xxslasherboixx_code

1 messages ¡ Page 1 of 1 (latest)

mortal cargoBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1263708698358972559

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

simple gull
#

Hmm can you provide Ids to check? The Subscription Id and the Customer Portal Session Id

heavy current
#

yes it is in test mode one sec

mortal cargoBOT
heavy current
#

cus_QV5fnlu5ssNKnv

honest kayak
#

hello! That customer has no Subscriptions on it

#

are you sure you've shared the correct Customer id?

heavy current
#

hey sorry

#

cus_QV2kB9OQlWJkbp

honest kayak
#

okay, and can you share the customer portal session id too? Or can you share the request id [0] where you created the portal session for this customer? it'd look like req_xxx

[0] https://stripe.com/docs/api/request_ids

heavy current
#

lemme try to find the req_xxx

#

i don't think i have it persisted anywhere

honest kayak
heavy current
#

yes that looks like it

honest kayak
#

the customer you passed in for that request is for cus_QV73PqP58u8uz0 which has no Subscriptions on it

heavy current
#

how do i get a subscription created that will show in the customer portal?

honest kayak
#

maybe lets backtrack a bit, you're using a no code solution i.e. Payment Links to create Subscriptions for your customers. You're also depending on Stripe to create the Customer for you right?

heavy current
#

well no i wasn't, i did have some code that was creating the customer. However, I tried disabling that and using this code to create the customer but then i got an error..

public function createPaymentLink(Request $request)
{
    $organization = Organization::where('id', auth()->user()->org_id)->first();

    Stripe::setApiKey(env('STRIPE_SECRET'));

    // Create the payment link
    $paymentLink = PaymentLink::create([
        'line_items' => [
            [
                'price' => 'price_1Pe2V8B7nDl92Q4PuQiwwiPy',
                'quantity' => 1,
            ],
        ],
        'customer_creation' => 'always'
    ]);

    // Redirect to the payment link URL
    return redirect($paymentLink->url);
}
#

this is the error I received

customer_creation can only be used if the payment link does not contain any recurring prices.

#

I am trying to create a subscription so i would think I would want a recurring

honest kayak
#

You don't need to pass in customer_creation=always because it will always create a new Customer for a recurring price already

#

just omit 'customer_creation' => 'always'

heavy current
#

hmm ok and i don't need to pass a customer id or anything?

#

how does that subscription get connected and therefore shown in the no code customer portal?

honest kayak
#

you don't need to pass a customer id, but if you don't, there are some implications that you need to be aware of

heavy current
#

so you're saying to do this..

        $paymentLink = PaymentLink::create([
            'line_items' => [
                [
                    'price' => 'price_1Pe2V8B7nDl92Q4PuQiwwiPy',
                    'quantity' => 1,
                ],
            ],
            'customer' => $organization->stripe_id,
        ]);
honest kayak
#

If you don't enable this setting, and depend on Stripe to create Customers for you, you can end up with multiple Customers with the same email. Stripe does not automatically de-duplicate Customers for you

heavy current
#

thanks, im so sorry, but im still confused as to how the customer portal and the payment link become linked? so that if a subscription is started via a payment link, how does that show up in the customer portal?

honest kayak
#

gimme a few minutes, I'm getting there

#

so if a Customer who has already paid for a Subscription, enters the email that they used to make payment for the Subscription for in the Customer Portal, they will be able to access the Portal and manage their existing Subscription there

#

does that all make sense?

#

ofc, ^ means you can only have one Subscription per email. If your business allows for more than one Subscription for each email/customer. This isn't going to work

#

To directly answer your previous question, you will only see the Subscription in the portal if your Customer actually has a Subscription that they paid for. The problem is that you were creating a Customer Portal for a Customer that hasn't paid for any Subscriptions yet

heavy current
#

ok that last part makes sense.

upon the signup action i was creating the customer in stripe and was then storing that id on the org record level.

Would you advise not doing that and just getting the customer_id from the payment link when they are startin the subscription?

honest kayak
#

the first question i have is, will your business ever have more than one Subscription per Customer?

heavy current
#

no only one per customer

#

i have enabled that limit customer to 1 subscription setting

honest kayak
#

then i would say yes, it would be easier for you to get the customer's id after the payment is completed. I'll suggest you test all of this out to make sure things work as per what you expect. Since it's mostly no-code, it should be quick to get up and running. It's possible you may have some requirement which this flow can't really accommodate

honest kayak
#

yep

heavy current
#

i think i just need to update the customer creation flow, thank you so much

honest kayak
#

hopefully everything is smooth from here on! If you have more questions / issues, feel free to reach out again