Changes for purchases - handle different type of purchases
This commit is contained in:
parent
d9d7099da6
commit
c1d77fa6d6
|
@ -20,12 +20,13 @@ class Admin::PurchasesController < ApplicationController
|
|||
protected
|
||||
|
||||
def download_purchase(purchase, url)
|
||||
uri = URI.parse("http://#{APP_CONFIG['store_ip']}/download/design")
|
||||
uri = URI.parse("http://#{APP_CONFIG['store_ip']}/download/purchase")
|
||||
http = Net::HTTP.new(uri.host, uri.port)
|
||||
request = Net::HTTP::Post.new(uri.request_uri)
|
||||
|
||||
public_key = OpenSSL::PKey::RSA.new(File.read(APP_CONFIG['main_public_key']))
|
||||
encrypted_data = public_key.public_encrypt({:purchase_id => purchase.purchase_id,
|
||||
:purchase_type => purchase._type,
|
||||
:roaming_id => Site.find(session[:site]).roaming_id,
|
||||
:url => url}.to_json)
|
||||
|
||||
|
|
|
@ -7,5 +7,6 @@ class Purchase
|
|||
field :author
|
||||
field :intro
|
||||
field :downloaded, :type => Boolean
|
||||
field :download_date, :type => Date
|
||||
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ PrototypeR4::Application.routes.draw do
|
|||
match '/site/set_registered', :to => CentralServerExchangeApp
|
||||
match '/site/public_key', :to => CentralServerExchangeApp
|
||||
match '/site/update', :to => GithubApp
|
||||
match '/purchase/design', :to => CentralServerExchangeApp
|
||||
match '/purchase/:type', :to => CentralServerExchangeApp
|
||||
match "/panel/:app_name/frontend/:action" => redirect {|params| "/panel/#{params[:app_name]}/#{params[:action]}" }
|
||||
|
||||
|
||||
|
|
|
@ -28,11 +28,16 @@ class CentralServerExchangeApp < Sinatra::Base
|
|||
end
|
||||
end
|
||||
|
||||
post '/purchase/design' do
|
||||
post '/purchase/:type' do
|
||||
begin
|
||||
private_key = OpenSSL::PKey::RSA.new(@site.private_key)
|
||||
p_design = PDesign.new.from_json(private_key.private_decrypt(request.params['purchase']))
|
||||
p_design.save
|
||||
|
||||
case params[:type]
|
||||
when 'Design'
|
||||
purchase = PDesign.new.from_json(private_key.private_decrypt(request.params['purchase']))
|
||||
end
|
||||
|
||||
purchase.save
|
||||
body 'true'
|
||||
rescue
|
||||
body 'false'
|
||||
|
|
Loading…
Reference in New Issue