Ruby on rails 如何在ruby中实现ccavenue

Ruby on rails 如何在ruby中实现ccavenue,ruby-on-rails,ruby,Ruby On Rails,Ruby,有人能帮我吗。我想在我的项目中集成ccavenue,我使用了ccavenue代码,但在orderID=@transaction.id.to_处出现了一些错误“未定义nil:NilClass的方法'id'。。这是我的密码 在application.helper中--> 在控制器中--> 结束 和控制器中的操作--> 我在上的“nil:NilClass的未定义方法'id'中出错” orderID=@transaction.id.to\u 从这个链接获得帮助-- 请指导我如何更正此代码 试试这个:

有人能帮我吗。我想在我的项目中集成ccavenue,我使用了ccavenue代码,但在orderID=@transaction.id.to_处出现了一些错误“未定义nil:NilClass的方法'id'。。这是我的密码

在application.helper中-->

在控制器中-->

结束

和控制器中的操作-->

我在上的“nil:NilClass的未定义方法'id'中出错” orderID=@transaction.id.to\u

从这个链接获得帮助--

请指导我如何更正此代码

试试这个:

通过搜索超过2个宝石被列入名单

1>

2>


在这些
中,
似乎是好的,尝试使用它。

@transaction
nil
。您在哪里为
@transaction
赋值?使用安装说明都在自述文件中。您可能还需要在他们的网站上注册,他们将提供逐步集成ccavenueI的过程。我尝试过,但“sudo gem安装active\u merchant\u ccavenue”出现错误“sudo command not found”@Daveinside您的应用程序gem文件添加gem“active\u merchant\u ccavenue”并捆绑安装。如果你使用的是ubuntu sudo,我将在Windows7上使用aptana studio 3,请解释一下,我在ruby@sachin方面没有经验
 def verifyChecksum( merchantID,  orderID,  amount,  authDesc,  workingKey,  checksum) 
 String str = merchantID+"|"+orderID+"|"+amount+"|"+authDesc+"|"+workingKey
 String newChecksum = Zlib::adler32(str).to_s
 return (newChecksum.eql?(checksum)) ? true : false
 end

 def getChecksum( merchantID,  orderID,  amount,  redirectUrl,  workingKey)
 String str = merchantID + "|" + orderID + "|" + amount + "|" + redirectUrl + "|" + workingKey;
 return Zlib::adler32(str)
 end
 def index


orderID = @transaction.id.to_s

amount = @transaction.total_amount.to_s

redirectURL = "http://www.dealbuddie.com/transactions/"+@transaction.id.to_s+"/ccavenue_redirect"

checksum = getChecksum(CCAVENUE_MERCHANT_ID, orderID, amount, redirectURL, CCAVENUE_WORKING_KEY)

  @ccaRequest = 

  "Merchant_Id="+CCAVENUE_MERCHANT_ID+"&"+

  "Amount="+amount+"&"+

  "Order_Id="+orderID+"&"+

  "Redirect_Url="+redirectURL+"&"+

  "billing_cust_name="+current_user.name+"&"+

  "billing_cust_address="+@transaction.address.street_address+"&"+

  "billing_cust_country="+@transaction.address.country+"&"+

  "billing_cust_tel="+@transaction.address.cell_phone+"&"+

  "billing_cust_email="+current_user.email+"&"+

  "billing_cust_state="+@transaction.address.state+"&"+

  "delivery_cust_name="+current_user.name+"&"+

  "delivery_cust_address="+@transaction.address.street_address+"&"+

  "delivery_cust_country="+@transaction.address.country+"&"+

  "delivery_cust_state="+@transaction.address.state+"&"+

  "delivery_cust_tel="+@transaction.address.cell_phone+"&"+

  "delivery_cust_notes="+"Note"+"&"+

  "billing_cust_city="+@transaction.address.city+"&"+

  "billing_zip_code="+@transaction.address.pincode.to_s+"&"+

  "delivery_cust_city="+@transaction.address.city+"&"+

  "delivery_zip_code="+@transaction.address.pincode.to_s+"&"+

  "Checksum="+checksum.to_s

  Dir.chdir("#{RAILS_ROOT}/public/jars/") do

  @encRequest = %x[java -jar ccavutil.jar #{CCAVENUE_WORKING_KEY} "#{@ccaRequest}" enc]

end
 def ccavenue_redirect

@encResponse = params[:encResponse]

@checksum = false

@authDesc = false

@p = nil

@ccaResponse = nil

if (params[:encResponse])

        if @encResponse

    Dir.chdir("#{RAILS_ROOT}/public/jars/") do

           @ccaResponse = %x[java -jar ravi-ccavutil.jar #{CCAVENUE_WORKING_KEY} "#{@encResponse}" dec]

    end

    @p = Rack::Utils.parse_nested_query @ccaResponse

    if (!@p.nil? && @p["Merchant_Id"] && @p["Order_Id"] && @p["Amount"] && @p["AuthDesc"] && @p["Checksum"])

      @checksum = verifyChecksum(@p["Merchant_Id"], @p["Order_Id"], @p["Amount"], @p["AuthDesc"], CCAVENUE_WORKING_KEY, @p["Checksum"])

      @authDesc = @p["AuthDesc"].eql?("Y") ? true : false

    end

  end

  if @checksum && @authDesc 

    transaction = Transaction.find(@p["Order_Id"])

    transaction.payment_confirmed = true

    transaction.save!

    message = current_buyer.user.name + "! Thank you for your order! It will soon be at your doorsteps!" 

    redirect_to root_path, :flash => {:success => message}

  else

    if !@authDesc

      message = current_buyer.user.name + "! Your bank did not authorize the transaction. Please go to Settings > My Orders page, and click on 'Pay Now' button to finish your transaction" 

      redirect_to root_path, :flash => {:error => message}

    else

      message = current_buyer.user.name + "! Oops! There was some error in retrieving your transaction confirmation. Please drop us an email at dealbuddie@dealbuddie.com for order confirmation."

      redirect_to root_path, :flash => {:error => message}

    end

  end

else

  message = current_buyer.user.name + "! Oops! Something went wrong while processing your request. Please go to Settings > My Orders page, and click on 'Pay Now' button to finish your transaction."

  redirect_to root_path, :flash => {:success => message}

end

end