Dave
Dave

Reputation: 4436

Integrating payu payment gateway (active_merchant_payu_in) with spree

I am trying to integrate payu.in payment gateway with spree into my rails application. I have included gem 'active_merchant_payu_in' in the application.

My app/models/spree/gateway/payu.rb looks like this:

module Spree
  class Gateway::Payu < Gateway
    def provider_class
      ActiveMerchant::Billing::Integrations::PayuIn
    end
  end
end

In application.rb

config.after_initialize do |app|
  app.config.spree.payment_methods += [
    Spree::Gateway::Payu
  ]
end

Development.rb

config.after_initialize do
  ActiveMerchant::Billing::Base.mode = :test    
  $payu_merchant_id = ActiveMerchant::Billing::Integrations::PayuIn.merchant_id = '--ID--'
  $payu_secret_key = ActiveMerchant::Billing::Integrations::PayuIn.secret_key = '--Key--'    
end

I have enabled Spree::Gateway::Payu from admin credentials. Now when i do a checkout i get below error.

NoMethodError in Spree::CheckoutController#update undefined method `authorize' for ActiveMerchant::Billing::Integrations::PayuIn:Module

can someone guide me towards right path. Many Thanks :)

Upvotes: 2

Views: 1625

Answers (1)

Rohit Agarwal
Rohit Agarwal

Reputation: 65

Incase anyone is still facing this problem.

Solution: Edit your payment method "Spree::Gateway::Payu" and set auto_capture? field to true.

Payu does not support authorize method which is called when "auto capture" is set to false, when set to true, "purchase" method is called which is supported by payu.

You can read more about auto capture in Spree's documentation. https://guides.spreecommerce.com/developer/payments.html

Upvotes: 1

Related Questions