#neha_api
1 messages ¡ Page 1 of 1 (latest)
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.
- neha_subscription-events, 5 hours ago, 62 messages
- neha_api, 6 hours ago, 38 messages
- neha_upcoming-prorationdate, 9 hours ago, 48 messages
- neha_best-practices, 3 days ago, 15 messages
- neha_docs, 3 days ago, 25 messages
- neha_best-practices, 3 days ago, 110 messages
and 4 more
đ 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/1216945860143743068
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
hi again
here's what i'm trying to do (this is my own custom ui)
i want pending_if_incomplete because i don't want to authorize the user till payment goes through
but i also want them to be able to pass in a promo code
i understand that i can check the "pending_update" of the updated subscription to ensure it went through
but when/how do i pass the promo code?
subscriptionId,
{
items: [{ id: subscription.items.data[0].id, price: nextPriceId }],
proration_behavior: "always_invoice",
payment_behavior: "pending_if_incomplete",
proration_date: subscription.current_period_start,
promotion_code: promoCodeId,
},
);```
hello! like what the error message mentions, you can't use pending_if_incomplete with promotion_code. There are limited attributes that pending_update supports.
If the pending_update feature doesn't support that attribute, you will need to implement the feature on your own to save the current subscription "setting" and be ready to rollback if the payment fails
well i use the following webhooks to provision access:
subscription.created, subscription.updated, invoice.paid
and the following to restrict access:
subscription.deleted, invoice.payment_failed
if i omit "pending if incomplete"
it's possible that these webhooks would be called as if the subscription payment went through ?
(also, how does the customer portal handle this?)
you can test things out and see how it works. At the very least, subscription.updated will be called
is there anything i can do with the subscription.invoice after i update the subscription ^
I'm not sure I understand? You need to let me know what do you want to do with it. I wouldn't know what you would want to do with it
what has that got to do with the event?
like could i do
subscriptionId,
{
items: [{ id: subscription.items.data[0].id, price: nextPriceId }],
proration_behavior: "always_invoice",
payment_behavior: "pending_if_incomplete",
proration_date: subscription.current_period_start,
},
);```
const invoice = getInvoice(newSusbcription.latestInvoiceId); // psuedo code
invoice.addPromoCode(promoCode);
or
okay, so if you try running that, what do you get?
one sec
trying this
const newSubscription = await this.stripe.subscriptions.update(
subscriptionId,
{
items: [{ id: subscription.items.data[0].id, price: nextPriceId }],
proration_behavior: "always_invoice",
payment_behavior: "pending_if_incomplete",
proration_date: subscription.current_period_start,
},
);
if (typeof newSubscription.latest_invoice === "string") {
this.stripe.invoices.update(newSubscription.latest_invoice, {
discounts: [{ discount: promoCodeId }],
});
}
nope didn't work
is there a reason why you can't apply the promotion code first, then apply the pending_update?
what if the promo code applies to the new product but not the old product
does the customer portal use "pending_if_incomplete" or was it using "allow_if_incomplete"
Use allow_incomplete to transition the subscription to status=past_due if a payment is required but cannot be paid.
Use pending_if_incomplete to update the subscription using pending updates.
By default, updates are applied regardless of whether payment on the new invoice succeeds. If payment fails, rolling back the updates is a manual process. You need to create a new invoice, prorate items on the invoice, and then initiate payment again.
does this mean if i did allow_incomplete, the subscription would "update" but be "past_due"? in the event of a payment failure
whatever the customer portal's behavior was, i am fine with it
ok nvm
ignore all that
i just tried w/o pending updates and it's not what i want
maybe i can update the customer w/ the coupon
then process the sub update
then remove it from the customer?
If you provide a coupon code, the customer will have a discount applied on all recurring charges. Charges you create through the API will not have the discount.
you need to test it out, i won't be able to tell you off the top of my head if things will work as you expect
ok
coupon
string
If you provide a coupon code, the customer will have a discount applied on all recurring charges. Charges you create through the API will not have the discount.
so this is the promo id? the coupon id?
the promo code? it's not very clear
with regards to the coupon, you can always restrict what products it applies to
where did you see that piece of info? can you share the corresponding URL?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
that's under the promotion_code parameter - in our API docs it says
The API ID of a promotion code to apply to the customer. The customer will have a discount applied on all recurring payments. Charges you create through the API will not have the discount.
the API ID which is https://docs.stripe.com/api/promotion_codes/object#promotion_code_object-id
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.