#marroco0488_code

1 messages ¡ Page 1 of 1 (latest)

runic daggerBOT
#

👋 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/1222272719115256019

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

patent hedgeBOT
barren cairn
#

When you start a subscription with a trial, the first invoice that's generated is for $0

#

Hence no payment is required in that case, so there's no PaymentIntent client-secret

#

If you're trying to use the client-secret to render elements then you can use pending_setup_intent property on subscription instead

cedar forge
#

$subscription->latest_invoice->pending_setup_intent Is this how i get that?

barren cairn
#

$subscription->pending_setup_intent

cedar forge
#

thanks in that case this pending_setup_intent will go as a clientSecret? -> createPaymentCard(clientSecret) {

        if ( this.card) {
            this.card.unmount();
            this.elements=null;
        }



        this.stripe = Stripe('....');
        const appearance = {
            theme: 'stripe'
        };
        const options = {
            layout: {
                type: 'tabs',
                defaultCollapsed: false,
            }
        };



        this.elements = this.stripe.elements({  clientSecret ,appearance});
        this.card = this.elements.create('payment');
        this.card.mount('#payment-element');
barren cairn
#

you'd need to expand the pending_setup_intent parameter to see SetupIntent's client-secret

#

but yes you can use that to initialize elements

cedar forge
#

i have this error -> This property cannot be expanded (pending_setup_intent).

barren cairn
cedar forge
#

sub_1OygLqBHYS6r19T0vsPBoGpQ

#

sorry

barren cairn
cedar forge
#

req_omyXeQUZo5dUxc

barren cairn
#

which is wrong

cedar forge
#

im using the method charges->retrieve -> $subscription = $stripe->subscriptions->create([
'customer' => $customerId,
'items' => [[
'price' => 'price_1LAxd9BHYS6r19T02EhtArGq',
]],
'trial_end' => $thirtyDaysFromNow,
'payment_behavior' => 'default_incomplete',
'payment_settings' => ['save_default_payment_method' => 'on_subscription'],
'expand' => ['latest_invoice.payment_intent'],
]);

       $setupintent= $stripe->charges->retrieve(
           $subscription->id,
            ['expand' => ['pending_setup_intent']]
        );
        dd($setupintent);
barren cairn
cedar forge
#

thanks, that solve the issue