#akrabulislam
1 messages ยท Page 1 of 1 (latest)
Did you pass a customer?
From where we need to pass the customer?
You don't necessarily need to, but here https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-customer
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Recommend reading that description to understand
But int the response I can see "customer": null,
Did you read above
I read it but I am getting any clue and solution of getting the customer . The customer field should have an ID
Can you share the request id for creating the session then
where do I get the session id
Starts with cs_
You're looking at the session object right now to see customer is null right?
It should be at the top of that
okay let me check
cs_test_a1ge7t8dH42O5ZKTQXZICf0BMFvh3KGkXr0fsfc51uHOWpLTQUSr1dXGwq
Oh this is a payment link session
You have customer_creation set to if_required on the payment link
You need to set it to always
See https://stripe.com/docs/api/payment_links/payment_links/create#create_payment_link-customer_creation
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Where can I set it always , because I have created the payment link from my dashboard and use it in the frontend just
or shall I need to call this function when triggering in the payment button from the UI
Hm it doesn't look like you can set this via the dashboard
But you should be able to use this update endpoint via the api to modify that payment link to always create a customer: https://stripe.com/docs/api/payment_links/payment_links/update#update_payment_link-customer_creation
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
stripe.error.InvalidRequestError: Request req_Zb7JOoIJvEDJ7Y: No such payment link: 'https://buy.stripe.com/test_7sI6oo1R60u77e0144'
encountered this error
when trying to call the api for so that every time create a new customer
Hi ๐
The URL used in this request was /v1/payment_links/https%3A%2F%2Fbuy.stripe.com%2Ftest_7sI6oo1R60u77e0144. Can you log the URL before making the request?
def modify_payment_link(self):
try:
stripe.PaymentLink.modify(
"https://buy.stripe.com/test_7sI6oo1R60u77e0144",
active=False,
)
return wrap_response({'message': 'Updated'}, 200)
except stripe.error.StripeError as e:
# Handle any Stripe API errors here
print(f"Stripe Error: {e}")
return wrap_response({'error': e}, 500)
This is hard coded
Well that's clearly wrong. To modify the Payment Link using the Stripe client library you need to pass the ID of the Payment Link. It will start with plink_ like we show in our API reference docs https://stripe.com/docs/api/payment_links/payment_links/update
def modify_payment_link(self):
try:
stripe.PaymentLink.modify(
"plink_1NqeLUGfBsqAl5dJvyhq2fYj",
active=False,
)
return wrap_response({'message': 'Updated'}, 200)
except stripe.error.StripeError as e:
# Handle any Stripe API errors here
print(f"Stripe Error: {e}")
return wrap_response({'error': e}, 500)
stripe.error.InvalidRequestError: Request req_yZIx6pBcNBn40H: No such payment link: 'plink_1NqeLUGfBsqAl5dJvyhq2fYj'
From the documentation this is generated based on my api key so I think it should be correct. Is there a way to get this plink from my dashboard
If you go to your Stripe Dashboard you can drop the ID in the top search bar. However I don't see a payment link with that ID on my end either
Okay and you are sure this Payment Link exists? Do you have the API request that created it?
Yes I have 2 payment link . I just created one now
but why I can't see anything related to that starts with plink_
Okay what happens when you select one in particular?
Okay they make it hard to find this. I just found my own
I went to my list of Payment Links, the clicked on a single row to get to the detail page for that Payment Link. Still no ID. But at the bottonm of the detail page is a link the Request Log where I created the Payment Link. When I clicked on that I can see the API request and response when the Payment Link was created. You can find the actual ID in the Response body
Thank you I got it. And called successfully the API
Great ๐
Now the customer should be created in each checkout session and will get the customer value in the event response. Is it correct?
That depends entirely on how the Payment Link is created. If customer_creation is set to always then it will create a unique customer each time a payment is completed. https://stripe.com/docs/api/payment_links/payment_links/create?lang=python#create_payment_link-customer_creation
You can see the first customer is not guest. It has a customer id (cus_OdxEjG7vdib6QA). But when I am pay with this email in the event checkout.session.completed I am still getting the customer properly null
Can you share the event ID?
evt_3NqfMgGfBsqAl5dJ1gbyx6Kr
In the Payment Link this is set : customer_creation: "if_required",
That will not create a Customer if it isn't required
https://stripe.com/docs/api/payment_links/payment_links/update But I called this api to update it
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
import stripe
stripe.api_key = "sk_test_51NqUYyGfBsqAl5dJCdubKkssjlyHO1lfDULM84LJqkuSQXrlO0RnKmXHDbePQ13KQlrseFgVYAqcdjIKf8BaT20d00zTjMJw1Z"
stripe.PaymentLink.modify(
"plink_1NqfdkGfBsqAl5dJmTtYvmcm",
active=False,
)
I changed the key values with mine
But this call succeeded
Let me try again
GIve me a min maybe I do I thing wrong
๐ hopping in since snufkin has to head out soon - let me know when you need any more help from us
Thank you so much for the help. We were able to fix it and hopefully now we will sort it out. WIll let you know if we need any more help