#max_api

1 messages · Page 1 of 1 (latest)

novel trellisBOT
#

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

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

atomic solstice
#

👋 happy to help

alpine copper
#

Hi 🙂

atomic solstice
#

I'm not sure I understand your ask

alpine copper
#

I have a few questions. I'll start from the top:

With Stripe, we are trying to search for customer's payments using the API and matching to the customer email in our database. However, if the email entered in Stripe contains captiol letters - and those don't match the casing of the email in our system - we aren't able to find the customer with the api. Is there something else we could do here?

atomic solstice
#

yes you can have multiple options the easiest would be to check on your side by doing a "toLowerCase" on both email addresses this way you are sure to get the right match

#

another thing you can do is to add on the customer some metadata with the ID of its corresponding match in your system

#

this way you could easily map them

alpine copper
#

The problem with that approach is that it requires us to retrieve all emails from the database to our system then check locally which is more time consuming than matching directly.

How can we automatically add metadata to payments when they are made?

atomic solstice
#

How can we automatically add metadata to payments when they are made?
how are you integrating with Stripe? are you using Checkout Sessions?

alpine copper
#

Yes, using checkout sessions and also payment links

atomic solstice
#

you can set payment_intent_data.metadata on the PaymentLink/Checkout Session

#

and when you get the checkout.session.completed event you can set the metadata from the PaymentIntent on the Customer

alpine copper
#

Can we then search for entries in the database by metadata key?

atomic solstice
#

yes you can use metadata to find customers

alpine copper
#

So can I pass metadata into the payment intent (for example, email: test@gmailcom)

Then search for that payment intent by metadata? The link above is for customers, does same apply for PaymentIntents??

atomic solstice
#

yes

alpine copper
#

Ok great, I'll be back in 2 mins

atomic solstice
alpine copper
#

Looks like that'll work

#

Would that come under meta_data then?

atomic solstice
#

no

alpine copper
#

Does a payment link create a checkout session? Is that how it works?

atomic solstice
#

yes exactly

alpine copper
#

So can we search for payment_intent using the client_reference_id?

atomic solstice
#

no

#

you would have to use the checkout.session.completed event to get the client_reference_id and if you want you can then copy it to the metadata of the PaymentIntent or customer or subscription depending on what you're trying to achieve exactly

novel trellisBOT
alpine copper
#

Another thing,
When finding payments of a single email, it has multiple customer_ID’s which requires us to loop through all the customer_id’s transactions to find the payment

Is there a better way of doing this?

vast nymph
#

I wouldn't think so, it's possible for a single email to be associated with multiple Customers and each customer can have multiple payments

alpine copper
#

Ok, thanks

#

Is a checkout session created for guest checkouts in payment links?

vast nymph
#

PaymentLinks always create CheckoutSessions, that's what they are(a reusable link that creates CheckoutSessions when interacted with)

alpine copper
#

Ok thanks.

#

Another thing - is there a way to easily migrate all customers to a new subscription product?

Currently, some are on a lower subscription fee and we want to change all of those to the main subscription product. Does this need to be done manually?

vast nymph
alpine copper
#

We don't want to change the subscription product but rather the product that the members are on. For example,

We have £30 every 28 days
We have £20 every month

We want all members to be on the product £30 every 28 days

vast nymph
#

same thing, that means changing the Subscription's items to use the new Price object that is £30 every 28 days

alpine copper
#

Sorry 2 mins, just looking

#

So is a 'subscription item' a product? We have lots of products, we want to clean up by removing all that aren't £30 every 28 days. This can be done via this api?

vast nymph
#

no, those are different objects. The SubscriptionItem is the "thing" the subscription is billing for, which is a certain quantity of a certain recurring Price. A Price defines the currency amount and recurring period. The Price is connected to a Product that describes what the actual thing being sold is (i.e. the description).

alpine copper
#

So the price is the product?

It's the product we need to change

vast nymph
#

No, a Price and a Product are different things(a Product can have multiple Prices since it can be sold at different prices or at different intervals). It's the Price that a Subsctiption is subscribed to.

alpine copper
#

Can we do this in bulk or does it need to be one-by-one?

vast nymph
#

you can write a script that calls the API in a loop , for example

alpine copper
#

Sure.

vast nymph
#

like I mentioned we have this toolkit thingy released somewhat recently that is at least adjacent to this and allow for some bulk actions; I don't think it specifically addresses migrating existing subscriptions to new prices(which is indeed a common feature request and I wish I had had a better answer than just calling the API for each one), but maybe it does, I haven't played around with it at all myself https://docs.stripe.com/billing/subscriptions/import-subscriptions-toolkit

alpine copper
#

Ok, I'll take a look at that too. Thanks 🙂

#

And last thing,

Do you have any documentation that can help with the following?

  1. Best practices for creating subscription products to be used in our new app
  2. Best way to map payments such as setup-fees which have multiple possible amounts and subscriptions to a user in logged-in state in new app
#

For context, members may want to add additional features to their subscription what's the best process for this? And for one off payments too, have you got any info on best practices?

vast nymph
alpine copper
#

Ok, thanks a lot. You've been very helpful 🙂