#pocketcolin

1 messages · Page 1 of 1 (latest)

worthy mistBOT
sacred marten
#

Hello, looking in to this, and just to confirm, you are creating the Invoice and then calling this on the client secret from the Invoice's PaymentIntent?

    elements,
    confirmParams: {
      // Make sure to change this to your payment completion page
      return_url: "http://localhost:4242/checkout.html",
      receipt_email: emailAddress,
    },
  });```
worthy mistBOT
clear ether
#
    elements,
    clientSecret: clientSecret,
    confirmParams: {
        return_url: `${window.location.href}`,
    },
    redirect: 'if_required',
})```
yep
#

at least pretty close

#

when I add the element to the page, I am setting mode: "subscription" . Would that cause an issue since this isn't a subscription purchase?

#

Interesting... if I change the mode to payment I get the following error instead:

#

so it seems like I need to set automatic_payment_methods: true but again not sure how to do that when creating an invoice.

sacred marten
#

Is there a specifc file that you got from the custom payment flow where it said to specify mode: 'subscription? As far as I know that is a setting is for a different flow than the one that you linked to

clear ether
#

yeah no you can ignore that. The current integration was for a subscription purchase and I'm reusing the same elements. I can change the mode to whatever we want.

#

creating the element:

const elements = stripe.elements({
    mode: 'payment',
    amount: planAmount,
    currency: 'usd',
    appearance,
})
sacred marten
#

If you aren't using that flow, I don't think you need to do those settings at all

clear ether
#

you mean the mode, amount, currency settings when initializing the element?

sacred marten
#

Yes, that is only needed for the other flow, if you are initializing the element with the intent from the invoice, you do not need to make thse settings

clear ether
#

ohhh

#

well wait I am not initializing the element with the intent from the invoice. I'm initializing the element before I have any intent or invoice.

#

I'm confirming payment with the intent

#

(with the client secret)

#

My flow:

  1. Initialize Stripe elements
  2. When user submits form, request client secret from server
  3. Server generates invoice and invoice item and finalizes invoice
  4. Server returns client secret from Payment Intent on the finalized Invoice
  5. Client runs confirmPayment with the client secret to process the payment
unborn stag
#

👋 stepping in as Pompey needs to step away

#

Sounds like you are having an issue with combining the deferred intent flow with creating one-off Invoices? Is that correct?

clear ether
#

yess I believe that sums it up?