#datter_paymentelement-subscription

1 messages ยท Page 1 of 1 (latest)

jolly quartzBOT
#

๐Ÿ‘‹ 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/1263161993175502881

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

frail seal
jolly quartzBOT
mossy mantle
#

Thanks for the info, still looking in to this. Does this happen when any payment method is selected? I am not immediately aware of when elements would attempt to confirm an intent without PM info but am looking in to it and will get back to you with what I can find

stable lava
#

datter_paymentelement-subscription

frail seal
#

FYI I have only enabled "cards"

stable lava
#

I'm taking over, I'll wait for your reply as I can't really look for the needle in the 200 lines of code

#

I think right now we need

  1. the exact error message you get
  2. what part of your code (client-side or server-side) is returning that error
  3. the exact PaymentIntent id associated with the error
frail seal
#

Thanks;

  1. "Processing error" client-side, "payment_intent_unexpected_state" with more info on the request id req_WB20yNbQuS9dQO,
    from the api logs in the stripe dashboard
  2. from stripe dashboard, but it is the client-side implementation of the pyments element that makes the confirmIntent() call
  3. pi_3Pda5RGppVLMkw060IKO9N6Z
stable lava
#

from stripe dashboard
what does that mean? the Dashboard can't really cause an error like that

frail seal
#

it isn't; the error was found in the api logs in the stripe dashboard, after investigation of the simple "processing error" stripe returns for the payments element

#

so the error is seen on req_WB20yNbQuS9dQO, where it states:
"You cannot confirm this PaymentIntent because it's missing a payment method. To confirm the PaymentIntent with cus_QUZBSIJ8ULQZPY, specify a payment method attached to this customer along with the customer ID."

stable lava
#

Okay so that happens client-side when you are confirming the PaymentIntent by calling confirmPayment()
Your code is not passing elements properly I think. You are doing const {error} = await confirmIntent({ stripeElements, clientSecret, confirmParams: ... but I think it should be const {error} = await confirmIntent({ elements: stripeElements, clientSecret, confirmParams: ...

frail seal
#

Checking now

#

doing that there are no errors, but the new customer has a new subscription assigned to it, but no payment method...

stable lava
#

It's all good, you'll get there, one step at a time. Can you share exact information what you mean by "no payment method"? If you could share the exact Subscription id and the exact Customer id I can have a look

frail seal
#

Thank you,
Subscription id: sub_1PdaZPGppVLMkw06VtjXyXlw
Customer id: cus_QUZircVMFXfRVz

stable lava
#

Damn I'm sorry I replied but in the wrong thread ๐Ÿคฆโ€โ™€๏ธ

#

Okay so that Customer is created on your server. That Subscription is created with the underlying PaymentIntent.
As far as I can tell you never confirmed that PaymentIntent client-side. So add logs before and after your confirmIntent() call to figure out what's going on

frail seal
#

Hahha it happens to the best of us!
I'll add logs before and after, run some tests and reply here when I am wiser on what is going on

stable lava
#

sounds good

frail seal
#

so i did some refactoring of the code, and it seems it never fired properly. Now however I am getting the following error as a response from Stripe running stripe.confirmPayment(): You specified "never" for fields.billing_details.name when creating the payment Element, but did not pass confirmParams.payment_method_data.billing_details.name when calling stripe.confirmPayment(). If you opt out of collecting data via the payment Element using the fields option, the data must be passed in when calling stripe.confirmPayment().
Do I need to supply a name of the customer, or am I misunderstanding something, and in any case can't it be inferred from the customer object when creating the subscription tied to that customer?

stable lava
#

If you explicitly pass never then you tell us "never collect it, I will give it to you instead" so you have to explicitly pass it

frail seal
#

okay, the reason for my setting it to "never", is that i do not want a field to appear asking for anything but the card data, since we have everything else on file in the database of the logged-in session (e.g. the user trying to subscribe).
should i pass all the details to confirmPayment (email, name, address.postalcode, address.country etc.), or can I make stripe reuse the data from the custoemr object?

stable lava
#

yes you should pass it on confirmPayment()

frail seal
#

okay, I'll try some more and get back to you ๐Ÿ™‚

#

if i set the payments element to "never" for address, i need to supply line1 and more. I have instead chosen to set address.country to "never" and supply it in confirmPayment() instead. Can I be sure stripe does not create a field for name, phone, email and the such, if that data is already created on the customer object associated with the subscription?

#

also a few questions remain:

  1. the subscirtption is now confirmed with the payment intent as expected, so that issue is resolved. now I can see, that the default payment method is not tied to the customer, just the subscription. Initially i followed Stripe's guide to create the intent before the payments element, where it successfully tied the default payment method to the customer, but now after having followed the guide to create the payments element before the intent, it no longer does.
  2. automatic tax calculation has been disabled for some reason, but I want to show the price of the subscription excl. vat taxes, and the taxes themselves on the invoice from stripe, but now it only invoices the amount without vat
stable lava
#

Can I be sure stripe does not create a field for name, phone, email and the such, if that data is already created on the customer object associated with the subscription?
no you can't be sure. We definitely do that already for payment methods that require this. Some need a name, other a full address, others an email. And PaymentElement collect what's required so it doesn't collect name or address for card.
So if you really want to avoid re-collecting you should disable them all and explicitly pass all the information on confirmPayment()

frail seal
#

roger that

#

did you see my other message? ๐Ÿ™‚

stable lava
#

yep sorry cycling through threads

#

now I can see, that the default payment method is not tied to the customer, just the subscription
yes that's expected behaviour. You configured it explicitly when you created the Subscription. We don't support automatically making the PaymentMethod the default on the Customer, it's always on that specific Subscription that you are confirming the PaymentIntent for.

#

automatic tax calculation has been disabled for some reason, but I want to show the price of the subscription excl. vat taxes, and the taxes themselves on the invoice from stripe, but now it only invoices the amount without vat
I'd need another concrete example to look at and I would need the exact code that creates the Subscription

frail seal
#
$stripe->subscriptions->create([
            'customer' => $customerId,
            'items' => [[
                'price' => $planPriceId,
            ]],
            'billing_cycle_anchor_config' => ['day_of_month' => 31],
            'proration_behavior' => 'create_prorations',
            'payment_behavior' => 'default_incomplete',
            'payment_settings' => ['save_default_payment_method' => 'on_subscription'],
            'expand' => ['latest_invoice.payment_intent', 'pending_setup_intent']
        ]);
#

thank you for your time and help. above is the code that creates the subscription

stable lava
#

okay so you didn't enable automatic tax calculation there right?

frail seal
#

sorry, it must've gotten removed when i refactored the code. Have a great rest of your day, and thanks again!