如何在rails中进行ccavenuee支付网关集成

时间:2015-12-22 08:46:40

标签: ruby-on-rails ccavenue

我尝试过ccavenue,但我收到了这个错误。 paypal工作正常。

undefined method payment_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

端 end`

我提到了这个链接: https://github.com/meshbrain/active_merchant_ccavenue

1 个答案:

答案 0 :(得分:0)

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