我想实现从Braintree支付网关到我的Django项目的订阅代码。我在这里找到示例:https://www.braintreepayments.com/docs/python/guide/recurring_billing 我有以下代码负责创建订阅 - 它在单个文件中工作(不在我的django应用程序中)。
当我转到django中的方法代码时,我得到代码405。
我的代码:
def subscriptions():
try:
customer_id = client.customer.id
customer = braintree.Customer.find(customer_id)
payment_method_token = client.customer.credit_cards[0].token
result = braintree.Subscription.create({
"payment_method_token": payment_method_token,
"plan_id": "myPlanId"
})
print result
if result.is_success:
print "Subscription success!"
except braintree.exceptions.NotFoundError:
print "No customer found."
我的网址
url(r'^subscription/$', subscriptions, name='subscription'),