#ethan_api

1 messages ยท Page 1 of 1 (latest)

hallow groveBOT
#

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

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

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

astral nacelle
#

Code for creating subscription:

const subscription = await stripe.subscriptions.create({
  customer: customerId,
  items: [
    {
      price: priceId,
      quantity: seatCount,
    },
  ],
  payment_behavior: 'default_incomplete',
  payment_settings: { save_default_payment_method: 'on_subscription' },
  expand: ['latest_invoice.confirmation_secret'],
});

Error:

{
  "error": {
    "code": "resource_missing",
    "doc_url": "https://stripe.com/docs/error-codes/resource-missing",
    "message": "This customer has no attached payment source or default payment method. Please consider adding a default payment method. For more information, visit https://stripe.com/docs/billing/subscriptions/payment-methods-setting#payment-method-priority.",
    "request_log_url": "https://dashboard.stripe.com/test/logs/req_HfDxGRNk1qK22K?t=1750306263",
    "type": "invalid_request_error"
  }
}

Request body according to Workbench - note missing payment_behaviour: "default_incomplete"

{
  "collection_method": "charge_automatically",
  "customer": "cus_SWbZYus5zJsfdG",
  "items": {
    "0": {
      "price": "price_1RTb4Y4COiNjImo6sRG82E3F",
      "quantity": "4"
    }
  }
}
unreal orchid
astral nacelle
#

I'm not specifying collection method though, and the default is charge_automatically correct?

#

So shouldn't it just create the subscription with status=incomplete?

unreal orchid
#

Yes, the default is charge_automatically

astral nacelle
unreal orchid
unreal orchid
#

Ok, so I just went through the process and I was not able to replicate your issue. This is what I used on my end:

      const subscription = await stripe.subscriptions.create({
        customer: 'cus_SWe7O4z31Vpf2B',
        items: [
          {
            price: 'price_1RbazQQKdNnoI2anyOi1Jfff',
          },
        ],
        metadata: {
          description: "This is a subscription that was created via the API (https://docs.stripe.com/api/subscriptions/create)"
        },
        payment_behavior: 'default_incomplete',
        //expand: ['latest_invoice.payment_intent'],
        expand: ['latest_invoice.confirmation_secret']
      });
#

And this is the request body per workbench

{
  "customer": "cus_SWe7O4z31Vpf2B",
  "expand": {
    "0": "latest_invoice.confirmation_secret"
  },
  "items": {
    "0": {
      "price": "price_1RbazQQKdNnoI2anyOi1Jfff"
    }
  },
  "metadata": {
    "description": "This is a subscription that was created via the API (https://docs.stripe.com/api/subscriptions/create)"
  },
  "payment_behavior": "default_incomplete"
}
astral nacelle
#

And your customer has no payment methods associated with them?

unreal orchid
#

None

#

I recommend double checking your code, because it appears the following did not make it's way into the request that you sent:

  payment_behavior: 'default_incomplete',
  expand: ['latest_invoice.confirmation_secret'],
astral nacelle
#

Yeah I'm aware ๐Ÿค”

#

Why would that be??

#
const subscription = await stripe.subscriptions.create({
  customer: customerId,
  items: [
    {
      price: priceId,
      quantity: seatCount,
    },
  ],
  payment_behavior: 'default_incomplete',
  payment_settings: { save_default_payment_method: 'on_subscription' },
  expand: ['latest_invoice.confirmation_secret'],
});

This is my actual code haha

#

nothing omitted or added here

unreal orchid
#

How are you sending the request?

astral nacelle
#

Via a firebase function running in the firebase emulator

#

Which may have just given me a clue

#

Give me 5 minutes I'll check that it's building correctly etc

unreal orchid
#

Sounds good.

astral nacelle
#

Ah that was it haha

#

Dunno what happened but resetting my functions build dir fixed it

#

It's always the things you don't think to check ๐Ÿ˜…

unreal orchid
#

Hahahaha. Glad that resolved it.

astral nacelle
#

๐Ÿคฆโ€โ™‚๏ธ sorry for wasting your time haha

#

But thank you for your help