From 0a623d87c49536b0f00eede80508b61cdeeee799 Mon Sep 17 00:00:00 2001 From: Brian Simpson Date: Tue, 19 Nov 2013 05:39:50 -0500 Subject: [PATCH] StripeController: don't raise exception for recent charges. --- r2/r2/controllers/ipn.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/r2/r2/controllers/ipn.py b/r2/r2/controllers/ipn.py index 5f2d580b8..0cf10b7b6 100644 --- a/r2/r2/controllers/ipn.py +++ b/r2/r2/controllers/ipn.py @@ -34,7 +34,7 @@ from r2.lib.errors import MessageError from r2.lib.filters import _force_unicode, _force_utf8 from r2.lib.log import log_text from r2.lib.strings import strings -from r2.lib.utils import randstr +from r2.lib.utils import randstr, timeago from r2.lib.validator import ( nop, textresponse, @@ -811,7 +811,12 @@ class StripeController(GoldPaymentController): customer_id = charge.customer buyer = account_from_stripe_customer_id(customer_id) if not buyer: - raise ValueError('no buyer for stripe charge: %s' % charge.id) + charge_date = datetime.fromtimestamp(charge.created, tz=g.tz) + + # don't raise exception if charge date is within the past hour + # db replication lag may cause the account lookup to fail + if charge_date < timeago('1 hour'): + raise ValueError('no buyer for charge: %s' % charge.id) webhook = Webhook(transaction_id=transaction_id, subscr_id=customer_id, pennies=pennies, months=months, goldtype='autorenew',