#Artem3265

1 messages · Page 1 of 1 (latest)

quartz nebulaBOT
cold prawn
#

Hi
are you using Element or Checkout?

karmic pagoda
#

screenshoot to help its the flow on bubble, and the elements that i can trigger from plugin Stripe.js

#

its a element

#

where i add card details

cold prawn
karmic pagoda
#

hmm yeas, its apart, but the stripe.js its and javascript element

cold prawn
#

Using StripeJs and Elements

karmic pagoda
#

just need to understand how the subscription its triggered behind, i mean it subscribe the user but dont trigger the authenthification

#

i am already read documentation , but dont understand this part:

#

When the form above has loaded, create an instance of the Payment Element and mount it to the container DOM node. In the create the subscription step, you passed the client_secret value to the frontend. Pass this value as an option when creating an instance of Elements.

#

how i can get the client_secret from subscription ?

#

i have tried to retrive subscription, and there is no client_secret

#

i can trigger the authentification with event "start payment element" but need to have client_secret

cold prawn
# karmic pagoda how i can get the client_secret from subscription ?

When you create the Susbcription. You need to expand latest_invoice.payment_intent :

const subscription = await stripe.subscriptions.create({
      customer: customerId,
      items: [{
        price: priceId,
      }],
      payment_behavior: 'default_incomplete',
      payment_settings: { save_default_payment_method: 'on_subscription' },
      expand: ['latest_invoice.payment_intent'],
    });

The client secret is at: subscription.latest_invoice.payment_intent.client_secret
https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements#create-subscription

#

I invite you to follow that guide step by step.

karmic pagoda
#

so i need to retrive the invoice from subscription, and grab the client_secret from invoice right ?

cold prawn
#

yes

karmic pagoda
#

understand

#

will try it

#

please also have another question,

#

what is the best way to charge trial period of subscription ? lets say 7 days trial its 1€

#

its create payment intent with 1€ and create subscription with 7 trial day ?

#

or add one time invoice to subscription ?

cold prawn
#

Trial are free by definition. If not you need to create a price and name it "Trial".

karmic pagoda
#

sry maybe dont explain it well

#

create a subscription with 7 days payed for 1€ and after that create a subscription billed monthly

cold prawn
karmic pagoda
#

i have checked, i have on event logs, the invoice from subscription with 0€ pass from draft to sucess and there is no client_secret

#

invoice finalized* not sucess

cold prawn
#

You need to make an API call and expand the latest_invoice.payment_intent of the subscription

karmic pagoda
#

i have tried the subscription with trial of 1 min just for test

cold prawn
#

On event you have just the root object

karmic pagoda
#

so i cant do it with retriv actions from stripe.js ?

#

it need to be an api call right ?

cold prawn
#

yes

karmic pagoda
#

understand, so need to retrive subscription trought API call and search for " latest_invoice.payment_intent " and inside its client_secret to create payment with authentification

cold prawn
karmic pagoda
#

understand, will try it

#

thanks you for your time

#

best regards

cold prawn
#

Np! have a great day!

karmic pagoda
#

have a good day