#sadeghiamir_api
1 messages ยท Page 1 of 1 (latest)
๐ 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/1340989724218888223
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
๐ happy to help
it really depends on your flow
I would suggest creating the customer object as early as possible to avoid this issue
you can also use custom idempotency keys that are derived from the customer's email perhaps so that you don't create the same customer twice
how can I do this?
current logic is:
try {
final String email = user.getEmail();
final String userId = user.getId();
log.info("user is {}", user);
CustomerSearchResult result = getStripeCustomers(user);
Customer customer;
// If no existing customer was found, create a new record
if (result.getData().isEmpty()) {
Map<String, String> metaData = new HashMap<>();
metaData.put("firebaseUID", userId);
CustomerCreateParams customerCreateParams = CustomerCreateParams.builder()
.setName(user.getFirstName())
.setEmail(email)
.setMetadata(metaData)
.build();
customer = Customer.create(customerCreateParams);
} else {
customer = result.getData().get(0);
}
return customer;
} catch (Exception ex) {
log.error("exception in search or create stripe customer {} for user id {}", ex, user.getId());
}
In my application user can update your email. thus relibale value for this purpose is id
please suggest me your idea according the id of user in my application.
the idempotency key isn't related to your customer Key but instead it defines the request you're sending
please read through the doc I sent you
and this blog post https://stripe.com/blog/idempotency to learn more about this technique
Online payment processing for internet businesses. Stripe is a suite of payment APIs that powers commerce for businesses of all sizes.