Sha256: b61e18ab89e1b5206d301ce8e7aea4bfc847e95b23f0f5fa523552254f737707
Contents?: true
Size: 1.81 KB
Versions: 2
Compression:
Stored size: 1.81 KB
Contents
class Przelewy24PaymentController < ApplicationController def payment @data = { :session_id => 'sssss', :description => "opis", :value => '34.3', :client => 'Adam Nowak', :address => 'Powstancow 22/2', :zipcode => '53-456', :city => 'Wroclaw', :country => 'Polska', :email => 'test@example.com' } end def payment_success(payment_params) end def payment_error(payment_params, code, description) end def payment_verify(response_params) return data = { :amount => 100.0, :crc_key => '' } end def comeback @response = przelewy24_verify(params) result = @response.split("\r\n") if result[1] == "TRUE" payment_success(params) else payment_error(params, :error_code => result[2], :error_descr => result[3]) end end private def przelewy24_verify(params) require 'net/https' require 'net/http' require 'open-uri' require 'openssl' data = payment_verify(params) params_new = {:p24_session_id => params[:p24_session_id], :p24_order_id => params[:p24_order_id], :p24_id_sprzedawcy => P24Payment::SELLER_ID, :p24_kwota => P24Payment.p24_price(data[:amount]).to_s} if data[:crc_key].present? params_new[:p24_crc] = Digest::MD5.hexdigest(params[:p24_session_id]+"|"+params[:p24_order_id]+"|"+params[:p24_kwota]+"|"+data[:crc_key]) end url = URI.parse(P24Payment.transaction_url) req = Net::HTTP::Post.new(url.path,{"User-Agent" => "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.10) Gecko/20100915 Ubuntu/10.04 (lucid) Firefox/3.6.10"}) req.form_data = params_new con = Net::HTTP.new(url.host, 443) con.use_ssl = true con.verify_mode = OpenSSL::SSL::VERIFY_NONE response = con.start {|http| http.request(req)} return response.body end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
przelewy24_payment-0.1.0 | app/controllers/przelewy24_payment/payment_controller.rb~ |
przelewy24_payment-0.0.1 | app/controllers/przelewy24_payment/payment_controller.rb~ |