Commit 09630221 by Mykhailo Makohin

some progress in liqpay

parent f6aa134a
......@@ -38,6 +38,7 @@ gem 'acts_as_list'
gem 'rails_sortable'
gem 'aasm'
gem 'ransack'
gem 'liqpay', '~>1.0.0'
group :development, :test do
......
......@@ -159,6 +159,7 @@ GEM
activerecord
kaminari-core (= 1.1.1)
kaminari-core (1.1.1)
liqpay (1.0.1)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
......@@ -340,6 +341,7 @@ DEPENDENCIES
haml
jbuilder (~> 2.5)
jquery-rails
liqpay (~> 1.0.0)
listen (~> 3.0.5)
mini_magick
mysql2 (>= 0.3.18, < 0.6.0)
......
......@@ -29,7 +29,6 @@ initUser = (user_email) ->
$('div.field_wrap').removeClass('form_ok')
$('div.field_with_errors').removeClass('form_error')
$('div.field_with_errors').removeClass('form_ok')
$('div.form-group').removeClass('form_ok')
......
......@@ -22,7 +22,8 @@ jQuery(document).ready(function($){
// initTip();
// initMap();
// initBookmarkAnimation();
initLoadMore();
submitForm();
onlyNumbers();
initSlider();
topTip();
// initTooltipster();
......@@ -33,7 +34,15 @@ jQuery(document).ready(function($){
// $('[data-toggle="popover"]').popover({title: "<span class=\"usr_surname\">Фондар</span><span class=\"usr_name\">Вікторія Тараневська <a href=\"#\" class=\"round_link\"><i class=\"icon icon_fb\"></i></span>", content: "<div class=\"usr_contributions\">Внесків 3</div><div class=\"usr_funds\"><div class=\"usr_funds_value\">на суму: 14 200 UAH</div></div><div class=\"usr_volunteering\">Волонтерство 2</div>", html: true, placement: "top"});
})
function submitForm(){
$( ".simple_form" ).submit(function() {
if ($(this).valid() && $( "#contributions_attributes_contribution" ).val() > '0' ) {
$('#modal').modal('hide');
$('#modal_payment').modal('show');
// $(".modal-backdrop").remove();
}
});
}
// function initBookmarkAnimation(){
// let anchorlinks = document.querySelectorAll('a[href^="#"]')
......@@ -51,19 +60,6 @@ jQuery(document).ready(function($){
// }
// }
function initLoadMore(){
$(document).ready(function(){
$(".project_item_content").slice(0, 2).show();
$("#loadMore").on("click", function(e){
e.preventDefault();
$(".project_item_content:hidden").slice(0, 2).slideDown();
if($(".project_item_content:hidden").length == 0) {
$("#loadMore").text("No Content").addClass("noContent");
}
});
})
}
function initSlider(){
$(document).ready(function(){
$('.slider').bxSlider();
......@@ -92,6 +88,17 @@ function initTwentytwenty() {
});
}
function onlyNumbers(){
$("#contributions_attributes_contribution").keypress(function (e) {
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
return false;
}
else {
console.log($("input#contributions_attributes_contribution").val());
$('div.form-group.amount').addClass('form_ok')
}
});
}
function playStopVideoInModal(){
$('body').on('click', '.tooltipster_img', function(){
......
/*
*=require_self
*/
@import url("loadMore.css");
@import url("normalize.css");
@import url("outdatedBrowser.min.css");
@import url("main.css");
......
......@@ -2,5 +2,13 @@ class ProjectsController < ApplicationController
respond_to :js
def show
@project = Project.friendly.find(params[:id])
@liqpay_request = Liqpay::Request.new(
amount: '999.99',
currency: 'UAH',
order_id: '123',
description: 'Some Product',
public_key: 'sandbox_i30820512794',
private_key: 'sandbox_0zBjPvvb13LMKaqRWJScxzqRz1EzZquRKZcXdUex'
)
end
end
\ No newline at end of file
end
......@@ -16,13 +16,25 @@ class UsersController < ApplicationController
def create
@user = User.find_or_create_by(user_params)
@user.skip_password_validation = true
respond_to do |format|
if @user.save
format.html { redirect_to root_path }
format.js
else
format.html
@errorEmail = []
@errorName = []
@errorContribution = []
if params[:contributions_attributes][:contribution] < '1'
@errorContribution.push('Amount must be greater than or equal 1 uah')
end
# @liqpay = Liqpay.new
if @user.save
# Contribution.create(contribution: params[:contributions_attributes][:contribution], user_id: @user.id)
else
respond_to do |format|
format.js
@user.errors.any?
if (@user.errors["email"] != nil)
@errorEmail.push(@user.errors["email"][0])
end
if (@user.errors["name"] != nil)
@errorName.push(@user.errors["name"][0])
end
end
end
end
......@@ -66,7 +78,7 @@ class UsersController < ApplicationController
end
def user_params
params.require(:user).permit(:email, :name, :location, :picture, :avatar, :role)
params.require(:user).permit(:email, :name, :location, :picture, :avatar, :role, contributions_attributes: [:id, :user_id, :contribution])
end
end
\ No newline at end of file
class User < ApplicationRecord
attr_accessor :skip_password_validation
after_initialize :set_default_role, :if => :new_record?
mount_uploader :avatar, AvatarUploader
has_many :contributions
accepts_nested_attributes_for :contributions
enum role: [:user, :admin]
validates :name, presence: true
def set_default_role
self.role ||= :user
end
......
class ContributionsService
# def initialize(contribution)
# @contribution = contribution
# end
# def params_project_partial
# [{title: 'description', position: 0},
# {title: 'project_galeries', position: 1},
# {title: 'project_qoutes', position: 2},
# {title: 'project_videos', position: 3},
# {title: 'project_photos', position: 4},
# {title: 'project_links', position: 5},
# {title: 'project_documents', position: 6}]
# end
# def set_project_partials
# @project.project_partials.create(params_project_partial)
# end
end
......@@ -4,15 +4,15 @@ class ProjectPartialsService
@project = project
end
def params_project_partial
[{title: 'description', position: 0},
{title: 'project_galeries', position: 1},
{title: 'project_qoutes', position: 2},
{title: 'project_videos', position: 3},
{title: 'project_photos', position: 4},
{title: 'project_links', position: 5},
{title: 'project_documents', position: 6}]
end
def params_project_partial
[{title: 'description', position: 0},
{title: 'project_galeries', position: 1},
{title: 'project_qoutes', position: 2},
{title: 'project_videos', position: 3},
{title: 'project_photos', position: 4},
{title: 'project_links', position: 5},
{title: 'project_documents', position: 6}]
end
def set_project_partials
@project.project_partials.create(params_project_partial)
......
......@@ -13,8 +13,10 @@
%meta{:content => "IE=edge", "http-equiv" => "X-UA-Compatible"}
%link{:href => "https://cdn.jsdelivr.net/bxslider/4.2.12/jquery.bxslider.css", :rel => "stylesheet"}/
/ %script{:src => "https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"}
%script{src: "https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"}
%script{:src => "https://cdn.jsdelivr.net/bxslider/4.2.12/jquery.bxslider.min.js"}
/Fonts
%script{:src => "https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"}
/Fonts
%link{:href => "//fonts.googleapis.com/css?family=Open+Sans:400,600,700", :rel => "stylesheet", :type => "text/css"}
%link{:href => "//fonts.googleapis.com/css?family=PT+Sans:400,700italic,700,400italic", :rel => "stylesheet", :type => "text/css"}
%link{:href => "//fonts.googleapis.com/css?family=Noto+Serif:400,400italic&subset=latin,cyrillic-ext", :rel => "stylesheet", :type => "text/css"}
......@@ -24,6 +26,8 @@
%link{:href => "https://fonts.googleapis.com/css?family=Montserrat:300|Six+Caps", :rel => "stylesheet"}
%body
= render 'partials/modal'
= render 'partials/modal_payment'
= render 'partials/modal_registration'
- if current_page?('/') || current_page?('/en') || current_page?('/uk')
= render 'partials/black_header'
- else
......
......@@ -46,20 +46,20 @@
= image_tag ("login.png")
- else
#sign_in
.dropdown.user_dropdown
%button#dropdownMenu1.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"}
- if current_user.avatar?
= image_tag(current_user.avatar_url)
- else
= image_tag "https://cdn1.iconfinder.com/data/icons/rcons-user-action/512/user-512.png"
%ul.dropdown-menu{"aria-labelledby" => "dropdownMenu1"}
- if current_user.admin?
%li
%a{:href => "/admin"}= t 'header.admin'
%li
%a{:href => "#"}= t 'header.profile'
%li
= link_to("#{t 'header.log_out'}", destroy_user_session_path, method: :delete)
.dropdown.user_dropdown
%button#dropdownMenu1.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"}
- if current_user.avatar?
= image_tag(current_user.avatar_url)
- else
= image_tag "https://cdn1.iconfinder.com/data/icons/rcons-user-action/512/user-512.png"
%ul.dropdown-menu{"aria-labelledby" => "dropdownMenu1"}
- if current_user.admin?
%li
%a{:href => "/admin"}= t 'header.admin'
%li
%a{:href => "#"}= t 'header.profile'
%li
= link_to("#{t 'header.log_out'}", destroy_user_session_path, method: :delete)
.search_block
%input#search_field.search_field{placeholder: "#{t 'header.find_by_name'}", :type => "text"}/
%button.search_btn
......
#modal.modal.fade.modal_styled.in{"aria-labelledby" => "modalLabel", :role => "dialog", :tabindex => "-1"}
#modal.modal.modal_styled.in{"aria-labelledby" => "modalLabel", :role => "dialog", :tabindex => "-1"}
.modal-dialog{:role => "document"}
.modal-content
#user_form
= simple_form_for :user, html: {autocomplete: 'off'}, remote: true, url: users_path do |f|
= simple_form_for :user, remote: true, html: { novalidate: true, autocomplete: 'off' }, url: users_path do |f|
.modal-header
.modal-header_top.clearfix
.modal-header_top_bg
......@@ -17,7 +17,9 @@
%h3#modalLabel.modal-title The funding
.col-sm-7.modal-header_bot_amount
.form-group.amount
/ = f.input :name, label: 'Amount in UAH', required: false, input_html: { class: 'form-group amount_field' }
= simple_fields_for :contributions_attributes do |contributions_form|
= contributions_form.input :contribution, required: false, label: 'Amount in UAH', input_html: { class: 'form-group amount_field' }
%span.error_text#contributionBlock.help-block
%span.error_text
#required_fields.help_text.absolute
%span.asterisk *
......@@ -30,11 +32,13 @@
.form-group
= f.label :email, 'E-mail'
.field_wrap
= f.input :email, label: false, required: false
%span.error_text
= f.input :email, label: false
%span.error_text#emailBlock.help-block
.form-group
= f.label :name, 'Fist name and Last name'
.field_wrap
= f.input :name, label: false, required: false
= f.input :name, label: false
%span.error_text#nameBlock.help-block
%span.error_text
.col-sm-3.modal-body_registration
%h4.modal_subtitle
......@@ -46,101 +50,3 @@
%i.icon.icon_google
.text-center
= f.submit "Next step", class: "btn btn_primary", "data-target" => "#modal2"
/ %button#create_step.btn.btn_primary{"data-target" => "#modal2", :name => "button", :type => "submit"} Далі
/ #modal2.modal.fade.modal_styled.in{"aria-labelledby" => "modalLabel", :role => "dialog", :tabindex => "-1"}
/ .modal-dialog{:role => "document"}
/ .modal-content
/ #user_form
/ %form{"accept-charset" => "UTF-8", :action => "/uk/users", "data-remote" => "true", :method => "post"}
/ %input{:name => "utf8", :type => "hidden", :value => "✓"}/
/ %input#for_map_false{:name => "user[for_map]", :type => "hidden", :value => "false"}/
/ .modal-header
/ .modal-header_top.clearfix
/ .modal-header_top_bg
/ .modal-header_steps_wrap
/ %span#first_step.modal-header_step Крок 1
/ %span#second_step.modal-header_step.active Крок 2
/ %button.round_link.close{"aria-label" => "Close", "data-dismiss" => "modal", :type => "button"}
/ %i.icon.icon_close
/ .modal-header_bot
/ .row
/ .col-sm-5
/ %h3#modalLabel.modal-title Фондування
/ .col-sm-7.modal-header_bot_amount
/ .form-group.amount.form_ok
/ %label{:for => "id_1"}
/ Сума внеску в
/ %span.currency UAH
/ %span#amount_line.amount_value{:style => ""} 23,00
/ %input#field_amount.form-control.amount_field{:name => "amount", :style => "display: none;", :type => "text", :value => "23,00"}/
/ %span.error_text
/ #required_fields.help_text.absolute{:style => "display: none;"}
/ %span.asterisk *
/ Заповніть всі поля
/ #body_user.modal-body{:style => "display: none;"}
/ .row
/ .col-sm-9.modal-body_login
/ %h4.modal_subtitle
/ Авторизація
/ .form-group.form_ok
/ %label{:for => "id_3"} E-mail
/ .field_wrap
/ %input#user_email.form-control{:autocomplete => "off", :name => "user[email]", :placeholder => "", :type => "text", :value => "misasdda@gmail.com"}/
/ %span.error_text
/ .form-group.form_ok
/ %input#project_id{:name => "project_id", :type => "hidden", :value => ""}/
/ %label{:for => "id_2"} Ім'я та прізвище
/ .field_wrap
/ %input#user_name.form-control.user_name{:name => "user[name]", :placeholder => "", :type => "text", :value => "cdcdscs"}/
/ %span.error_text
/ .checkbox.checkbox_padd
/ %input{:name => "user[is_signed]", :type => "hidden", :value => "0"}/
/ %input#user_check{:name => "user[is_signed]", :placeholder => "Підписатися на новини", :type => "checkbox", :value => "1"}/
/ %label{:for => "user_check"} Підписатися на новини
/ .col-sm-3.modal-body_registration
/ %h4.modal_subtitle
/ Швидка реєстрація
/ .soc_btn_wrap.clearfix
/ %a.soc_btn.soc_btn_fb{:href => "/users/auth/facebook?for_map=false&locale=uk"}
/ %i.icon.icon_fb
/ %a.soc_btn.soc_btn_tw{:href => "/users/auth/twitter?for_map=false&locale=uk"}
/ %i.icon.icon_tw
/ %a.soc_btn.soc_btn_google{:href => "/users/auth/google_oauth2?for_map=false&locale=uk"}
/ %i.icon.icon_google
/ .text-center
/ %button#create_step.btn.btn_primary{"data-target" => "#modal2", :name => "button", :type => "submit"} Далі
/ #body_payment_system.modal-body
/ .help_text Оберіть платіжну систему зручну для вас
/ .radio
/ .radio_item
/ %input#webmoney.payment_system{:checked => "checked", :name => "payment_system", :type => "radio", :value => "wayforpay"}/
/ %label{:for => "webmoney"}
/ %img{:alt => "", :src => "/assets/w4p_white-b437ac64b5311e3e1682da87862a883baa8ba683c005e8932a95f3a41fad24c3.png"}/
/ .radio_item
/ %input#liqpay.payment_system{:name => "payment_system", :type => "radio", :value => "liqpay"}/
/ %label{:for => "liqpay"}
/ %img{:alt => "", :src => "/assets/liqpay-b8fcd029cbf27dedd5ad1da07f269d069770446e7ef2aa5a079c0cf1fe4b56e2.png"}/
/ .text-center.modal_btns
/ %form{"accept-charset" => "utf-8", :action => "https://www.liqpay.com/api/3/checkout", :method => "post"}
/ %input{:name => "data", :type => "hidden", :value => "eyJ2ZXJzaW9uIjoiMyIsImFjdGlvbiI6InBheSIsImFtb3VudCI6IjIzLjAiLCJjdXJyZW5jeSI6IlVBSCIsImRlc2NyaXB0aW9uIjoiRG9icm92aWxuYSBwb3poZXJ0dmEiLCJvcmRlcl9pZCI6IjEwNTkiLCJzYW5kYm94IjoiMSIsImxhbmd1YWdlIjoidWsiLCJzZXJ2ZXJfdXJsIjoiaHR0cDovL3ZtMjA5LmJ2YmxvZ2ljLm5ldC9saXFwYXlfY2FsbGJhY2s/bG9jYWxlPXVrIiwicmVzdWx0X3VybCI6Imh0dHA6Ly92bTIwOS5idmJsb2dpYy5uZXQvbGlxcGF5X3BheW1lbnRzP2xvY2FsZT11ayIsInB1YmxpY19rZXkiOiJpMzc4NjQ2NDQ5NDcifQ=="}/
/ %input{:name => "signature", :type => "hidden", :value => "YNI9UbDLRDbkBR2h9Kp+hQlcR6E="}/
/ %input#liqpay_button.btn.btn_primary.hidden{:name => "btn_text", :src => "", :type => "submit", :value => "Оплатити"}/
/ %form#wayforpay_form{:action => "https://secure.wayforpay.com/pay", :method => "POST"}
/ %input#merchantAccount{:name => "merchantAccount", :type => "hidden", :value => "vm209_bvblogic_net"}/
/ %input#merchantDomainName{:name => "merchantDomainName", :type => "hidden", :value => "bvblogic.net"}/
/ %input#merchantTransactionSecureType{:name => "merchantTransactionSecureType", :type => "hidden", :value => "AUTO"}/
/ %input#merchantAuthType{:name => "merchantAuthType", :type => "hidden", :value => "SimpleSignature"}/
/ %input#orderReference{:name => "orderReference", :type => "hidden", :value => "1059-2019-11-06-13-10-15-utc"}/
/ %input#orderDate{:name => "orderDate", :type => "hidden", :value => "1573045815"}/
/ %input#amount{:name => "amount", :type => "hidden", :value => "23.0"}/
/ %input#currency{:name => "currency", :type => "hidden", :value => "UAH"}/
/ %input#productName_{:name => "productName[]", :type => "hidden", :value => "Dobrovilna pozhertva"}/
/ %input#productPrice_{:name => "productPrice[]", :type => "hidden", :value => "23.0"}/
/ %input#productCount_{:name => "productCount[]", :type => "hidden", :value => "1"}/
/ %input#merchantSignature{:name => "merchantSignature", :type => "hidden", :value => "e032df73df2689fcbab4350d823ce012"}/
/ %input#returnUrl{:name => "returnUrl", :type => "hidden", :value => "http://warm.if.ua/wayforpay_payments"}/
/ %input#serviceUrl{:name => "serviceUrl", :type => "hidden", :value => "http://warm.if.ua/wayforpay_callback"}/
/ %button#wayforpay_button.btn.btn_primary{:type => "submit"} Оплатити
/ .nav_link
/ %a#back_step.link{:href => "#"} Назад
\ No newline at end of file
#modal_payment.modal.modal_styled{"aria-labelledby" => "modalLabel", :role => "dialog", :tabindex => "-1"}
.modal-dialog{:role => "document"}
.modal-content
.modal-header
.modal-header_top.clearfix
.modal-header_top_bg
.modal-header_steps_wrap
%span.modal-header_step крок 1
%span.modal-header_step.active крок 2
%button.round_link.close{"aria-label" => "Close", "data-dismiss" => "modal", :type => "button"}
%i.icon.icon_close
.modal-header_bot
.row
.col-sm-5
%h3#modalLabel.modal-title Фондування
.col-sm-7.modal-header_bot_amount
.form-group
%label{:for => "id_1"}
Сума внеску в
%span.currency UAH
%span.amount_value 1 000 000 000
.modal-body
.help_text Оберіть платіжну систему зручну для вас
.radio
.radio_item
%input#liqpay{:checked => "checked", :name => "payment_system", :type => "radio", :value => "liqpay"}
%label{:for => "liqpay"}
= image_tag('liqpay.png')
.radio_item
%input#webmoney{:name => "payment_system", :type => "radio", :value => "webmoney"}/
%label{:for => "webmoney"}
= image_tag('w4p_white.png')
.text-center.modal_btns
%a.btn.btn_primary{:href => "#"} оплатити
.nav_link
%a.link{"data-dismiss" => "modal", "data-target" => "#modal", "data-toggle" => "modal", :type => "button"} Назад
= liqpay_button Liqpay::Request.new(amount: '999.99', currency: 'UAH',order_id: '123', description: 'Some Product', public_key: 'sandbox_i30820512794',private_key: 'sandbox_0zBjPvvb13LMKaqRWJScxzqRz1EzZquRKZcXdUex'), title: "Pay now!"
= simple_form_for :user, url: users_path, authenticity_token: true do |f|
#modal3.modal.fade.modal_styled{"aria-labelledby" => "modalLabel", :role => "dialog", :tabindex => "-1"}
#modal3.modal.fade.modal_styled.in{"aria-labelledby" => "modalLabel", :role => "dialog", :tabindex => "-1"}
.modal-dialog{:role => "document"}
.modal-content
.modal-header
......
......@@ -12,6 +12,7 @@
= t ('donate')
.large_progress_wrap
.large_progress_title
= liqpay_button @liqpay_request, title: "Pay now!"
= t "#{@project.status}"
.project_content
.project_partials
......@@ -27,6 +28,7 @@
%a.btn.btn_default{"data-target" => "#modal", "data-toggle" => "modal", :href => "#"}
%i.icon.icon_plus>
підтримати проект
#simple
.news_wrap
.container.grid_padding_xs
%h3.heading_mb
......
$('#modal').append(<%= j (render('partials/modal')) %>);
\ No newline at end of file
$(".notice").remove();
$(".form-group").removeClass("has-error");
$("#emailBlock").html("#{escape_javascript(@errorEmail[0])}");
$("#emailBlock:contains(Email)").closest(".form-group").addClass("has-error");
$("#nameBlock").html("#{escape_javascript(@errorName[0])}");
$("#nameBlock:contains(Name)").closest(".form-group").addClass("has-error");
$("#contributionBlock").html("#{escape_javascript(@errorContribution[0])}");
$("#contributionBlock:contains()").closest(".form-group").addClass("has-success");
$("#contributionBlock:contains(1)").closest(".form-group").addClass("has-error");
\ No newline at end of file
......@@ -7,6 +7,7 @@ require 'carrierwave/processing/mini_magick'
require 'awesome_print'
require 'acts_as_list'
require 'liqpay'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
......
Liqpay.default_options = {
public_key: 'sandbox_i30820512794',
private_key: 'sandbox_0zBjPvvb13LMKaqRWJScxzqRz1EzZquRKZcXdUex',
currency: 'UAH'
}
\ No newline at end of file
......@@ -7,6 +7,8 @@ uk:
email:
blank: "Email can't be blank"
invalid: "Email is invalid"
name:
blank: "Name can't be blank"
time:
formats:
short: "%Y-%m-%d %H:%M:%S"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment