我在django代码中 Build 了一个模型是:
import stripe
from django.conf import settings
from django.contrib.auth.signals import user_logged_in
from django.db.models.signals import post_save
from django.db import models
stripe.api_key = settings.STRIPE_SECRET_KEY
#Stripe
class UserStripe(models.Model):
user = models.OneToOneField(settings.AUTH_USER_MODEL)
stripe_id = models.CharField(max_length=120)
def __unicode__(self):
return str(self.stripe_id)
def get_or_create_stripe(sender, user, *args, **kwargs):
try:
user.userstripe.stripe_id
except UserStripe.DoesNotExist:
customer = stripe.Customer.create(
email = str(user.email)
)
new_user_stripe = UserStripe.objects.create(
user=user,
stripe_id = customer.id,
)
except:
pass
user_logged_in.connect(get_or_create_stripe)
我已将api密钥更改为设置中的实时代码,甚至删除了条带中的旧测试API密钥 . 但该应用程序仍在使用旧的api,我一直收到以下错误 .
/ accounts / login /中的AuthenticationError提供的API密钥:sk_test _ ******************** IddZ请求方法:Django版本:1.8.4异常类型:AuthenticationError异常值:提供过期的API密钥:sk_test _ ******************** IddZ例外位置:/app/.heroku/python/lib/python2.7/site-packages/stripe /api_requestor.py in handle_api_error,第163行Python可执行文件:/app/.heroku/python/bin/python Python版本:2.7.12 Python路径:['/ app','/ app / .heroku / python / bin', '/ app','/ app / .heroku / python / lib / python27.zip','/ app / .heroku / python / lib / python2.7','/ app / .heroku / python / lib / python2 . 7 / plat-linux2','/ app / .heroku / python / lib / python2.7 / lib -tk','/ app / .heroku / python / lib / python2.7 / lib-old','/ app /.heroku/python/lib/python2.7/lib-dynload','/ app / .heroku / python / lib / python2.7 / site-package','/ app / .heroku / python / lib / python2 . 7 / site-packages / setuptools-25.2.0-py2.7.egg','/ app / .heroku / python / lib / python2.7 / site-package / patch.8.1.2-py2.7.egg'服务器时间:2016年11月13日,星期日17 :25:32 0000
有任何想法吗:
1 回答
代码是正确的,api是正确的,在我运行
heroku restart
重新启动dyno后,它运行正常 .