我正在使用以下Braintree代碼以通過customer_id找到客戶,但得到此錯誤customer with id "customer_id" not found
。爲了做到這一點,我需要用一個代表Braintree Vault中客戶的客戶ID的變量替換字符串'customer_id'。未找到標識爲「customer_id」的客戶
我很喜歡這個變量,需要一些幫助!
User.rb
customer = Braintree::Customer.find(customer_id)# this string here need to be replaced
customer_card = customer.payment_methods[0].token
payment_method = Braintree::PaymentMethod.find(customer_card)
sub = payment_method.subscriptions[0]
sub.status
create方法位於transactions_controller.rb
def create
nonce_from_the_client = params['payment_method_nonce']
@result = Braintree::Customer.create(
first_name: params[:first_name],
last_name: params[:last_name],
:payment_method_nonce => nonce_from_the_client
)
if @result.success?
puts @result.customer.id
puts @result.customer.payment_methods[0].token
redirect_to showcase_index_path, notice: 'Subscribed'
else
redirect_back(fallback_location: (request.referer || root_path),
notice: "Something went wrong while processing your transaction. Please try again!")
end
end
確保客戶表中有customer_id列。 – xiaocui
感謝回覆@xiaocui ...我在我的用戶表中有customer_id,因爲我沒有客戶表,但仍然返回同樣的錯誤'customer id'customer_id「not found'。任何想法,我可能會在這裏想念? – Theopap