您好我昨天使用Passenger/Capistrano和Nginx服務器將應用程序部署到VPS。Braintree結帳在部署後給出錯誤`Braintree :: ConfigurationError`
除訂購頁面上輸入checkout
按鈕外,其它均順利運行。
然後應用程序崩潰,並在production.log
有這個錯誤行Braintree::ConfigurationError (Braintree::Configuration.merchant_id needs to be set): app/controllers/orders_controller.rb:22:in 'new'
的事情是Merchiant_id
設置,我完全失去了。
部署之前我將Sandbox
API密鑰更改爲Production
API密鑰application.yml
。我使用來隱藏API keys
。
當我在運行這個localhost
之前,部署一切正常。
我已經一遍又一遍地瀏覽Braintree指南。我找不到任何錯誤。
我失去了一些東西在這裏?
這裏是orders_controller.rb
是錯誤來自。
class OrdersController < ApplicationController
include CurrentCart
before_action :set_cart, only: [:new, :create]
before_action :set_order, only: [:show, :edit, :destroy]
def index
@orders = Order.all?
end
def new
@images = ["1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg"]
@random_no = rand(5)
@random_image = @images[@random_no]
if @cart.product_items.empty?
redirect_to root_url, notice: 'Your Cart is Empty'
return
end
@order = Order.new
@client_token = Braintree::ClientToken.generate #this is line 22 were the error is
end
def create
@order = Order.new(order_params)
if @order.save
charge
if @result.success?
@order.add_product_items_from_cart(@cart)
Cart.destroy(session[:cart_id])
session[:cart_id] = nil
OrderNotifier.received(@order).deliver
redirect_to root_url, notice: 'Thank You for Your Order'
else
flash[:error] = 'Please Check Your Cart'
redirect_to root_url, alert: @result.message
@order.destroy
end
else
@client_token = Braintree::ClientToken.generate
render :new
end
end
def show
end
def destroy
@order.destroy
redirect_to root_url, notice: 'Order deleted'
end
private
def set_order
@order = Order.find(params[:id])
end
def order_params
params.require(:order).permit(:name, :email, :address, :city, :country)
end
def charge
@result = Braintree::Transaction.sale(
amount: @cart.total_price_usd,
payment_method_nonce: params[:payment_method_nonce])
end
end
好,謝謝,我會檢查出來......希望這能解決它 – DaudiHell
沒有....我得到一個新的錯誤,在服務器上缺少application.yml .....猜猜我必須在服務器上創建它 – DaudiHell
對不起,當然。 ....你必須這樣做...我會更新答案,如果它的工作 – Slowboy