How to get subscription_id or customer_id #4572
-
Hey Polar Team, I am experimenting with using polar instead of stripe to subscribe to premium account in my apps (create checkout, bind my user with polar's user, be able to check if they are subscribed), but I find it bit puzzling how to proceed after creating checkout. So I wanted to create checkout from my python code, checkout is done for monthly recurring product, so I assumed there will be some generated I love how simple polar is for setting up shop, but it would greatly benefit if there would be more examples how to interface with it on more programmatic way. Without having id to check if my user is subscribed I have no idea what features I can offer them on my app. Here goes my sample: import polar_sdk
from polar_sdk import Polar
from polar_sdk.models import CheckoutStatus
with Polar(
server= 'sandbox',
access_token="polar_pat_MY_SANDBOX_TOKEN",
) as s:
res = s.checkouts.custom.create(request={
"payment_processor": polar_sdk.CheckoutProductCreatePaymentProcessor.STRIPE,
"product_id": "product_id_subscription",
})
if res is not None:
# handle response
print("id: ",res.id)
print("customer_id: ",res.customer_id)
print("url: ",res.url)
print("subscription_id: ",res.subscription_id)
while True:
# handle items
res_2 = s.checkouts.custom.get(id=res.id)
if res_2.status == CheckoutStatus.SUCCEEDED:
print(res_2.status)
print(res_2.subscription_id)
break Output of this code looks like this:
It would be great to have examples for those most common things - like checkout pipeline etc. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hey @PeterWaIIace. Great feedback and writing more guides and examples is definitely something we're going to do. We've done quite a few for TypeScript though in the meantime. I'd look at this example in particular: Our recommended solution here is to use In addition, we're working on enhanced Customer Management & APIs and will offer a more thorough customer model automatically too, but until then and even after then, I'd recommend passing your own I hope that answers the question/issue? |
Beta Was this translation helpful? Give feedback.
-
Transfering this in discussions |
Beta Was this translation helpful? Give feedback.
Hey @PeterWaIIace. Great feedback and writing more guides and examples is definitely something we're going to do. We've done quite a few for TypeScript though in the meantime.
I'd look at this example in particular:
https://docs.polar.sh/developers/guides/node#reconciliation-with-your-app
Our recommended solution here is to use
metadata
(JSON) in the creation of a checkout session. You can then insert the user_id on your end and the future order and webhooks associated with purchases via that checkout will contain the fullmetadata
object, i.e your services user_id.In addition, we're working on enhanced Customer Management & APIs and will offer a more thorough customer model automaticall…