2015-06-26 47 views
1

我有以下控制器至庫。但它不會鏈接。我查看了文檔參考,在我看來,它不應該是任何額外的調整。鏈接的PayPal帳戶的正確方法與布倫特裏DropUI

任何提示?

+0

Hey Chris;我在Braintree的PayPal團隊工作。您是否介意發佈用於初始化Dropin UI的代碼以及您正在使用的braintree.js的版本?我可以幫助你從那裏解決問題。 – goggin13

回答

0

我使用python/javascript開發了api開發的braintree。您需要爲交易創建。如果您擁有customer_id,則可以生成braintree標記。您可以按照此代碼創建令牌:

def checkout(request): 
    api_token = request.session['token'] 
    nonce = request.POST['payment_method_nonce'] 
    customer = Customer.objects.get(user=request.user) 
    # With this the PaymentMethod will be associated with the Customer 
    result = braintree.PaymentMethod.create({ 
     "customer_id": customer.customer_id, 
     "payment_method_nonce": nonce 
    }) 
    token = result.payment_method.token 
    print token 
    # you the BT token to charge the user 
    result = braintree.Transaction.sale({ 
     "amount": 10, 
     "payment_method_token": token, 
     "options": {'submit_for_settlement': True} 
    }) 
    print result.transaction.id 
相關問題