#Dooing
1 messages ยท Page 1 of 1 (latest)
Hello ๐
We have a guide here that explains how you can use it with Checkout, Payment Links, Subscriptions etc
https://stripe.com/docs/products-prices/getting-started#use-products-and-prices
well
I dont need a subscriptuon
and payment links... not sure what they are.. but they sound like not what U need
what I need
so what is checkout?
is that the buy once thingy?
Checkout offers stripe hosted payment page where customers can put in their information and pay
https://stripe.com/docs/payments/checkout
, hosted on Stripe.
no
I want this hosted in our app
so in our app, I want to button - e.g. buy a one hour consultation
then I want the customer to confirm the payment with 3D secure, using their alreadt existing credit card
(default card)
Then you can create invoices for the prices
https://stripe.com/docs/invoicing/integration#create-invoice-code
I dont follow
you mean, by creating an invoice, the customer technically buys / pays it?
so if you do want to utilize the price object then your options are as mentioned here
https://stripe.com/docs/products-prices/getting-started#use-products-and-prices
If you don't want to use the price object then you can use the custom payment flow
https://stripe.com/docs/payments/accept-a-payment
https://stripe.com/docs/payments/save-and-reuse?platform=web#charge-saved-payment-method
but this api asks for the invoice id..
thats weird... as I am just creating it
Not sure I follow
no I want the price object
I was just asking that it asks me to put an invoice id also
anyway I wrote now:
.builder()
.setCustomer(stripeCustomerId)
.setCollectionMethod(InvoiceCreateParams.CollectionMethod.CHARGE_AUTOMATICALLY)
.setDaysUntilDue(0L)
.build();
--
would that mean - charge - NOW
and how to add 3Dsecure to that.. I assume with a payment intent?
.addExpand("latest_invoice.payment_intent")
.build();
Invoice invoice = Invoice.create(params);
String clientSecret = invoice
.getPaymentIntentObject()
.getClientSecret();
myabe like that?
????
hello world?
Ah, sorry for the delay! I'm catching up on your question since my colleague had to step away
Taking a step back here to make sure I understand the question
You want to add a payment flow to your website to allow customers to complete a one-time purchase. Do you want to charge them immediately, or just store their payment details and create a charge at a later time?
the payment details were stored earlier
for a subscription
now they want to buy a cherry on the cake ๐
so I guess ideally, they would charged just in time when clicking the BUY NOW button
with their already existing default card
but 3d secure.. so I assume I need to send back a payment intent secret to the frontend?
or would hte frontend initiate all of this and the backend would JUST create a payment intent secret for confirmation?
Ah I see
and?
I think you can handle this a few ways. You can add a one-time item to the subscription, which will be included in their next invoice: https://support.stripe.com/questions/how-to-add-one-time-items-to-invoices-and-subscriptions-in-the-dashboard
You can create a separate invoice and use the previously-saved payment payment method (from the subscription) and charge them immediately
what if there is no next invoice becasue they would cancel earlier.. then this could be a problem, I assume
You can create a separate invoice and use the previously-saved payment payment method (from the subscription) and charge them immediately
I assumer thats what I did above
still my question, how to create the payment intent, which, as I assume, I would need... can I create it as an extension in the same call?
You can create the PaymentIntent server side, using the customer's existing payment_method
the question is how to combine the request for minimal number of requests.
based on this, I have now created that:
public void oneTimePayment(String stripeCustomerId, String stripePriceId) {
try {
InvoiceCreateParams params = InvoiceCreateParams.builder()
.setCustomer(stripeCustomerId)
.setCollectionMethod(InvoiceCreateParams.CollectionMethod.CHARGE_AUTOMATICALLY)
.setDaysUntilDue(0L)
.addExpand("latest_invoice.payment_intent")
.build();
Invoice invoice = Invoice.create(params, requestOptions);
InvoiceItemCreateParams invoiceItemParams = InvoiceItemCreateParams.builder()
.setCustomer(stripeCustomerId)
.setPrice(stripePriceId)
.setInvoice(invoice.getId())
.build();
InvoiceItem.create(invoiceItemParams, requestOptions);
InvoiceSendInvoiceParams invoiceSendInvoiceParams = InvoiceSendInvoiceParams.builder()
.build();
invoice.sendInvoice(invoiceSendInvoiceParams, requestOptions);
} catch (StripeException e) {
throw new StripeExternalException(e);
}
so it seems, for the whole thing I do not need 1, but actually 3 requests already
now where of these 3 requests can I add my
.addExpand("latest_invoice.payment_intent")
so that I retrieve the secret for the client / frontend payment 3dSecure confirmtion?
And the order - is it actually - backend creates the invoice and the secret, or should the client / frontend create the invoice and then the backend only create the secret.. ?? I assume the first, as only the backend would have the right stripe price id in its database
reading up and answering, one sec
if you're /send sending the Invoice, why would you want the client_secret on the frontend? Sending Invoices means the Invoice is emailed to the end Customer so they can pay from their email inbox (just clarifying that part)
and answering each of your questions:
so it seems, for the whole thing I do not need 1, but actually 3 requests already
yes this is expected, you're
a// creating an Invoice
b/ adding an InvoiceItem to the Invoice
c/ sending the Invoice
these are 3 distinct requests, you can't batch them up in 1
now where of these 3 requests can I add my
.addExpand("latest_invoice.payment_intent")
You don't add that expand
You just do
.addExpand("payment_intent")
You don't need the latest_invoice part there
and you add it to
a// creating an Invoice
or
c/ sending the Invoice
is it actually - backend creates the invoice and the secret, or should the client / frontend create the invoice and then the backend only create the secret.. ??
Backend creates the Invoice
Invoice has an underlying PaymentIntent on it automatically
Frontend only calls confirmPayment() on the PaymentIntent's client_secret
but you don't need to do the last thing necessarily since you are emailing the Invoice to the end customer