私はcustomer_idを介して顧客を検索しますが、このエラーはcustomer with id "customer_id" not found
となりますので、以下のBraintreeコードを使用しています。そしてこの作業をするために、私はBraintree Vault内の顧客の顧客IDを表す変数に文字列 'customer_id'を置き換える必要があります。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
作成方法はtransactions_controller.rbあなたはブレイン:: Customer.findに置くためにCUSTOMER_IDを得るのですか
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 with id」customer_idがまだ見つかりません。私はここで何が欠けているかもしれないか何か考え?? – Theopap