#Dooing

1 messages ยท Page 1 of 1 (latest)

serene bearBOT
compact perch
late bison
#

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?

compact perch
late bison
#

, 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)

compact perch
late bison
#

I dont follow

#

you mean, by creating an invoice, the customer technically buys / pays it?

compact perch
#

yup

#

PaymentIntents don't take in price objects as a parameter

late bison
#

but this api asks for the invoice id..

#

thats weird... as I am just creating it

compact perch
#

but this api asks for the invoice id..
thats weird... as I am just creating it
Not sure I follow

late bison
#

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?

tame sorrel
#

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?

late bison
#

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?

tame sorrel
#

Ah I see

late bison
#

and?

tame sorrel
#

You can create a separate invoice and use the previously-saved payment payment method (from the subscription) and charge them immediately

late bison
#

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?

tame sorrel
#

You can create the PaymentIntent server side, using the customer's existing payment_method

late bison
#

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

fossil summit
#

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

late bison
#

THanks

#

this is super helpful

#

waitinf for hour here, you are the first one to fully and properly answering my questions, thank you!