【问题标题】:how to do ccavenuee payment gateway integration in rails如何在 Rails 中进行 ccavenue 支付网关集成
【发布时间】:2015-12-22 08:46:39
【问题描述】:

我尝试了 ccavenue,但出现此错误。贝宝工作正常。

undefined methodpayment_service_for'`

这是我的控制器操作

def create @subscription = Subscription.new(subscription_params) @programme = Programme.find(subscription_params[:programme_id]) rand_number = rand.to_s[2..11] @programme.update_attributes(:invoice_id => rand_number) session[:programme_id]=@programme.id session[:invoice_id]=@programme.invoice_id @paypal = PaypalPayment.create(:material_type => 'Programmes',:invoice_id => rand_number,:currency => @programme.currency, :status => 'Processing', :created_at => DateTime.now, :user_id => current_user.specific.id, :email_id => current_user.specific.email, :programme_id => @programme.id,:amount => @programme.price_paisas) @paypal.save

`session[:paypal_id]=@paypal.id
logger.info @programme.inspect
if subscription_params[:payment_type] == 'paypal'
  item_details=[]
  if @programme.currency == 'INR'
    price = @programme.price.exchange_to('USD')
  else
    price = @programme.price
  end
  logger.info price.inspect
  item_details << {:name => @programme.title, :quantity => '1', :amount => price.fractional}
  response = EXPRESS_GATEWAY.setup_purchase(price.fractional,
                                            :items => item_details,
                                            :currency => "USD",
                                            :order_id => @programme.invoice_id,
                                            :return_url => students_success_url,
                                            :cancel_return_url => students_root_url
  )
  logger.info response.inspect
  session[:programme_price]=price
  return redirect_to EXPRESS_GATEWAY.redirect_url_for(response.token)

elsif subscription_params[:payment_type] == 'ccavenue'
      payment_service_for @programme.invoice_id, CCAVENUE_ACCOUNT,
        :amount => @programme.price.fractional,
        :currency => 'INR',
        :service => :ccavenue do |service|   
          service.customer :name => current_user.name,
               :email => current_user.email,
               :phone => current_user.mobile 
          service.redirect :return_url => students_success_url
          submit_tag 'Proceed to payment'
     end
end

结束 结束`

我参考了这个链接: https://github.com/meshbrain/active_merchant_ccavenue

【问题讨论】:

    标签: ruby-on-rails ccavenue


    【解决方案1】:

    payment_service_forActive Merchant gem 的视图助手。您应该在视图中使用此方法,或者您应该在控制器中包含视图助手。

    【讨论】:

    • 我应该在哪里添加这个,你能指定文件吗?和代码。我可以在同一个控制器中添加这个吗?
    • here。在您的控制器中尝试:`include ActiveMerchant::Billing::Integrations::ActionViewHelper'
    • 在视图中使用会更好。
    • 在视图中意味着我应该包含在这条路径中,对吗? lib/active_merchant/billing/integrations/action_view_helper.rb
    • @sree,如何正确操作请参阅我上方评论中的链接。
    猜你喜欢
    • 2017-09-23
    • 2017-12-19
    • 2015-12-21
    • 2019-05-04
    • 2015-01-16
    • 2011-08-07
    • 1970-01-01
    • 2013-05-03
    • 2012-08-15
    相关资源
    最近更新 更多