stripe/stripe-python

Invalid timestamp: must be an integer Unix timestamp in the future

maplelover opened this issue · 3 comments

Describe the bug

'Invalid timestamp: must be an integer Unix timestamp in the future.' error_param=due_date error_type=invalid_request_error message='Stripe API error received'

invalid_request_error - due_date

{
"collection_method": "send_invoice",
"due_date": "1665417599",
"custom_fields": {
"0": {
"value": "2023-01-23 ~ 2023-02-05",
"name": "Period"
}
},
"metadata": {
"bill_id": "1",
"env": "staging"
},
"description": "Please pay as soon as possible!",
"customer": "cus_NKYA1LUhdEzYir"
}

To Reproduce

due_date = 1665417599
invoice = stripe.Invoice.create(
customer=#tripe_customer_id,
collection_method='send_invoice',
due_date=due_date,
)

Expected behavior

convert parameter due_date to integer

Code snippets

No response

OS

macOS

Language version

Python 3.8

Library version

stripe-python v5.1.1

API version

2020-08-27

Additional context

No response

@maplelover the Unix timestamp 1665417599 corresponds to 2022-10-10 15:59:59 UTC. This is in the past. You can't set due_date on Invoice creation to a time in the past, this is not support, which is what the API error indicates. You need to pass a future date instead.

If you have any follow up questions and since this is more an integration help/product question, I recommend that you reach out to our support team directly to discuss this further instead: https://support.stripe.com/contact

@remi-stripe The time stamp 1665417599 is written at will. You can change it to 1683807199. The root cause of this problem is that stripe believes that parameter due_date is a string type, not an integer type. Attempting to switch the old API version does not work. This code was normal before. It should be caused by the updated version of the stripe.

I am not sure whether this is a bug of sdk or a bug of stripe. I look forward to your reply.

due_date = 1683807199
invoice = stripe.Invoice.create(
customer=#tripe_customer_id,
collection_method='send_invoice',
due_date=due_date,
)

@maplelover that is not correct though. This parameter expects a Unix timestamp in the future. You can try the following command where the timestamp is for March 1st for example:

curl https://api.stripe.com/v1/invoices \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d customer=cus_4QFOF3xrvBT2nU \
  -d collection_method=send_invoice \
  -d due_date=1677657600

I looked into our logs and I don't see any API Requests passing the parameter due_date with the value 1683807199 in the past 24 hours. My guess is that you are not running the exact code you think you are and either pass a date in the past or an empty value for some reason.

This is definitely not a bug with the SDK or Stripe and it does feel like an integration question. Please work directly with our support team for help: https://support.stripe.com/contact