#jacques_best-practices

1 messages ยท Page 1 of 1 (latest)

rain stratusBOT
#

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

๐Ÿ“ 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.

steel vault
#

hi! I don't 100% understand what you're asking, could you rephrase it slightly?

rain stratusBOT
rotund berry
#

I currently have a backoffice api whose purpose is to make database modifications and create subscriptions.

Currently, when we finish creating the sub, I check the status of the sub and according, I make changes in the database, however, when the change fails on our side, we reroll our changes in the database, however the subscription stripe will always be the same.

Here's the code below

if (moment(startDate, "DD/MM/YYYY").isSameOrBefore(moment(today, "DD/MM/YYYY"))) {
            // create stripe subscription
            stripeSubscription = await stripe.createSubscription(user.rk_pspCustomerId, stripePrice.id, stripeUserPaymentMethod.toString(), stripeMetadata);
        } else if (moment(startDate, "DD/MM/YYYY").isAfter(moment(today, "DD/MM/YYYY"))) {
            // create stripe subscription schedule
            stripeSubscription = await stripe.createSubscriptionSchedule(user.rk_pspCustomerId, stripeUserPaymentMethod.toString(), stripePrice.id, stripeMetadata, moment(startDate, "DD/MM/YYYY").unix());
        }
        // check subscription status
        switch (stripeSubscription?.status) {
            case "active":
                // update contract status
                // update subscripton status
                // update user status
                break;
            case "not_started":
                // update contract status
                // update subscripton status
                // update user status
                break;
            case "incomplete":
                throw new Error(`Stripe subscription status is ${stripeSubscription?.status}`);
            default:
                throw new Error(`Could not create subscription in stripe, subscription status is ${stripeSubscription?.status}`);
        }
#

But I think that if the stripe side is successful, then if we make changes at home, we won't rollback so as not to lose the data at home.

weary jewel
#

๐Ÿ‘‹ stepping in

#

Sorry, I still don't understand what the question is here...

#

Is there something we can help you with?

rotund berry
#

I think we've found a way on our side after all.

weary jewel
#

Okay sounds good! Do let us know if we can help.