#Dooing-Subscription

1 messages ยท Page 1 of 1 (latest)

real escarp
#

Hi there, you can use subscription if the products require recurring payments.

#

Does your products need recurring payments or just one-time payments

vestal nymph
#

both

#

the customer generally wants subscriptions, but the customer can buy one time addons

#

on top

real escarp
vestal nymph
#

This is not at all helpful. I know there are different models.

#
  1. Should I create 3 products, with each having different prices? Or should I simply create 19 different products, wouldnt that be simpler?
#
  1. And how to retrieve recurring products / prices vs. one time? MaybeType Service vs Good?
real escarp
vestal nymph
#

I know I can. The question is, what is recommended. In the end, all I need is a price. So is it better to use many prices under one product, or just several products, each having one price?

#

second, I know there are recurring and one time payments. I am trying to retrieve the products / prices from the api, and I found a type parameter SERVICE vs GOOD. But I did not fine RECURRING vs. ONE_TIME. So my question is, that the one and the same, or do I need a different selector to only retrieve recurring / one time prices?

real escarp
vestal nymph
#

Thanks.

#

Is there wa way, I can retrieve the list of all products, and for each product, the list of its available prices?

#

I searched the api and tried in code, but I did not find any such option.
It seems, I can ask the price for the product it belongs to.. but I assume to make this work I'd need to add some expand?
And while this may be one possibility.. it woul dbe much better to have all products to iterate over, with their prices attached, then, the other way round...

#

(because in the ui, you'd iterate over each product, and the list its prices)

real escarp
vestal nymph
#

Are you saying, there is no other way then to call the prices api for each product, so calling the prices api multiple times?

#

Wouldnt it then be more efficent to retrieve the list of prices, and ask for the product of each price?
DO I need to add an expand?

real escarp
vestal nymph
#

yes, and how can I expand it?

rich garnet
#

expand:["data.product"]

#

For a subscription, that is currently in creation... and has a trial... can I call
.addExpand("latest_invoice.payment_intent")
on the subscription, to get the payment intent secret so the frontend can confirm a payment method added?

#

will answer that one in a sec

#

yes you can do that

vestal nymph
#

For retrieving a list of products... how can I define - get me only the RECURRING products vs get me only the one time products?

I assume:
.setType(ProductListParams.Type.SERVICE)
and .setType(ProductListParams.Type.GOODS)

?

rich garnet
#

you can't

#

ah actually you can

#

just try it in test mode, much faster than asking here.

vestal nymph
#

aaaah! So that means, at least theoretically, you could have / setup a PRODUCT, that has BOTH - recurring AND one time prices attached to it.

#

just try it in test mode, much faster than asking here
Yes /.

#

yes / no. Yes only when you know what you know ๐Ÿ™‚

#

I am in my code, and using the client library... so then I am looking for the methods... and if I dont find a method for recurring.. because I am on product not price,... then
running my not compiling code wont help either

outer night
#

Hey, taking over here. Let me know if there's any follow-up Qs I can answer!

vestal nymph
#

actually all answered.. here's a new one -
there are products and prices - in the api, I can see BOTH have metadata. In the dashboard however, I cant seem to find metadata for prices? How to add them>

outer night
vestal nymph
#

oh

#

great to know. will try. thanks.

#

weird bug TBH

#

tested

#

does not work

outer night
#

Could you describe what flow you did, and what error you got ? so that I can reproduce

vestal nymph
#

I went into the dashboard

#

created a product with a price

#

edited the price

#

no meta data existing

outer night
vestal nymph
outer night
#

This popup is for editing the price, you need to look at the page showing the details of the price

vapid crag
#

๐Ÿ‘‹ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!

vestal nymph
#

THanks Tarzan.

#

The above is closed, but we have another issue now, and perfect to talk to you.. as it is related to our last discussion.

vapid crag
#

shoot

vestal nymph
#

public SubscriptionSetupDTO setupSubscription(String stripeCustomerId, String stripePriceId, Long endOfTrialTimestamp) {
try {
SubscriptionCreateParams subCreateParams = SubscriptionCreateParams.builder()
.addItem(SubscriptionCreateParams.Item.builder()
.setPrice(stripePriceId)
.build())
.setCustomer(stripeCustomerId)
.setTrialEnd(endOfTrialTimestamp)
.setPaymentBehavior(SubscriptionCreateParams.PaymentBehavior.DEFAULT_INCOMPLETE)
.setPaymentSettings(SubscriptionCreateParams.PaymentSettings.builder()
.setSaveDefaultPaymentMethod(SubscriptionCreateParams.PaymentSettings.SaveDefaultPaymentMethod.ON_SUBSCRIPTION)
.build())
.addExpand("latest_invoice.payment_intent")
//.addExpand("pending_setup_intent")
.build();

        Subscription subscription = Subscription.create(subCreateParams, requestOptions);
        String subscriptionId = subscription.getId();
        String clientSecret = subscription.getLatestInvoiceObject()
            .getPaymentIntentObject()
            .getClientSecret();
        return SubscriptionSetupDTO.of(subscriptionId, clientSecret);
    } catch (StripeException e) {
        throw new StripeExternalException(e);
    }
}
#

this is now what we do for a subscription with a trial

#

we need the payment intent, the UI tellss us

#

but since it is a trial.. there is no payment object yet, since this is what we are trying to confirm in the first place

#

so we get a NullPointer Exception

vapid crag
#

that's why we discussed using pending_setup_intent that you commented out

vestal nymph
#

yeah we did

#

this works in the backend.

#

but it will throw an exception in the UI

#

Uncaught (in promise) IntegrationError: Invalid value for stripe.confirmCardPayment intent secret: value should be a PaymentIntent client secret. You specified: a SetupIntent client secret.

vapid crag
#

because if you do remember we've also discussed this, on the front-end you either use confirmCardPayment for PaymentIntent or confirmCardSetup for SetupIntent

vestal nymph
#

oh ok a different method

vapid crag
#

yes

vestal nymph
#

no I dont remember

vapid crag
#

no worries

vestal nymph
#

but I will forward to the UI guy ๐Ÿ˜‰

vapid crag
#

I know it's been a while since our long discussion about this

vapid crag
#

did you manage to make it work?

vestal nymph
#

I forwarded the info to the UI guy

#

and I think he is currently in his lunch break

#

the link... no idea what it si

#

is

vapid crag
#

it's our previous conversation here in discord

vestal nymph
#

not fully.. but I found th thread to click on, inside your link, ok