我有以下控制器:
class PaymentsController < ApplicationController
before_action :authenticate_user!, only: [:new]
def new
gon.client_token = generate_client_token
end
def create
@result = Braintree::Transaction.sale(
amount: 60,
payment_method_nonce: params[:payment_method_nonce])
if @result.success?
puts @result.transaction.payment_instrument_type
flash[:notice] = 'Yes, transaction completed'
else
flash[:alert] = "Something went wrong while processing your transaction. Please try again!"
gon.client_token = generate_client_token
render :new
end
end
private
def generate_client_token
Braintree::ClientToken.generate(customer_id: current_user.braintree_customer_id)
end
end
与上面的代码,我用PayPal帐户链接到库为特定客户测试。 但是它不会链接。 我查了一下,在我看来它不应该有任何额外的调整文件的参考。
任何提示?