#iwynos_adi

1 messages ยท Page 1 of 1 (latest)

bold wadiBOT
river pumice
#

So you can use that intent to save your user's payment info

vernal monolith
#

our goal is to get the user to provide their payment info at time of creating the subscription even if there is a free trial period we are offering

versed flare
#

``$subs_obj = $stripe->subscriptions->create([
'customer' => $stripe_cust_id,

            'items' => [
                [
                'price_data' => [
                    'unit_amount' => $transaction_amt* 100, //usd to cent
                    'currency' => $transaction_currency,
                    'product' => $transaction_pro,   //'prod_ODkeMOLt9GkaPZ'
                    'recurring' => ['interval' => $transaction_period], //'month'
                    ],
                ],
              
            ],
            
            
            'payment_behavior' => 'default_incomplete',
            'payment_settings' => ['save_default_payment_method' => 'on_subscription'],
            ]);


        $client_secret_key =  $stripe->subscriptions->retrieve(
            $subs_obj->id,
            ['expand' => ['latest_invoice.payment_intent']]
        )->latest_invoice->payment_intent->client_secret;``
vernal monolith
#

see the code above @river pumice please

versed flare
#

This is what I use to get client_secret_key when there there is no need of a trail period

river pumice
#

Yep, it looks like what I said was relevant

#

You are trying to access a payment intent that does not exist

versed flare
#

Will the client_secret inside the pending_setup_intent will work( which i got after expanding pending_setup_intent)

river pumice
#

Yes, though your client will likely have to make a slightly different call than it is currently making

#

Like if you are using confirmPayment on the client you will need to use confirmSetup instead

versed flare
#

Can you help me with sample code or a supporting doc for the same

river pumice
versed flare
#

This is what I am getting when I expand pending_setup_intent
But I am unable to extract client_secret

river pumice
#

The 6th property listed in that screenshot is the client_secret, you should be able to use it as normal

bold wadiBOT
versed flare
#

I am not able to extract client_secret help me out

plucky stratus
#

๐Ÿ‘‹ When you say not able to, are you seeing an error or something else? More details would help

versed flare
#

It gives me a null value

                $subs_obj->id,
                ['expand' => ['pending_setup_intent']]
            );
      return $stripe_json->pending_setup_intent->client_secret; ```
plucky stratus
#

Try printing $stripe_json , does pending_setup_intent exist there?

versed flare
#

Yes

plucky stratus
#

what happens if you print out $stripe_json -> pending_setup_intent

Are you seeing an obiect?

versed flare
#

Yes

plucky stratus
#

Try printing out the whole string before you return it
$stripe_json->pending_setup_intent->client_secret

versed flare
#

returns null

plucky stratus
#

how about $stripe_json->pending_setup_intent->id?

versed flare
#

same it also returns me null

fading plank
#

๐Ÿ‘‹ stepping in

#

Can you hardcode in your Subscription ID for one test?

versed flare
#

One sec

fading plank
versed flare
#

Where I can see the subscription list which has been setup under the trail period

#

?

fading plank
#

Not sure what you mean by that exactly

#

You want to see your trialing Subscriptions in the Dashboard?

versed flare
#

yes

fading plank