M
M
Max2016-06-04 17:03:30
Ruby on Rails
Max, 2016-06-04 17:03:30

How to get a response from liqpay (Rails)?

Hello, tell me how to get a response from liqpay.
Request to liqpay:

def check_payment_status
      if @place.status == false
        @liqpay_request = Liqpay::Request.new(
          :amount => 0.1 ,
          :currency => 'UAH',
          :description => "#{@place_title}, Place number: #{@place.place_number}, date: #{@place.session_date}, time: #{@place.session_time}",
          :order_id => @place.id,
          :sandbox => '1',
          result_url: place_url(@place),
          server_url: liqpay_payment_url
        )
      end
    end

payments_controller
class PaymentsController < ApplicationController
  protect_from_forgery :except => :liqpay_payment

  def liqpay_payment
    @liqpay_response = Liqpay::Response.new(params)
    @place = Place.find(@liqpay_response.order_id)

    @place.data = {}

    (Liqpay::Response::ATTRIBUTES - %w(public_key sender_phone transaction_id)).each do |attribute|
      @place.data[attribute] = @liqpay_response.send(attribute)
    end

    if @liqpay_response.success?
      @place.update_attributes!(:status => 'success')
    else
      @place.update_attributes!(:status => 'failed')
    end
    redirect_to @place
  rescue Liqpay::InvalidResponse
    render text: 'Payment error', status: 500
  end
end

Route
get '/liqpay_payment' => 'payments#liqpay_payment'
On liqpay itself, set:
Notification URL server-server: localhost:3000/liqpay_payment Store
URL client-server: localhost:3000/liqpay_payment
And tick the box - Require order_id when paying in the store.
Tell me why the payments_controller controller does not work. After payment, there is a redirect to the product page and that's it. Everything is clean in the logs. The localhost:3000/liqpay_payment page is never called.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2016-06-04
@sim3x

Perhaps because the private cannot come to you on the localhost?
And in order for such a thing to work, you need to post everything in public

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question