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