#acronie_api
1 messages ยท Page 1 of 1 (latest)
๐ 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/1229811261206696008
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi there ๐ did the customer have a value set for invoice_settings.default_payment_method when the request to create the Subscription was made?
invoice_settings.default_payment_method
No both of them have no payment method attached
^^ as seen here
That's the problem then. You can't create a Subscription unless there is a default payment method available. If there isn't one defined on the Customer object, then one needs to be provided to the Subscription creation request.
Just issued a 0$ invoice without any payment method
strange that this works ๐ค
I thought this was a bug to begin with but
this is from my production just now
Can you elaborate on what you did there?
set the quantity to 0$ for a price
try {
return ctx.prisma.$transaction(async (tx) => {
const subscription = await stripe.subscriptions.create({
customer: customer.id,
items: [
{
price: process.env.STRIPE_PER_MONTH_SUBSCRIPTION_PRICE_ID,
quantity: 0,
},
],
expand: ["latest_invoice.payment_intent"],
off_session: true,
payment_settings: {
payment_method_types: ["card"],
},
});
await tx.employer.update({
where: {
id: employer.id,
},
data: {
subscriptionIdMonthly: subscription.id,
subscriptionStatusMonthly:
subscription.status === "active"
? SubscriptionStatus.ACTIVE
: SubscriptionStatus.INACTIVE,
},
});
return {
message: "Subscribed successfully.",
};
});
} catch (e) {
throw new TRPCError({
code: "INTERNAL_SERVER_ERROR",
message: "couldn't add subscription for free'",
});
}
Sorry, I meant can you share the request you made? We aren't as familiar with the dashboard UIs, we primarily focus on helping with the API here, so I'm not able to follow those as easily.
Oh gotcha
This works right now
(in prod too)
Things are more lax when there first payment is $0.
what does that mean?
Let's take a step back, what is your desired behavior here? Maybe I can help map what we offer to that.
oh got it
I just want to hand them things for free but still have an invoice for it
and don't want them to add their payment details at time but if they have that shouldn't be an issue either
(Do I make sense)
I think I understand what you're after, but isn't that also the behavior you're seeing? You encounter an error when creating a Subscription that requires payment, but don't encounter an error when creating a free Subscription? Sorry if I'm not parsing this right yet.
but don't encounter an error when creating a free Subscription
yea soooo
0$ invoice = free sub right? And no payment method required
req_MS0lKai5ayo45x have a look at this
{
"expand": {
"0": "latest_invoice.payment_intent"
},
"off_session": "true",
"items": {
"0": {
"quantity": "0",
"price": "price_1OvCLaSIyQodp0OwC3ybuAtW"
}
},
"customer": "cus_Pw0JDpMtRxRgcP"
}```
0$ and should be free essentially but json "code": "resource_missing",
Looking
While I do, do you have the request where you were able to create a $0 Invoice without error that you can share as well?
Hm, I'm not readily spotting the difference here. Still looking.
sure you can ping me if you need my help ๐
I have a theory. The Customer from this request has a pending Invoice Item that was created for them which hasn't been pulled into an Invoice yet. I'm pretty sure your request to create a Subscription is trying to pull in that pending Invoice Item, leading to the first Invoice for that Subscription to not be free.
https://dashboard.stripe.com/test/logs/req_jqysOJsr0zXm2S
cus_Pw5yMZaELFSmzm same happens with this tho
oh nvm it doesn't
strange is there anyway I can avoid it?
can confirm this theory is true
I was just double checking whether you can create a Subscription and tell it to ignore pending Invoice Items, but am not seeing a way to do so. I believe you would need to either collect a Payment Method to be ready to handle the cost associated with the pending Invoice Item. Alternatively you might build logic to look for pending Invoice Items for a customer before creating a Subscription, deleting them, creating your Subscription, and then recreating any deleted Invoice Items you still need.
Alternatively you might build logic to look for pending Invoice Items for a customer before creating a Subscription, deleting them, creating your Subscription, and then recreating any deleted Invoice Items you still need.
yea something like that maybe
this is admin dashboard so I can just throw an errorr with "pending unpaid invoice" message too
Thanks for the help!