#iamdinesh_error

1 messages ยท Page 1 of 1 (latest)

grizzled flickerBOT
#

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

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

kindred musk
#

Here is my complete code

customer_id = self._get_company_customer(company)

if payment_method_id:
    extra = {}
        if account_id:
            extra["stripe_account"] = account_id

        try:
            pm = stripe.PaymentMethod.attach(
                payment_method_id,
                customer=customer_id,
                **extra,
            )
            
            stripe.Customer.modify(
                customer_id,
                invoice_settings={
                    'default_payment_method': pm.id,
                },
                **extra
            )
            
        except stripe.error.StripeError as e:
            raise CustomException.raise_error(e.user_message, status_code=400)
        except Exception as e:
            raise CustomException.raise_error(str(e), status_code=400)

frequency = "month"

product = stripe.Product.create(
    name=description,
    description=description,
    **product_extra
)

request_data = {
    "customer": customer_id,
    "items": [
        {
            'price_data': {
                "currency": currency,
                "product": product.id,
                "recurring": {
                    "interval": frequency,
                    "interval_count":  1
                },
                "unit_amount": amount
            }
        }
    ],
    "payment_behavior": "default_incomplete",
    "expand": ['latest_invoice.payment_intent.invoice.subscription'],
}
subscription = stripe.Subscription.create(
    **request_data
)
grizzled flickerBOT
slender plume
#

Or is the error happening locally in the SDK?

#

Oh

#
subscription = stripe.Subscription.create(
    **request_data
)

this looks wrong, but let me double check never mind, i misunderstood

kindred musk
#

Error exception happening in 311

try:
    stripe.Customer.modify(
        customer_id,
        invoice_settings={
            'default_payment_method': pm.id,
        },
        **extra
    )
    print("306")
except stripe.error.StripeError as e:
    print("308: ", e.user_message)
    raise CustomException.raise_error(e.user_message, status_code=400)
except Exception as e:
    print("311: ", str(e))
    raise CustomException.raise_error(str(e), status_code=400)

stable iron
#

Hi there ๐Ÿ‘‹ jumping in as my teammate needs to step away soon. Did that generate a request ID that you can share?
https://support.stripe.com/questions/finding-the-id-for-an-api-request#:~:text=Using the dashboard,the dashboard URL as well

I'm taking a look at the code that you shared, but it seems like our API is returning an error there and understanding that error would likely be helpful.

kindred musk
#

Sorry we got the fix... Thanks for your response...