activemerchant / offsite_payments

A simple and unified API to handle dozens of different offsite payment pages.
MIT License
169 stars 200 forks source link

Changed URL ROBOKASSA #209

Open abuhtoyarov opened 8 years ago

abuhtoyarov commented 8 years ago

Docs

I look the documentation and see that now a new URL for payment https://auth.robokassa.ru/Merchant/Index.aspx

To work in test mode required parameter is IsTest.

Now for payment use the following URL:

http://test.robokassa.ru/Index.aspx -test mode https://merchant.roboxchange.com/Index.aspx - production mode

anoam commented 8 years ago

As hotfix you can redefine urls like this:

# config/initializers/offsite_payments.rb
OffsitePayments::Integrations::Robokassa.production_url = "https://auth.robokassa.ru/Merchant/Index.aspx"
OffsitePayments::Integrations::Robokassa.test_url = "https://auth.robokassa.ru/Merchant/Index.aspx"

The best way I found to add IsTest to parameters is monkey patching:

OffsitePayments::Integrations::Robokassa::Helper.class_eval do
  def form_fields
    @fields
      .merge(test_field)
      .merge(OffsitePayments::Integrations::Robokassa.signature_parameter_name => generate_signature)
  end

  def params
    @fields.merge(test_field)
  end

  private

  def test_field
    {"IsTest" => test? ? 1 : 0}
  end
end

It works fine for me, but I'm not pretty sure that it would be ok for all cases.