我已经阅读了这个 stackoverflow Q&A但它并没有解决我的问题。
在我的场景中,我submit_transaction_for_settlement(transaction_id)
使用优秀的包将函数 () 推送到 redis 队列django-rq
。此功能的工作是提交交易以进行结算。
在沙箱中,每当执行此功能时,我都会收到相同的错误:AttributeError: type object 'Configuration' has no attribute 'environment'
.
我尝试了关于我的函数内部agf
的建议instantiate a new gateway for each transaction
,但没有奏效!
也许这与redis队列的环境或worker环境有关?
def submit_transaction_for_settlement(transaction_id):
from braintree import Configuration, BraintreeGateway
config = Configuration(environment=settings.BRAINTREE_ENVIRONMENT, merchant_id=settings.BRAINTREE_MERCHANT_ID,
public_key=settings.BRAINTREE_PUBLIC_KEY, private_key=settings.BRAINTREE_PRIVATE_KEY)
gateway = BraintreeGateway(config=config)
result = gateway.transaction.submit_for_settlement(transaction_id)