#Timo - Payment Links
1 messages ยท Page 1 of 1 (latest)
Hello! We have the Payment Links API documented here, including Java code snippets: https://stripe.com/docs/api/payment_links/payment_links
Alright, thank you very much.
I do have a question though, I don't fully understand how I can set the price etc.
You would create a Product and Price in the Dashboard or via the API, then create a Payment Link for the Price you want to charge.
If you want to do this in code the Products API is here: https://stripe.com/docs/api/products
And the Prices API is here: https://stripe.com/docs/api/prices
So something like this should work?
List<Object> lineItems = new ArrayList<>();
Map<String, Object> product = new HashMap<>();
product.put("price", "price_1Khgp6JxcER6HYwj81XXMDgN");
product.put("quantity", 1);
lineItems.add(product);
Map<String, Object> params = new HashMap<>();
params.put("line_items", lineItems);
try {
PaymentLink paymentLink = PaymentLink.create(params);
Client.send(paymentLink.getUrl());
} catch (StripeException e) {
e.printStackTrace();
}```
My Java's pretty rusty, but I think that's the general idea, yep!
and that will generate something like https://buy.stripe.com/uniqueidfortheclient?
And then I can retrieve that link and check if the client has paid, if so give him the product?
It's a unique ID for the Payment Link, which is not unique to the specific client.
Payment Links are designed to be reused over and over again by many different customers.
No but I mean, if I generate one for every client I can retrieve if he has paid?
Can you describe what you're trying to build at a high level so I can make sure Payment Links are the best option for you?
By client do you mean your customer?
Yea
I am trying to make a payment system in a minecraft plugin itself. So if a player/customer tries to buys something, he or she will receive a payment link where he or she can pay. And then every 5 minutes, its getting all the created links, check if it is paid, if so, give the player their ranks, if not, cancel/delete the link.
It sounds like Checkout Sessions are a better fit for your use case: https://stripe.com/docs/api/checkout/sessions
Does that generate links as well?
Payment Links are intended to be create-once-use-many-times, which is not what you're describing. Checkout Sessions, on the other hand, are specific to a single customer and transaction, they expire on their own, and they generate a unique URL for each one.
Alright, thanks for your help. I appreciate it.
Have a look at the quickstart here: https://stripe.com/docs/checkout/quickstart
And for the fulfilment piece I strongly recommend you use webhooks instead of polling Stripe. See here for details: https://stripe.com/docs/payments/checkout/fulfill-orders
Whats the difference?
I recommend reading through the guides I linked you to, which will explain how it all works, then come back here and ask us questions if you have any. ๐
๐