#max-orders-api

1 messages · Page 1 of 1 (latest)

last goblet
pastel mesa
#

I was looking at doing it via orders but thats depreciated
so id be wanting to get a customers latest payment
and then i could just compare the product
but i'm not entirely sure how I could do that

pastel mesa
#

So the easiest way I can think of

#

is that I just want to get payments

#

via API

#

because if i could get the data from this screen I could write the code using it easily

#

Is this possible?

last goblet
#

so let's start here, it looks like you're building a project, what APIs have you looked at right now?

pastel mesa
#

So in terms of stripe, we have the payment intents, creating customers etc

last goblet
#

and how did you come across Orders, which is deprecated correct

#

just trying to understand background/context

pastel mesa
#

For sure

#

So yeah we have our app setup to mainly use stripe, we create customers, have a static single product avaliable at a given time (set by us in the dashboard)

#

and then when our aws lambda function is triggered

#

We charge the user that triggered the lambda function for the set product

#

the issue is that the user can trigger that lambda function multiple times which we want to prevent - as the product is limited one time purchase per customer

#

so the issue we're facing is we need to make sure the user hasnt purchased that product before charging them in the lambda function

#

I found some similar work done online using orders, but yeah thats deprecated and i'm not sure that using legacy code like that is the best plan forward as we plan to go quite far with this app

#

So my thinking was - if i could get a list of a customers payments, then I could check that their latest payment isn't for our current product (eg. if they had tried to order it twice, the second time the lambda function would run it would check and see their latest payment was for our current product and the purchase wouldn't go through)

#

Like on this page of the dashboard where we can see payments for a specific user

last goblet
#

thats deprecated and i'm not sure that using legacy code like that is the best plan forward
so first off, yes that is right

I'm guessing you have no database or concept of "state" in your lambda? typically this is solved by just recording on your end whether a Customer has paid for something once and validating that, and only trying to create a payment if they have not

pastel mesa
#

Yeah you're correct we don't - that's a step I could see being used but

#

due to our business plan - we would have 3-4 different "sales" happen during a week and want the app to be easily maintainable, which would mean we would have to have the database be cleared or reset after each product was avaliable

#

an option for sure but - using stripe the way I was hoping would save that work if it was possible

last goblet
#

well this wouldn't be the right thing to expect Stripe to handle really, this would be very specific application logic in your code that works for your business specifically, so it would be on your code to handle

pastel mesa
#

For sure - no thats all right, I was just hoping I had missed something in the docs that would allow me to get payments haha

#

I appreciate all your help a lot - i'll be working on handling it on our side of things from now 🙂

last goblet
#

np all good!

#

technically (far from ideal) but you could handle it such that (your lambda) can fetch all payments on that Customer and iterate through them and only then create a Charge if needed

pastel mesa
#

How would I be able to fetch the payments on that customer - I couldn't find something similar in the docs

#

Ill present both options to team and see what works best for us

#

but that would be a valuable option depending

last goblet
pastel mesa
#

Cheers - ill work through both with our dev team

#

Fantastic support by the way - stripe is the only payment api i'll ever use, hope you have a good rest of your day mate!