From 4b05510feb7bd9fcf0b2db2648eb00a725517bc5 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Fri, 9 Feb 2018 10:07:18 +0100 Subject: [PATCH] suite --- Gemfile | 3 + Gemfile.lock | 6 + app/controllers/application_controller.rb | 12 + .../public/abonnements_controller.rb | 27 ++ app/controllers/public/needs_controller.rb | 2 +- app/controllers/public/payments_controller.rb | 453 ++++++++++++++++++ app/models/abonnement.rb | 22 + app/models/customer.rb | 3 + app/models/payment.rb | 23 + app/views/public/abonnements/new.html.haml | 12 + app/views/public/payments/paid.html.haml | 12 + .../public/payments/paid_by_ogone.html.haml | 10 + .../payments/paid_by_ogone_confirm.html.haml | 4 + config/environments/development.rb | 2 +- config/initializers/ogone.rb | 1 + config/ogone.yml | 24 + config/routes.rb | 14 + .../20180209004732_create_abonnements.rb | 16 + db/migrate/20180209010600_create_payments.rb | 46 ++ db/schema.rb | 47 +- test/fixtures/abonnements.yml | 17 + test/fixtures/payments.yml | 9 + test/models/abonnement_test.rb | 7 + test/models/payment_test.rb | 7 + 24 files changed, 776 insertions(+), 3 deletions(-) create mode 100755 app/controllers/public/abonnements_controller.rb create mode 100644 app/controllers/public/payments_controller.rb create mode 100644 app/models/abonnement.rb create mode 100644 app/models/payment.rb create mode 100644 app/views/public/abonnements/new.html.haml create mode 100644 app/views/public/payments/paid.html.haml create mode 100644 app/views/public/payments/paid_by_ogone.html.haml create mode 100644 app/views/public/payments/paid_by_ogone_confirm.html.haml create mode 100644 config/initializers/ogone.rb create mode 100644 config/ogone.yml create mode 100644 db/migrate/20180209004732_create_abonnements.rb create mode 100644 db/migrate/20180209010600_create_payments.rb create mode 100644 test/fixtures/abonnements.yml create mode 100644 test/fixtures/payments.yml create mode 100644 test/models/abonnement_test.rb create mode 100644 test/models/payment_test.rb diff --git a/Gemfile b/Gemfile index 93ff100..94f0b61 100755 --- a/Gemfile +++ b/Gemfile @@ -79,3 +79,6 @@ gem "posix-spawn" gem 'rubyzip', '>= 1.0.0' # will load new rubyzip version gem 'zip-zip' # will load compatibility for old rubyzip API. + + +gem 'ogone-rails' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 6e00749..3d5d0fc 100755 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -130,6 +130,8 @@ GEM net-ssh (>= 2.6.5) nokogiri (1.6.6.2) mini_portile (~> 0.6.0) + ogone-rails (0.1.10) + activesupport paranoia (2.1.4) activerecord (~> 4.0) posix-spawn (0.3.11) @@ -250,6 +252,7 @@ DEPENDENCIES kaminari-bootstrap mysql2 net-ssh (~> 2.7.0) + ogone-rails paranoia (~> 2.0) posix-spawn rails (= 4.2.0) @@ -269,3 +272,6 @@ DEPENDENCIES wkhtmltopdf-binary workflow (~> 1.2.0) zip-zip + +BUNDLED WITH + 1.16.1 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a406f32..ca6bee5 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -61,6 +61,18 @@ class ApplicationController < ActionController::Base private + def current_abo + if current_customer + abo = current_customer.abonnements.where(:paid => true).where("start_at <= ? and end_at >= ?", Time.now, Time.now).first + end + end + + def require_negos_abo + if !current_abo + redirect_to new_public_abonnement_path + end + end + def auth_admin if !current_admin redirect_to new_admin_admin_auth_path diff --git a/app/controllers/public/abonnements_controller.rb b/app/controllers/public/abonnements_controller.rb new file mode 100755 index 0000000..fc27704 --- /dev/null +++ b/app/controllers/public/abonnements_controller.rb @@ -0,0 +1,27 @@ +# -*- encoding : utf-8 -*- + +class Public::AbonnementsController < ApplicationController + + before_filter :auth_customer + layout "public" + + def new + @abonnement = current_customer.abonnements.new(:price => 300.0, :start_at => Time.now, :end_at => (Time.now+13.months).end_of_day, :slug => "negos-principal") + end + + def create + @abonnement = current_customer.abonnements.new(:price => 300.0, :start_at => Time.now, :end_at => (Time.now+13.months).end_of_day, :slug => "negos-principal") + + if @abonnement.save + session[:abonnement_id] = @abonnement + + @payment = @abonnement.payments.create(:amount => @abonnement.total_price_ttc, :payment_type_id => 1, :customer_id => current_customer.id) + session[:payment_id] = @payment.id + redirect_to paid_by_ogone_public_payment_path(@payment) + else + redirect_to :action => :new + end + + end + +end diff --git a/app/controllers/public/needs_controller.rb b/app/controllers/public/needs_controller.rb index 330f239..976aa8c 100755 --- a/app/controllers/public/needs_controller.rb +++ b/app/controllers/public/needs_controller.rb @@ -1,7 +1,7 @@ class Public::NeedsController < ApplicationController layout "public" - + before_filter :require_negos_abo before_filter :auth_customer before_filter :check_enabled diff --git a/app/controllers/public/payments_controller.rb b/app/controllers/public/payments_controller.rb new file mode 100644 index 0000000..828a877 --- /dev/null +++ b/app/controllers/public/payments_controller.rb @@ -0,0 +1,453 @@ +# -*- encoding : utf-8 -*- + +class Public::PaymentsController < ApplicationController + + layout "public" + + skip_before_filter :verify_authenticity_token, :only => [:payplug_ipn, :paypal_ipn, :ogone_ipn] + + def paid + @payment = current_customer.payments.find(params[:id]) + + if params[:orderID] + if @payment.ogone_payid? and !@payment.element.paid + @abonnement = @payment.element + @payment = @abonnement.payments.create(:amount => @abonnement.total_price_ttc, :payment_type_id => 1, :customer_id => current_customer.id) + end + end + + end + def paid_by_ogone + + @payment = current_customer.payments.find(params[:id]) + + if @payment.paid + render :inline => "paiement déjà enregistré" + #redirect_to new_public_donator_transaction_path(:paid => true) + else + + + + @ogone_options = { + :amount => @payment.amount, + :accept_url => "http://#{HOSTNAME}"+paid_by_ogone_confirm_public_payment_path(@payment.id), + :decline_url => "http://#{HOSTNAME}"+paid_public_payment_path(@payment.id), + :exception_url => "http://#{HOSTNAME}"+paid_public_payment_path(@payment.id), + :cancel_url => "http://#{HOSTNAME}"+paid_public_payment_path(@payment.id), + :orderid => @payment.token, + :PARAMVAR => "ogoneipn", + :PSPID => OgoneRails::pspid, + :currency => OgoneRails::currency, + :language => OgoneRails::language, + + } + + + + end + + end + + + + def paid_by_ogone_confirm + + @check = OgoneRails::CheckAuth.new( request ) + + if @check.valid? + + @payment = Payment.find_by_token(params[:orderID]) + + + + end + + if !@payment.paid + update_ogone_infos() + + end + + + + if !@payment.paid + + #render :inline => "pas payé" + #redirect_to paid_public_payment_path(@payment) + end + + + end + + + def ogone_ipn + + update_ogone_infos() + + render :inline => "ok" + + end + + + + + + #------------------------------ + + + + + + def paid_by_paypal + @donator_transaction = DonatorTransaction.find(session[:donator_transaction_id]) + + if @donator_transaction.paid + redirect_to new_public_donator_transaction_path(:paid => true) + else + @payment = Payment.create(:tr_payment_type_id => 6) + @donator_transaction.tr_payments << @payment + + require 'paypal-sdk-merchant' + @api = PayPal::SDK::Merchant::API.new + + + @set_express_checkout = @api.build_set_express_checkout({ + :SetExpressCheckoutRequestDetails => { + :custom => @payment.token, + :ReturnURL => do_paypal_payment_public_donator_transaction_url(@donator_transaction.id), + :CancelURL => edit_public_donator_transaction_url(@donator_transaction.id), + :NoShipping => 1, + :PaymentDetails => [{ + :OrderTotal => { + :currencyID => "EUR", + :value =>@donator_transaction.total }, + + :NotifyURL => "http://#{HOSTNAME}"+paypal_ipn_public_donator_transaction_path(@donator_transaction), + :ShipToAddress => { + :Name => @donator_transaction.particular_bill.name.to_s+" "+@donator_transaction.particular_bill.firstname.to_s, + :Street1 => @donator_transaction.particular_bill.address_2, + :Street2 => @donator_transaction.particular_bill.address_3, + :CityName => @donator_transaction.particular_bill.city.upcase, + :StateOrProvince => "", + :Country => @donator_transaction.particular_bill.country.upcase, + :PostalCode => @donator_transaction.particular_bill.cp.upcase }, + + :PaymentAction => "Sale" }] } }) + + # Make API call & get response + @set_express_checkout_response = @api.set_express_checkout(@set_express_checkout) + + # Access Response + if @set_express_checkout_response.success? + + @get_express_checkout_details = @api.build_get_express_checkout_details({ + :Token => @donator_transaction.token }) + + @get_express_checkout_details_response = @api.get_express_checkout_details(@get_express_checkout_details) + + + + + @payment_detail = @get_express_checkout_details_response.GetExpressCheckoutDetailsResponseDetails.PaymentDetails[0] + + + redirect_to @api.express_checkout_url(@set_express_checkout_response.Token) + else + @set_express_checkout_response.Errors + end + end + end + + + + def do_paypal_payment + load_specific_page if @new_site + + require 'paypal-sdk-merchant' + @api = PayPal::SDK::Merchant::API.new + + + @get_express_checkout_details = @api.build_get_express_checkout_details({:Token => params[:token] }) + + @get_express_checkout_details_response = @api.get_express_checkout_details(@get_express_checkout_details) + + + + + # Access Response + if @get_express_checkout_details_response.success? + + + @payment = Payment.find_by_token(@get_express_checkout_details_response.GetExpressCheckoutDetailsResponseDetails.Custom.to_s) + + + @order = @payment.donator_transaction + + + + + else + + + @get_express_checkout_details_response.Errors + end + + # Build request object + @do_express_checkout_payment = @api.build_do_express_checkout_payment({ + :DoExpressCheckoutPaymentRequestDetails => { + :PaymentAction => "Sale", + :Token => params[:token], + :PayerID => params[:PayerID], + :PaymentDetails => [{ + :OrderTotal => { + :currencyID => "EUR", + :value => @order.total }, + :NotifyURL => "http://#{HOSTNAME}"+paypal_ipn_public_donator_transaction_path(@order) }] } }) + + # Make API call & get response + @do_express_checkout_payment_response = @api.do_express_checkout_payment(@do_express_checkout_payment) + + # Access Response + if @do_express_checkout_payment_response.success? + @payment_info = @do_express_checkout_payment_response.DoExpressCheckoutPaymentResponseDetails.PaymentInfo[0] + + @do_express_checkout_payment_response.DoExpressCheckoutPaymentResponseDetails + @do_express_checkout_payment_response.FMFDetails + + + + + + + + + if @payment_info.PaymentStatus.to_s == "Completed" + + params[:payment_status] ="Completed" + update_paypal_infos() + + + else + redirect_to select_payment_public_donator_transaction_path(@donator_transaction.id) + #render :file => 'public/500.html', :status => 500, :layout => false + + end + + + + + + + + else + render :file => 'public/500.html', :status => 500, :layout => false + end + + + + + end + + def paypal_ipn + + + @api = PayPal::SDK::Merchant.new + if @api.ipn_valid?(request.raw_post) # return true or false + @payment = Payment.find_by_token(params[:custom].to_s) + + @order = @payment.donator_transaction + + + + # @order.payment_type= 6 + # @order.paid = true + # @order.paid_at = Time.now + + @payment.paypal_test_ipn= params[:test_ipn] + + @payment.paypal_txn_type = params[:txn_type] + @payment.paypal_txn_id = params[:txn_id] + @payment.paypal_payment_date = params[:payment_date] + + @payment.paypal_payment_status = params[:payment_status] + @payment.paypal_reason_code = params[:reason_code] + @payment.paypal_payment_type = params[:payment_type] + + @payment.paypal_mc_currency = params[:mc_currency] + @payment.paypal_mc_fee = params[:mc_fee] + @payment.paypal_mc_gross = params[:mc_gross] + + @payment.paypal_residence_country = params[:residence_country] + + + if params[:charset] == "windows-1252" + + else + @payment.paypal_last_name = params[:last_name] + @payment.paypal_first_name = params[:first_name] + @payment.paypal_payer_email = params[:payer_email] + end + @payment.paypal_payer_id = params[:payer_id] + @payment.paypal_payer_status = params[:payer_status] + + @payment.paypal_receiver_id = params[:receiver_id] + @payment.paypal_receiver_email = params[:receiver_email] + + @payment.paypal_protection_eligibility = params[:protection_eligibility] + @payment.paypal_ipn_track_id = params[:ipn_track_id] + + + update_paypal_infos() + + + + + + + + + + else + + end + render :inline => "test" + end + + + + #------ + + + + + + + + + + protected + + def update_ogone_infos + + @check = OgoneRails::CheckAuth.new( request ) + + if @check.valid? + + @payment = Payment.find_by_token(params[:orderID]) + + + + + #### + @payment.payment_type_id = 1 + @payment.amount = params[:amount].to_f + + @payment.ogone_payid = params[:PAYID] + @payment.ogone_pm = params[:PM] + @payment.ogone_status = params[:STATUS] + @payment.ogone_acceptance = params[:ACCEPTANCE] + @payment.ogone_cardno = params[:CARDNO] + @payment.ogone_ed = params[:ED] + @payment.ogone_cn = params[:CN] + @payment.ogone_trxdate = params[:TRXDATE] + @payment.ogone_ncerror = params[:NCERROR] + @payment.ogone_brand = params[:BRAND] + @payment.ogone_subbrand = params[:SUBBRAND] + @payment.ogone_eci = params[:ECI] + @payment.ogone_ip = params[:IP] + @payment.ogone_alias = params[:ALIAS] + @payment.ogone_cb_expiration = Date.parse(params[:ED][2..3].to_s+"/"+params[:ED][0..1].to_s+"/01") if params[:ED] + + + + + + + + if params["STATUS"].to_i == 9 + if !@payment.paid + @payment.paid_at = Time.now + + + + @payment.paid = true + + + end + + else + @payment.paid = false + + end + + @payment.save + + if @payment.paid and @payment.element + + @payment.element.after_paid + + end + + + + + end + + + end + + + def update_paypal_infos + + if params[:payment_status] == "Completed" + if !@order.paid + @payment.paid_at = Time.now + + @order.paid_at = @payment.paid_at + + @order.paid = true + + if @order.recurrent + + @order = true + + DonateTransactionsMails.general("fr", "confirmation_paypal_rec", @order).deliver + else + @gen_recu = true + DonateTransactionsMails.general("fr", "confirmation_paypal", @order).deliver + end + @order.check_newsletter + + end + + else + @order.paid = false + + end + @order.completed_finish = true + + @payment.save + @order.tr_payment_ok = @payment if @order.paid + @order.save + + + + if @generate_recurrent + + @order.create_recurrent_payment + @order.generated_recurrent_payment.generate_infos + + + end + + if @gen_recu + @order.generate_recu + end + + + + end + + + + +end \ No newline at end of file diff --git a/app/models/abonnement.rb b/app/models/abonnement.rb new file mode 100644 index 0000000..ad7ee54 --- /dev/null +++ b/app/models/abonnement.rb @@ -0,0 +1,22 @@ +class Abonnement < ActiveRecord::Base + + has_many :payments, :as => :element + + def after_paid + self.paid = true + self.save + end + + def total_price_ht + self.price + end + + def total_price_ttc + total_price_ht + total_price_ht * tva + end + + def tva + 0.2 + end + +end diff --git a/app/models/customer.rb b/app/models/customer.rb index 5e513ab..cbcb026 100755 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -1,5 +1,8 @@ class Customer < ActiveRecord::Base + has_many :abonnements + has_many :payments + belongs_to :particular_bill, :class_name => "Particular" accepts_nested_attributes_for :particular_bill diff --git a/app/models/payment.rb b/app/models/payment.rb new file mode 100644 index 0000000..3fef298 --- /dev/null +++ b/app/models/payment.rb @@ -0,0 +1,23 @@ +class Payment < ActiveRecord::Base + + belongs_to :element, :polymorphic => true + + before_create do + generate_token + end + + before_validation do + self.iban = self.iban.to_s.gsub(/\s+/, "") + end + + def generate_token + + if !self.token + begin + self.token = SecureRandom.hex(8) + end while Payment.exists?(:token => self.token) + + end + end + +end diff --git a/app/views/public/abonnements/new.html.haml b/app/views/public/abonnements/new.html.haml new file mode 100644 index 0000000..d3643f6 --- /dev/null +++ b/app/views/public/abonnements/new.html.haml @@ -0,0 +1,12 @@ + +=semantic_form_for [:public, @abonnement] do |f| + =f.hidden_field :start_at + =f.hidden_field :end_at + =f.hidden_field :price + =f.hidden_field :slug + + .center + + %p Pour profiter des fonctions de Négos, vous pouvez dès à présent souscrire à un abonnement pour 300€ HT (360€ TTC) + + =submit_tag "Souscrire maintenant >", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/public/payments/paid.html.haml b/app/views/public/payments/paid.html.haml new file mode 100644 index 0000000..d9f7a91 --- /dev/null +++ b/app/views/public/payments/paid.html.haml @@ -0,0 +1,12 @@ +.center + %h1 + Payer mon abonnement + + -if params[:orderID] + %p + Votre paiement CB a échoué, pour tenter de nouveau merci de suivre ce lien : + %br + =link_to "Payer par CB", paid_by_ogone_public_payment_path(@payment), :class => "btn btn-primary" + -else + %p + =link_to "Payer par CB", paid_by_ogone_public_payment_path(@payment), :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/public/payments/paid_by_ogone.html.haml b/app/views/public/payments/paid_by_ogone.html.haml new file mode 100644 index 0000000..c683a49 --- /dev/null +++ b/app/views/public/payments/paid_by_ogone.html.haml @@ -0,0 +1,10 @@ +.center + %p Vous allez être redirigé automatiquement sur le serveur de paiement sécurisé par Ogone. Si ce n'est pas le cas, merci de cliquer sur "payer maintenant" + %form{:action => CONFIG_OGONE["ecom_url"], :id => "ogone_form"} + -form_content = ogone_fields(@ogone_options) + -form_content << '' + =raw form_content + + :javascript + $("#ogone_form").submit() + diff --git a/app/views/public/payments/paid_by_ogone_confirm.html.haml b/app/views/public/payments/paid_by_ogone_confirm.html.haml new file mode 100644 index 0000000..99e8032 --- /dev/null +++ b/app/views/public/payments/paid_by_ogone_confirm.html.haml @@ -0,0 +1,4 @@ +.center + %h1 Merci pour votre paiement ! + %p + Vous pouvez désormais profiter de votre abonnement. \ No newline at end of file diff --git a/config/environments/development.rb b/config/environments/development.rb index 2bf00e2..deef3bd 100755 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -44,5 +44,5 @@ Rails.application.configure do config.action_mailer.default_url_options = { host: 'localhost', port: 3000} - HOSTNAME="localhost:3000" + HOSTNAME="78.245.74.12"#"localhost:3000" end diff --git a/config/initializers/ogone.rb b/config/initializers/ogone.rb new file mode 100644 index 0000000..630e3bc --- /dev/null +++ b/config/initializers/ogone.rb @@ -0,0 +1 @@ +CONFIG_OGONE = YAML.load_file("#{Rails.root.to_s}/config/ogone.yml")[Rails.env] diff --git a/config/ogone.yml b/config/ogone.yml new file mode 100644 index 0000000..fe95cfd --- /dev/null +++ b/config/ogone.yml @@ -0,0 +1,24 @@ +development: + pspid: "NEGOS" + sha_in: "Mysecretsig1875!?" + sha_in_dl: " " + sha_out: "MyDSecretsig1875!?" + currency: "EUR" + language: "fr_FR" + direct_url: "https://secure.ogone.com/ncol/test/orderdirect.asp" + ecom_url: "https://secure.ogone.com/ncol/test/orderstandard_utf8.asp" + api_user: " " + api_pswd: " " + mode: 'test' +production: + pspid: "NEGOS" + sha_in: "MysecrVts!?ig1875" + sha_in_dl: " " + sha_out: "MyDSec!?radsig1865" + currency: "EUR" + language: "fr_FR" + direct_url: "https://secure.ogone.com/ncol/prod/orderdirect.asp" + ecom_url: "https://secure.ogone.com/ncol/prod/orderstandard_utf8.asp" + api_user: " " + api_pswd: " " + mode: 'live' \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index c11a3f8..257457f 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,6 +4,8 @@ Rails.application.routes.draw do get "vouisstar" => "public/home#vouisstar" + get "/ogoneipn" => "public/payments#ogone_ipn", :as => :ogone_ipn_public_payments + constraints subdomain: 'commander' do get "/" => "public/home#vouisstar" @@ -22,6 +24,18 @@ Rails.application.routes.draw do get 'p/:mlm_token' => "public/customers#parrainage", :as => :mlm_token namespace :public do + resources :payments do + member do + get :paid_by_ogone + get :paid_by_ogone_confirm + get :paid + end + collection do + get :ogone_ipn + end + end + resources :abonnements + resources :conversations get 'documents/:download_token', to: 'documents#download', as: :download_document diff --git a/db/migrate/20180209004732_create_abonnements.rb b/db/migrate/20180209004732_create_abonnements.rb new file mode 100644 index 0000000..628226b --- /dev/null +++ b/db/migrate/20180209004732_create_abonnements.rb @@ -0,0 +1,16 @@ +class CreateAbonnements < ActiveRecord::Migration + def change + create_table :abonnements do |t| + t.integer :abonnement_type_id + t.string :slug + t.datetime :start_at + t.datetime :end_at + t.boolean :paid + t.boolean :enabled + t.decimal :price, precision: 10, scale: 2 + t.references :customer + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20180209010600_create_payments.rb b/db/migrate/20180209010600_create_payments.rb new file mode 100644 index 0000000..0fd5539 --- /dev/null +++ b/db/migrate/20180209010600_create_payments.rb @@ -0,0 +1,46 @@ +class CreatePayments < ActiveRecord::Migration + def change + create_table :payments do |t| + t.references :customer + + t.string :element_type + t.integer :element_id + + t.datetime :paid_at + t.boolean :paid + + t.string :ogone_payid + t.string :ogone_pm + t.string :ogone_status + t.string :ogone_acceptance + t.string :ogone_cardno + t.string :ogone_ed + t.string :ogone_cn + t.string :ogone_trxdate + t.string :ogone_ncerror + t.string :ogone_brand + t.string :ogone_subbrand + t.string :ogone_eci + t.string :ogone_ip + t.string :ogone_alias + t.date :ogone_cb_expiration + + t.string :iban + t.string :bic + t.string :token + + t.string :check_number + t.string :check_bank + + t.decimal :amount, precision: 10, scale: 2 + t.integer :payment_type_id + + + + + + + t.timestamps null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 1d9be37..9964413 100755 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,20 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171220122439) do +ActiveRecord::Schema.define(version: 20180209010600) do + + create_table "abonnements", force: :cascade do |t| + t.integer "abonnement_type_id", limit: 4 + t.string "slug", limit: 255 + t.datetime "start_at" + t.datetime "end_at" + t.boolean "paid", limit: 1 + t.boolean "enabled", limit: 1 + t.decimal "price", precision: 10, scale: 2 + t.integer "customer_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end create_table "accepted_offers", force: :cascade do |t| t.datetime "created_at", null: false @@ -629,6 +642,38 @@ ActiveRecord::Schema.define(version: 20171220122439) do t.string "civilite", limit: 255 end + create_table "payments", force: :cascade do |t| + t.integer "customer_id", limit: 4 + t.string "element_type", limit: 255 + t.integer "element_id", limit: 4 + t.datetime "paid_at" + t.boolean "paid", limit: 1 + t.string "ogone_payid", limit: 255 + t.string "ogone_pm", limit: 255 + t.string "ogone_status", limit: 255 + t.string "ogone_acceptance", limit: 255 + t.string "ogone_cardno", limit: 255 + t.string "ogone_ed", limit: 255 + t.string "ogone_cn", limit: 255 + t.string "ogone_trxdate", limit: 255 + t.string "ogone_ncerror", limit: 255 + t.string "ogone_brand", limit: 255 + t.string "ogone_subbrand", limit: 255 + t.string "ogone_eci", limit: 255 + t.string "ogone_ip", limit: 255 + t.string "ogone_alias", limit: 255 + t.date "ogone_cb_expiration" + t.string "iban", limit: 255 + t.string "bic", limit: 255 + t.string "token", limit: 255 + t.string "check_number", limit: 255 + t.string "check_bank", limit: 255 + t.decimal "amount", precision: 10, scale: 2 + t.integer "payment_type_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "portlets", force: :cascade do |t| t.integer "block_id", limit: 4 t.integer "content_id", limit: 4 diff --git a/test/fixtures/abonnements.yml b/test/fixtures/abonnements.yml new file mode 100644 index 0000000..8658763 --- /dev/null +++ b/test/fixtures/abonnements.yml @@ -0,0 +1,17 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + abonnement_type_id: 1 + slug: MyString + start_at: 2018-02-09 01:47:32 + end_at: 2018-02-09 01:47:32 + paid: false + enabled: false + +two: + abonnement_type_id: 1 + slug: MyString + start_at: 2018-02-09 01:47:32 + end_at: 2018-02-09 01:47:32 + paid: false + enabled: false diff --git a/test/fixtures/payments.yml b/test/fixtures/payments.yml new file mode 100644 index 0000000..c4e83e6 --- /dev/null +++ b/test/fixtures/payments.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + paid_at: 2018-02-09 02:06:00 + paid: false + +two: + paid_at: 2018-02-09 02:06:00 + paid: false diff --git a/test/models/abonnement_test.rb b/test/models/abonnement_test.rb new file mode 100644 index 0000000..425e056 --- /dev/null +++ b/test/models/abonnement_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class AbonnementTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/payment_test.rb b/test/models/payment_test.rb new file mode 100644 index 0000000..13cc3cf --- /dev/null +++ b/test/models/payment_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PaymentTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end