Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
CarolinePascal commited on
fix(invoice number): fixing invoice number
Browse files
app.py
CHANGED
|
@@ -220,25 +220,29 @@ class DatePickerView(discord.ui.View):
|
|
| 220 |
async def eta(interaction: discord.Interaction, invoice: str = None):
|
| 221 |
if invoice:
|
| 222 |
await interaction.response.defer(ephemeral=True)
|
|
|
|
|
|
|
| 223 |
try:
|
| 224 |
-
|
| 225 |
-
except stripe.error.
|
| 226 |
view = DatePickerView()
|
| 227 |
await interaction.followup.send(
|
| 228 |
-
"❌
|
| 229 |
view=view,
|
| 230 |
ephemeral=True,
|
| 231 |
)
|
| 232 |
return
|
| 233 |
-
|
|
|
|
| 234 |
view = DatePickerView()
|
| 235 |
await interaction.followup.send(
|
| 236 |
-
"❌
|
| 237 |
view=view,
|
| 238 |
ephemeral=True,
|
| 239 |
)
|
| 240 |
return
|
| 241 |
|
|
|
|
| 242 |
purchase_date = datetime.fromtimestamp(inv.created)
|
| 243 |
purchase_date = purchase_date.replace(hour=0, minute=0, second=0, microsecond=0)
|
| 244 |
await interaction.followup.send(
|
|
|
|
| 220 |
async def eta(interaction: discord.Interaction, invoice: str = None):
|
| 221 |
if invoice:
|
| 222 |
await interaction.response.defer(ephemeral=True)
|
| 223 |
+
if invoice.isdigit():
|
| 224 |
+
invoice = f"REACHYMINI-{invoice}"
|
| 225 |
try:
|
| 226 |
+
results = stripe.Invoice.search(query=f'number:"{invoice}"')
|
| 227 |
+
except stripe.error.AuthenticationError:
|
| 228 |
view = DatePickerView()
|
| 229 |
await interaction.followup.send(
|
| 230 |
+
"❌ Unable to verify invoice. Please select your purchase date manually:",
|
| 231 |
view=view,
|
| 232 |
ephemeral=True,
|
| 233 |
)
|
| 234 |
return
|
| 235 |
+
|
| 236 |
+
if not results.data:
|
| 237 |
view = DatePickerView()
|
| 238 |
await interaction.followup.send(
|
| 239 |
+
"❌ Invoice not found — make sure you're entering the **invoice number** (not the order number). Please select your purchase date manually:",
|
| 240 |
view=view,
|
| 241 |
ephemeral=True,
|
| 242 |
)
|
| 243 |
return
|
| 244 |
|
| 245 |
+
inv = results.data[0]
|
| 246 |
purchase_date = datetime.fromtimestamp(inv.created)
|
| 247 |
purchase_date = purchase_date.replace(hour=0, minute=0, second=0, microsecond=0)
|
| 248 |
await interaction.followup.send(
|