Skip to content

Commit

Permalink
Renamed computer product to computers
Browse files Browse the repository at this point in the history
product and image slug must be aligned.
We had discrepancy between product `computer` and slug `computers`
which prevents computing download link and thus sending success email.
  • Loading branch information
rgaudin committed Feb 3, 2025
1 parent 8ecd65f commit 405505b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
28 changes: 20 additions & 8 deletions scheduler/src/routes/stripe.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
# envs & secrets
STRIPE_API_KEY = os.getenv("STRIPE_API_KEY")
STRIPE_PUBLIC_API_KEY = os.getenv("STRIPE_PUBLIC_API_KEY")
CARDSHOP_API_URL = os.getenv(
"CARDSHOP_API_URL", "https://api.imager.kiwix.org"
)
CARDSHOP_API_URL = os.getenv("CARDSHOP_API_URL", "https://api.imager.kiwix.org")
SHOP_PUBLIC_URL = os.getenv(
"SHOP_PUBLIC_URL", "https://www.kiwix.org/en/cardshop-access/"
)
Expand All @@ -37,7 +35,7 @@
"product_ted": "TED Hotspot",
"product_preppers": "Preppers Hotspot",
"product_medical": "Medical Hotspot",
"product_computer": "Computer Hotspot",
"product_computers": "Computer Hotspot",
"product_access_1m": "One month Imager Access",
"product_access_1y": "Annual Imager Access",
},
Expand All @@ -46,7 +44,7 @@
"product_ted": "TED Hotspot",
"product_preppers": "Preppers Hotspot",
"product_medical": "Medical Hotspot",
"product_computer": "Computer Hotspot",
"product_computers": "Computer Hotspot",
"product_access_1m": "One month Imager Access",
"product_access_1y": "Annual Imager Access",
},
Expand All @@ -55,7 +53,7 @@
"product_ted": "TED Hotspot",
"product_preppers": "Preppers Hotspot",
"product_medical": "Medical Hotspot",
"product_computer": "Computer Hotspot",
"product_computers": "Computer Hotspot",
"product_access_1m": "One month Imager Access",
"product_access_1y": "Annual Imager Access",
},
Expand All @@ -64,7 +62,7 @@
"product_ted": "TED Hotspot",
"product_preppers": "Preppers Hotspot",
"product_medical": "Medical Hotspot",
"product_computer": "Computer Hotspot",
"product_computers": "Computer Hotspot",
"product_access_1m": "Accès Imager 1 mois",
"product_access_1y": "Accès Imager annuel",
},
Expand Down Expand Up @@ -128,6 +126,8 @@ def send_paid_order_email(
def get_links_for(product):
"""(http, torrent, magnet) URLs for a product-ID"""
# currently, product-ids matches the auto-images slugs
if product == "computer": # temporary for webhook started with incorrect ID
product = "computers"
image = AutoImages.get(product)
return image["http_url"], image["torrent_url"], image["magnet_url"]

Expand Down Expand Up @@ -288,6 +288,12 @@ def handle_access_order(session, customer):
os.getenv("STRIPE_PRICE_TED"),
handle_image_order,
),
"computers": (
os.getenv("STRIPE_METHOD_CS"),
os.getenv("STRIPE_PRICE_CS"),
handle_image_order,
),
# temporary for webhook completion
"computer": (
os.getenv("STRIPE_METHOD_CS"),
os.getenv("STRIPE_PRICE_CS"),
Expand Down Expand Up @@ -437,7 +443,13 @@ def success():

context = {"customer": customer, "session": session, "shop_url": SHOP_PUBLIC_URL}
product = session.metadata.get("product")
if product.startswith("wikipedia-") or product in ("preppers", "computer", "ted", "medical"):
if product.startswith("wikipedia-") or product in (
"preppers",
"computer", # temporary
"computers",
"ted",
"medical",
):
kind = "image"
http_url, torrent_url, _ = get_links_for(product)
context.update({"http_url": http_url, "torrent_url": torrent_url})
Expand Down
2 changes: 1 addition & 1 deletion scheduler/src/templates/stripe/shop.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ <h2>Computer package</h2>
</ul>
</section>
<form class="button-holder">
<input type="hidden" name="product" value="computer">
<input type="hidden" name="product" value="computers">
<button class="btn btn-outline-secondary">Purchase</button>
<div class="loader"><i class="spinner-border spinner-border-xl" role="status"></i></div>
</form>
Expand Down

0 comments on commit 405505b

Please sign in to comment.