2015-06-29 69 views
1

我的沙盒帳戶不存儲客戶在其保管庫中的付款方式。我創建使用客戶對象:Braintree保管庫未存儲付款方式

def create_customer 
    result = Braintree::Customer.create(
    :first_name => params[:first_name], 
    :last_name => params[:last_name], 
    :email => params[:email], 
    :phone => params[:phone] 
    ) 
    if result.success? 
    render :json => {'result' => result.customer.id} 
    else 
    render :json => {'errors' => result.errors}, :status => 400 
    end 
end 

,然後存儲customer_id我的數據庫中,供以後使用。

創建client_token時,我發送相同的customer_id到API。這裏是創建client_token的代碼:

def client_token 
    token = Braintree::ClientToken.generate(
    :customer_id => params[:customer_id] 
    ) 
    render :json => {"token" => token} 
end 

回答

1

我在布倫特裏工作。如果您對集成更多的問題,你可以隨時get in touch with our support team

你需要create a payment method與您從客戶端接收回來的亂數:

result = Braintree::PaymentMethod.create(
    :customer_id => "131866", 
    :payment_method_nonce => nonce_from_the_client 
)