#miked_code

1 messages ยท Page 1 of 1 (latest)

slender bridgeBOT
#

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

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

trail crag
twin rover
#

At a high level, you'll use the Subscription's underlying PaymentIntent or SetupIntent to collect the payment method, and you wouldn't use stripe.PaymentMethod.create

trail crag
#

I did look at that link but it takes me down a path which doesn't fit my needs. Essentially my system is an information management system for chemicals. If you have up to 10 chemicals the entry level price is $10 per month, the next level is 100 chemicals for $20 per month and then POA. So the user gets a to play with a couple of chemicals before automatically being shown the Stripe payment button for an automatic 10 chemicals subscription. If they get to 11 chemicals they get a second look at the Stripe payment button for the $20 per month subscription. Paying the money causes my system to generate a token for the number of chemicals they subscribe for.

twin rover
#

i'm a bit confused, what specifically doesn't fit your needs? Since you mentioned, if you have up to 10 chemicals, the entry price is $10 per month, wouldn't that mean a customer would pay $10 upon initial subscription?

trail crag
#

Yes - and that works.

twin rover
#

alright, maybe you can share more on which specific bit doesn't work

trail crag
#

I should have said that did work as a straight payment and if I revert my code it would still work. However, to make that a recurring monthly payment I need to trigger Stripe to recognise it as a subscription. For that I wrote the code in the file I uploaded. It is called by my payment_view and now I look at that I see where I might be going off the rails. Here is a snippet ...

                        charge = stripe.Charge.create(
                            amount=int(
                                cents * round(
                                    float(fee + gst),
                                    rnd,
                                )
                            ),
                            currency=curr.code,
                            description=stripe_desc,
                            source=customer_id,
                        )
#

Let me paste that again ...

    amount=int(
        cents * round(
            float(fee + gst),
            rnd,
        )
    ),
    currency=curr.code,
    description=stripe_desc,
    source=customer_id,
)
#

Perhaps that should be charge = stripe.Subscription.create

twin rover
#

So Charges are a legacy API and you should really be migrating off it. I would suggest that you don't try to think of a 1 -> 1 migration (it'll just be really confusing), but rather how to implement what you want with reference to the guide that I shared

trail crag
#

Except that all my code needs to look the same to the user and it means a complete rewrite of the UI

twin rover
#

what does all your code needs to look the same to the user mean?

#

how are you collecting payment details right now from your user?

trail crag
#

Sadly, I'm recently saddled with a full-time carer role for my disabled wife and I don't get much brainspace nowadays.

#

I'll re-read that guide

twin rover
#

sure, feel free to reach out again if you have more questions.

If you want everything to be similar, for this bit If they get to 11 chemicals they get a second look at the Stripe payment button for the $20 per month subscription. - I would envision that your button would trigger a request to update the Subscription. (https://docs.stripe.com/billing/subscriptions/pending-updates)

I would actually suggest considering a tiered pricing model instead : https://docs.stripe.com/products-prices/pricing-models#tiered-pricing

Learn how to handle payment failures when updating subscriptions.

Learn about common pricing models and how to create them.

trail crag
#

A quick look at the guide tells me I already collect all the necessary data and all I have to do is make the right calls at the right time. Previously when I saw Stripe-hosted pages I just looked away.

twin rover
#

there are different tabs there for different integrations

trail crag
#

Your documentation is so voluminous it boggles my mind. I suggest a simple mechanism to help idiots like me would be to give each set of documentation a background colour (or background pattern for the colour-blind) so the "legacy" documentation looked different than the recommended docs. The same might apply to the different tabs there you just mentioned. Your website graphic designers need to lift their game.

twin rover
#

Appreciate the feedback, I'll pass that on!