我的沙箱帐户不会将客户的付款方式存储在其保管库中。我正在使用以下方法创建客户对象:
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时,我向API发送相同的customer_id
。以下是创建client_token的代码:
def client_token
token = Braintree::ClientToken.generate(
:customer_id => params[:customer_id]
)
render :json => {"token" => token}
end
答案 0 :(得分:1)
我在Braintree工作。如果您对集成有更多疑问,可以随时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
)