Hi all, I’m trying to understand an Anvil error that I’m receiving when running a Stripe checkout.
Following is my code that I’ve pulled into a blank form so it’s easy to read and reproduce:
from ._anvil_designer import Form1Template
from anvil import *
import anvil.server
import stripe.checkout
class Form1(Form1Template):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
# Any code you write here will run when the form opens.
try:
amount_due = 12345
charge = stripe.checkout.charge(amount = amount_due,
currency = "USD",
title = "My Company",
description = "My Services")
print(charge)
except Exception as e:
print("Error: %s" % e)
try:
invoice_number = '1234'
cpid = 5678
amount_due = anvil.server.call('get_amount_due', invoice_number, cpid)
charge = stripe.checkout.charge(amount = amount_due,
currency = "USD",
title = "My Company",
description = "My Services")
print(charge)
except Exception as e:
print("Error: %s" % e)
The first checkout event works fine, but the second one comes back with an error noted as “No module named ‘stripe.checkout’.” The only difference is that I’m calling a server function to obtain the payment amount in that second call and it returns the amount due.
I’m sure it’s something simple, but I am a little baffled by it.
Thanks in advance,
David