cleaning the house
31
lib/Dojo.pm
@@ -22,11 +22,13 @@ use Dojo::Model::Vdgproc;
|
||||
$r->any('/')->to('home#home_');
|
||||
$r->any('/home')->to('home#home');
|
||||
$r->any('/pod')->to('home#podcast');
|
||||
$r->any('/store')->to('home#store');
|
||||
# $r->any('/store')->to('home#store');
|
||||
$r->any('/tv')->to('home#tv');
|
||||
$r->any('/contact')->to('home#contact');
|
||||
$r->any('/contact2')->to('home#contact2');
|
||||
$r->any('/pang')->to('home#pang');
|
||||
# json ==================
|
||||
$r->any('/json/*dreq')->to('data#simple');
|
||||
# =============================================================================
|
||||
|
||||
# de la tienda ================================================================
|
||||
@@ -35,12 +37,7 @@ use Dojo::Model::Vdgproc;
|
||||
$r->any('/spay/:class/:id' => [class => qr/\d+/, id => qr/\d+/])->to('proc#spay');
|
||||
$r->any('/spay/intentCreate')->to('proc#intentCreate');
|
||||
$r->any('/spay/intentConfirm')->to('proc#intentConfirm');
|
||||
# =============================================================================
|
||||
|
||||
# por matar ===================================================================
|
||||
$r->any('/xpay')->to('misc#stripe');
|
||||
$r->any('/storep')->to('home#storep');
|
||||
$r->any('/storep/:id' => [id => qr/\d+/])->to('home#storep');
|
||||
$r->any('/spay/userCheck')->to('proc#userCheck');
|
||||
# =============================================================================
|
||||
|
||||
# candy =======================================================================
|
||||
@@ -48,10 +45,6 @@ use Dojo::Model::Vdgproc;
|
||||
$r->any('/candy')->to('home#candy');
|
||||
# =============================================================================
|
||||
|
||||
# json ========================================================================
|
||||
$r->any('/json/*dreq')->to('data#simple');
|
||||
# =============================================================================
|
||||
|
||||
# usuarios y accesos ==========================================================
|
||||
$r->any('/reg')->to('users#reg');
|
||||
|
||||
@@ -74,14 +67,14 @@ use Dojo::Model::Vdgproc;
|
||||
|
||||
# admin =======================================================================
|
||||
my $admin = $r->under('/admin')->to('users#is_admin');
|
||||
$admin->any('')->to('home#admin');
|
||||
$admin->any('home')->to('home#admin_home');
|
||||
$admin->any('radio')->to('home#admin_radio');
|
||||
$admin->any('eventos')->to('home#admin_eventos');
|
||||
$admin->any('eventos/:type'=> [type=>['e','p','c']])->to('home#admin_eventos');
|
||||
$admin->any('mensajes')->to('home#admin_mensajes');
|
||||
$admin->any('tienda')->to('home#admin_tienda');
|
||||
$admin->any('json/:dreq/:id')->to('home#admin_json');
|
||||
$admin->any('')->to('admin#admin');
|
||||
$admin->any('home')->to('admin#admin');
|
||||
$admin->any('radio')->to('admin#radio');
|
||||
$admin->any('eventos')->to('admin#eventos');
|
||||
$admin->any('eventos/:type'=> [type=>['e','p','c']])->to('admin#eventos');
|
||||
$admin->any('mensajes')->to('admin#mensajes');
|
||||
$admin->any('tienda')->to('admin#tienda');
|
||||
$admin->any('json/:dreq/:id')->to('admin#json');
|
||||
|
||||
# =============================================================================
|
||||
|
||||
|
||||
82
lib/Dojo/Controller/Admin.pm
Normal file
@@ -0,0 +1,82 @@
|
||||
package Dojo::Controller::Admin;
|
||||
use Mojo::File 'path';
|
||||
use Mojo::JSON qw(decode_json encode_json);
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
use Dojo::Support qw{ log };
|
||||
|
||||
|
||||
# pagina y mensajes ===========================================================
|
||||
sub admin{
|
||||
my $c=shift;
|
||||
my $n=$c->param("dreq")//"";
|
||||
my $json = {status => "304"};
|
||||
$json = ($c->dbv->rmsgid ($c->param('id')))[0] if ($n =~m/^mensajes$/);
|
||||
$json = ($c->dbv->ecourse($c->param('id')))[0] if ($n =~m/^ecourse$/);
|
||||
$json = ($c->dbv->qcourse($c->param('id')))[0] if ($n =~m/^qcourse$/);
|
||||
$json = ($c->dbv->qplace ($c->param('id')))[0] if ($n =~m/^qplace$/);
|
||||
$c->render(json=>$json);
|
||||
}
|
||||
|
||||
|
||||
# Eventos =====================================================================
|
||||
sub admin_eventos{
|
||||
my $c=shift;
|
||||
if ( (my $t=$c->param('type') // "") =~/[ecp]/){
|
||||
my $id=$c->param('id');
|
||||
my $req=$c->param('req');
|
||||
if ( $req eq "Eliminar"){
|
||||
$c->dbv->event_del($id) if ($t eq 'e');
|
||||
$c->dbv->course_del($id) if ($t eq 'c');
|
||||
$c->dbv->place_del($id) if ($t eq 'p');
|
||||
}
|
||||
elsif( $req eq "Aceptar"){
|
||||
if($t eq 'e'){
|
||||
my @list=map{$c->param($_)}qw/eplace yini mini dini yend mend dend cost promo pen ecourse eimg een id/;
|
||||
$c->dbv->event_up(@list) if ($id ==0);
|
||||
$c->dbv->event_ch(@list) if ($id >0);
|
||||
}
|
||||
if($t eq 'c'){
|
||||
my @list=map{$c->param($_)}qw/cname csubjects cservices cen id/;
|
||||
$c->dbv->course_up(@list) if ($id ==0);
|
||||
$c->dbv->course_ch(@list) if ($id >0);
|
||||
}
|
||||
if($t eq 'p'){
|
||||
my @list=map{$c->param($_)}qw/pname paddr pobs pto pst pco plat plng pen id/;
|
||||
$c->dbv->place_up(@list) if ($id ==0);
|
||||
$c->dbv->place_ch(@list) if ($id >0);
|
||||
}
|
||||
}
|
||||
$c->redirect_to("/admin/eventos");
|
||||
}
|
||||
|
||||
$c->stash(
|
||||
courses=>$c->dbv->courses,
|
||||
places=>$c->dbv->places,
|
||||
months=>$c->dbv->months,
|
||||
events=>$c->dbv->events,
|
||||
img=>$c->dbv->eimgList,
|
||||
);
|
||||
$c->stash(template=>"home/admin/event");
|
||||
$c->stash(layout=>"admin");
|
||||
}
|
||||
|
||||
sub admin_tienda{
|
||||
my $c=shift;
|
||||
$c->stash(u=>$c->dbv->user_heads);
|
||||
$c->stash(s=>$c->dbv->store_heads);
|
||||
$c->stash(template=>"home/admin/tienda");
|
||||
$c->stash(layout=>"admin");
|
||||
}
|
||||
|
||||
# Funciones auxiliares ========================================================
|
||||
sub admin_json{
|
||||
my $c=shift;
|
||||
my $id = $c->param('id');
|
||||
my $req = $c->param('dreq');
|
||||
my $json = "304";
|
||||
$json = $c->dbv->astore($id) if $req=~/tienda/;
|
||||
$json = $c->dbv->course($id) if $req=~/course/;
|
||||
$json = $c->dbv->place($id) if $req=~/place/;
|
||||
$json = $c->dbv->eventa($id) if $req=~/event/;
|
||||
$c->render(json=>$json);
|
||||
}
|
||||
@@ -8,6 +8,7 @@ use Net::Telnet;
|
||||
my $server_name = "";
|
||||
our $t; #telnet server object
|
||||
my $data_path = path('lib/Dojo/Model/Data')->make_path;
|
||||
|
||||
sub simple{
|
||||
my $c=shift;
|
||||
my $n=$c->param("dreq")//"";
|
||||
@@ -18,16 +19,6 @@ sub simple{
|
||||
$c->render(json=>$json);
|
||||
}
|
||||
|
||||
sub admin{
|
||||
my $c=shift;
|
||||
my $n=$c->param("dreq")//"";
|
||||
my $json = {status => "304"};
|
||||
$json = ($c->dbv->rmsgid ($c->param('id')))[0] if ($n =~m/^mensajes$/);
|
||||
$json = ($c->dbv->ecourse($c->param('id')))[0] if ($n =~m/^ecourse$/);
|
||||
$json = ($c->dbv->qcourse($c->param('id')))[0] if ($n =~m/^qcourse$/);
|
||||
$json = ($c->dbv->qplace ($c->param('id')))[0] if ($n =~m/^qplace$/);
|
||||
$c->render(json=>$json);
|
||||
}
|
||||
#==== candy =====================================================
|
||||
sub candy{
|
||||
my $c=shift;
|
||||
@@ -43,32 +34,36 @@ sub candy{
|
||||
$c->render(json => {a=>$r});
|
||||
}
|
||||
|
||||
sub turnOff{
|
||||
grep(/Result: true/,join('',sendT('host:deactivate("'.$server_name.'")')))?1:0
|
||||
unless (isOn()==0);
|
||||
}
|
||||
sub turnOn{
|
||||
grep(/Result: true/,join('',sendT('host:activate("'.$server_name.'")')))?1:0
|
||||
unless (isOn()==1);
|
||||
sub turnOff{
|
||||
grep(/Result: true/,join('',sendT('host:deactivate("'.$server_name.'")')))?1:0
|
||||
unless (isOn()==0);
|
||||
}
|
||||
|
||||
sub turnOn{
|
||||
grep(/Result: true/,join('',sendT('host:activate("'.$server_name.'")')))?1:0
|
||||
unless (isOn()==1);
|
||||
}
|
||||
|
||||
sub isOn{return grep(/\s$server_name/,sendT("host:list()"))? 1:0; }
|
||||
sub isOn{return grep(/\s$server_name/,sendT("host:list()"))? 1:0; }
|
||||
|
||||
sub sendT{
|
||||
commandT(shift);
|
||||
my @r = $t->getlines(All=>0);
|
||||
return @r
|
||||
}
|
||||
|
||||
sub connectT{
|
||||
$t = new Net::Telnet ( Port=>5582, Timeout=>1, Errmode=>'return' );
|
||||
# $t = new Net::Telnet ( Port=>5582, Timeout=>1, Errmode=>'die' );
|
||||
return 1 if $t->open();
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub commandT{
|
||||
$t->getlines(All=>0);#empty buffer
|
||||
$t->print(shift); #run istruction
|
||||
}
|
||||
|
||||
sub disconnectT{ $t->close();}
|
||||
|
||||
#=========================================================
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package Dojo::Controller::Example;
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
|
||||
# This action will render a template
|
||||
sub welcome {
|
||||
my $self = shift;
|
||||
|
||||
# Render template "example/welcome.html.ep" with message
|
||||
$self->render(msg => 'Welcome to the Mojolicious real-time web framework!');
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -1,107 +0,0 @@
|
||||
package Dojo::Controller::Misc;
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
use Mojo::Template;
|
||||
use Dojo::Support qw{ log get_names};
|
||||
# estos son paypal=======:w
|
||||
use LWP::UserAgent;
|
||||
use HTTP::Request::Common;
|
||||
use JSON;
|
||||
use Data::Dumper;
|
||||
|
||||
# 4000004840000008 3, 6, 9, 12, and 18 month installment plans available
|
||||
# "*p4000004840000008
|
||||
# 4242424242424242 No installment plans available.
|
||||
my $sky='sk_test_GXWsfsoxy5336LrSw7SgTXNC00TV9O4Dbq';
|
||||
my $api_create_path='https://api.stripe.com/v1/payment_intents';
|
||||
|
||||
sub stripe {
|
||||
my $self = shift;
|
||||
my $request = defined ($self->req->json)? $self->req->json->{'req'}:"start";
|
||||
|
||||
# item info ======================
|
||||
my $header = "Beijing Wisdom </br> Healing Center";
|
||||
my $title = "Retiro Curso de Tercer método de ZhiNengQiGong";
|
||||
my $subtitle = "Una experiencia de instrucción del tercer método y profundización con los instructores ZhangQing (Helen) y QiuFuChun (Karl).";
|
||||
my ($amount,$description,$max_time) = (1417500,"Tercer método",9);
|
||||
# ==============================
|
||||
|
||||
if( $request eq "precheck" ){
|
||||
my $pmi=$self->req->json->{'payment_method_id'} // 0;
|
||||
my $t = intentCreate( $pmi, $amount, $description, $max_time);
|
||||
$self->render(json=>$t);
|
||||
}
|
||||
|
||||
elsif( $request eq "check" ){
|
||||
my $pii = $self->req->json->{'payment_intent_id'};
|
||||
my $plan = $self->req->json->{'selected_plan'}//0;
|
||||
|
||||
unless ($plan==0) {if ($plan->{count} > $max_time) {
|
||||
log("\n\n max time instalment attempt\n\n");
|
||||
$self->render(json=>{'error'=>'max time error'});
|
||||
return 0;
|
||||
}}
|
||||
my $r = intentConfirm($pii,$plan);
|
||||
$self->render(json=>$r);
|
||||
}
|
||||
|
||||
else {
|
||||
$self->stash(header=>$header);
|
||||
$self->stash(title=>$title);
|
||||
$self->stash(subtitle=>$subtitle);
|
||||
$self->stash(layout=>'xpay');
|
||||
}
|
||||
}
|
||||
|
||||
#stripe appi functions
|
||||
sub intentCreate{
|
||||
my ($pmi,$amount,$descriptor,$max_time) = @_;
|
||||
my $payment_info=[
|
||||
'payment_method'=>$pmi,
|
||||
'amount'=>$amount,
|
||||
'currency'=>'mxn',
|
||||
'description'=>$descriptor,
|
||||
'payment_method_options[card][installments][enabled]'=>'true'
|
||||
];
|
||||
my $r=stripeAppi($api_create_path,$payment_info);
|
||||
my $t->{intent_id}=$r->{id};
|
||||
foreach (@{$r->{payment_method_options}{card}{installments}{available_plans}}){
|
||||
push (@{$t->{available_plans}}, $_) unless ($_->{count}>$max_time);
|
||||
}
|
||||
return $t;
|
||||
}
|
||||
|
||||
sub intentConfirm{
|
||||
my ($pii,$plan) = @_;
|
||||
my $api_confirm_path = "https://api.stripe.com/v1/payment_intents/$pii/confirm";
|
||||
my $cplan=0;
|
||||
|
||||
$cplan = [
|
||||
'payment_method_options[card][installments][plan][type]'=>'fixed_count',
|
||||
'payment_method_options[card][installments][plan][interval]'=>'month',
|
||||
'payment_method_options[card][installments][plan][count]'=>$plan->{count},
|
||||
]
|
||||
unless ($plan==0);
|
||||
my $r = stripeAppi($api_confirm_path,$cplan);
|
||||
my $rtt = {
|
||||
'status'=>$r->{'status'},
|
||||
'plan' => $r->{'payment_method_options'}{'card'}{'installments'}{'plan'},
|
||||
};
|
||||
return $rtt;
|
||||
}
|
||||
|
||||
sub stripeAppi{
|
||||
my ($path,$data) = @_;
|
||||
my $req = POST $path, $data;
|
||||
$req->authorization_basic($sky,'');
|
||||
$req->content_type('application/x-www-form-urlencoded');
|
||||
my $ua = LWP::UserAgent->new;
|
||||
my $res=$ua->request($req);
|
||||
unless ($res->is_success){
|
||||
log("stripe error! path=$path\n data=".Dumper($data)."\n $res->status_line ");
|
||||
return 0;
|
||||
}
|
||||
my $json = JSON->new->utf8;
|
||||
return $json->decode($res->decoded_content);
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -2,55 +2,14 @@ package Dojo::Controller::Proc;
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
use Mojo::Template;
|
||||
use Dojo::Support qw{ log get_names};
|
||||
# estos son paypal=======:w
|
||||
|
||||
use LWP::UserAgent;
|
||||
use HTTP::Request::Common;
|
||||
use JSON;
|
||||
use Data::Dumper;
|
||||
#=========================
|
||||
sub tst{
|
||||
my $c=shift;
|
||||
if( defined($c->req->json) ){
|
||||
my $oid = $c->req->json->{'orderID'} //0;
|
||||
log( $oid );
|
||||
#credentials====
|
||||
my $client='AQdZ1JJL-GNBgGTI3W6cXChmj6MnZsInRGlWeHw1kbGiE_49eTtZ2fPvEq9ersU2y6O5WpxccdsyAQw7';
|
||||
my $secter='EBn8CNOCrJbVZ_fNllXB7oUIm9_vhtqrJMm2zSBGbxSyiiych3cHOIWOLAD5NVw4Z3dmNhmsHQwPsrZ0';
|
||||
my $pauth='https://api.sandbox.paypal.com/v1/oauth2/token/';
|
||||
my $porder='https://api.sandbox.paypal.com/v2/checkout/orders/';
|
||||
#=================
|
||||
#pre auth ====
|
||||
my $ua = LWP::UserAgent->new;
|
||||
my $req=POST $pauth, ["grant_type"=>"client_credentials"];
|
||||
$req->authorization_basic($client,$secter);
|
||||
$req->content_type('application/x-www-form-urlencoded');
|
||||
my $res=$ua->request($req);
|
||||
log("paypal pre auth error! $res->status_line") unless ($res->is_success );
|
||||
my $json = JSON->new->utf8;
|
||||
my $r=$json->decode($res->decoded_content);
|
||||
#==============
|
||||
|
||||
#order details ====
|
||||
my $ub = LWP::UserAgent->new;
|
||||
$ub->default_header('Content-Type'=> 'application/json' );
|
||||
$ub->default_header('Authorization'=> 'Bearer ' . $r->{access_token} );
|
||||
my $resb=$ub->get($porder.$oid);
|
||||
log("paypal checkout error!") unless ($resb->is_success );
|
||||
my $jsonb = JSON->new->utf8;
|
||||
my $s=$jsonb->decode($resb->decoded_content);
|
||||
#===================
|
||||
$c->rendered(200); #es default,nomas para enfatizar que puede ser 400 o 500
|
||||
# interesan create time, id, payer: email address, shippng address
|
||||
}
|
||||
else{
|
||||
my $data=$c->dbg->store_id($c->param('id'));
|
||||
$c->redirect_to('store') unless ($data->{'id'});
|
||||
$c->stash($data);
|
||||
$c->stash(layout=>'default');
|
||||
}
|
||||
#$c->render(text=> $c->config->{radio}{'channel'});
|
||||
|
||||
}
|
||||
# User ========================================================================
|
||||
|
||||
sub cal {
|
||||
@@ -71,67 +30,13 @@ sub event{
|
||||
$c->stash(layout=> "defaultContact");
|
||||
}
|
||||
|
||||
|
||||
sub store{
|
||||
my $c = shift;
|
||||
$c->stash( r=>$c->dbg->store);
|
||||
$c->stash(layout=> "defaultContact");
|
||||
}
|
||||
|
||||
sub storep{
|
||||
my $c=shift;
|
||||
if( defined($c->req->json) ){
|
||||
my $oid = $c->req->json->{'orderID'} //0;
|
||||
log( $oid );
|
||||
#credentials====
|
||||
my $client='AQdZ1JJL-GNBgGTI3W6cXChmj6MnZsInRGlWeHw1kbGiE_49eTtZ2fPvEq9ersU2y6O5WpxccdsyAQw7';
|
||||
my $secter='EBn8CNOCrJbVZ_fNllXB7oUIm9_vhtqrJMm2zSBGbxSyiiych3cHOIWOLAD5NVw4Z3dmNhmsHQwPsrZ0';
|
||||
my $pauth='https://api.sandbox.paypal.com/v1/oauth2/token/';
|
||||
my $porder='https://api.sandbox.paypal.com/v2/checkout/orders/';
|
||||
#=================
|
||||
#pre auth ====
|
||||
my $ua = LWP::UserAgent->new;
|
||||
my $req=POST $pauth, ["grant_type"=>"client_credentials"];
|
||||
$req->authorization_basic($client,$secter);
|
||||
$req->content_type('application/x-www-form-urlencoded');
|
||||
my $res=$ua->request($req);
|
||||
log("paypal pre auth error! $res->status_line") unless ($res->is_success );
|
||||
my $json = JSON->new->utf8;
|
||||
my $r=$json->decode($res->decoded_content);
|
||||
#==============
|
||||
|
||||
#order details ====
|
||||
my $ub = LWP::UserAgent->new;
|
||||
$ub->default_header('Content-Type'=> 'application/json' );
|
||||
$ub->default_header('Authorization'=> 'Bearer ' . $r->{access_token} );
|
||||
my $resb=$ub->get($porder.$oid);
|
||||
log("paypal checkout error!") unless ($resb->is_success );
|
||||
my $jsonb = JSON->new->utf8;
|
||||
my $s=$jsonb->decode($resb->decoded_content);
|
||||
#===================
|
||||
$c->rendered(200); #es default,nomas para enfatizar que puede ser 400 o 500
|
||||
# interesan create time, id, payer: email address, shippng address
|
||||
}
|
||||
else{
|
||||
my $data=$c->dbg->store_id($c->param('id'));
|
||||
$c->redirect_to('cal') if ($c->param('id')==4);
|
||||
$c->redirect_to('store') unless ($data->{'id'});
|
||||
$c->stash($data);
|
||||
$c->stash(layout=>'default');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub spay{
|
||||
my $c = shift;
|
||||
my $data=$c->mproc->store_id($c->param('class'),$c->param('id'));
|
||||
$c->stash($data);
|
||||
if( ($c->param('id') <= 86) && ($c->param('id') >= 80) )
|
||||
{ $c->stash(layout=>'xpay');}
|
||||
else {$c->stash(layout=>'default');}
|
||||
}
|
||||
|
||||
#stripe appi functions
|
||||
#stripe appi function =============================================================================
|
||||
sub intentCreate{
|
||||
my $c = shift;
|
||||
unless (defined ($c->req->json)){
|
||||
@@ -139,21 +44,28 @@ sub intentCreate{
|
||||
$c->render(template=>'home/not_found', status=>404);
|
||||
return 0;
|
||||
}
|
||||
my $pmi=$c->req->json->{'payment_method_id'} // 0;
|
||||
|
||||
my $data=$c->mproc->intentCreate($c->req->json->{'tid'});
|
||||
my ($amount,$description,$max_time) = ($data->{'precio'},$data->{'nombre'},9);
|
||||
# if(!@$data){ intentError($c,"event not found",1); return;};
|
||||
|
||||
my $pmi=$c->req->json->{'payment_method_id'} // 0;
|
||||
my $amount = $data->{'precio'} * $c->req->json->{'mq'} ;
|
||||
my $description = $data->{'nombre'};
|
||||
my $max_time = 9;
|
||||
|
||||
my $api_create_path='https://api.stripe.com/v1/payment_intents';
|
||||
my $payment_info=[
|
||||
'payment_method'=>$pmi,
|
||||
'amount'=>$amount,
|
||||
'amount'=>$amount*100,
|
||||
'currency'=>'mxn',
|
||||
'description'=>$description,
|
||||
'payment_method_options[card][installments][enabled]'=>'true'
|
||||
];
|
||||
my $r=stripeAppi($api_create_path,$payment_info);
|
||||
if ($r==0){intentError($c,"api create error",1); return;}
|
||||
my $t->{intent_id}=$r->{id};
|
||||
foreach (@{$r->{payment_method_options}{card}{installments}{available_plans}}){
|
||||
push (@{$t->{available_plans}}, $_) unless ($_->{count}>$max_time);
|
||||
push (@{$t->{available_plans}}, $_) unless ($_->{count} > $max_time);
|
||||
}
|
||||
$c->render(json=>$t);
|
||||
return 0;
|
||||
@@ -162,30 +74,49 @@ sub intentCreate{
|
||||
sub intentConfirm{
|
||||
my $c = shift;
|
||||
my $max_time = 9;
|
||||
|
||||
unless (defined ($c->req->json)){
|
||||
$c->stash(layout=>'clean');
|
||||
$c->render(template=>'home/not_found', status=>404);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
my $pii = $c->req->json->{'payment_intent_id'};
|
||||
my $plan = $c->req->json->{'selected_plan'}//0;
|
||||
|
||||
unless ($c->mproc->intentSanity($c->req->json) == 0 ){
|
||||
intentError($c,"sanity failed",0); return; }
|
||||
|
||||
my $data = $c->req->json;
|
||||
my $pii = $data->{'payment_intent_id'};
|
||||
my $plan = $data->{'selected_plan'} // 0;
|
||||
my $api_confirm_path = "https://api.stripe.com/v1/payment_intents/$pii/confirm";
|
||||
|
||||
unless ($plan==0) {if ($plan->{count} > $max_time) {
|
||||
log("\n\n max time instalment attempt\n\n");
|
||||
$c->render(json=>{'error'=>'max time error'});
|
||||
|
||||
my $cplan = 0;
|
||||
if ($plan != 0){
|
||||
if ($plan->{count} > $max_time) {
|
||||
intentError($c,'max time installment attempt error',3);
|
||||
return 0;
|
||||
}}
|
||||
my $cplan=0;
|
||||
}
|
||||
$cplan = [
|
||||
'payment_method_options[card][installments][plan][type]'=>'fixed_count',
|
||||
'payment_method_options[card][installments][plan][interval]'=>'month',
|
||||
'payment_method_options[card][installments][plan][count]'=>$plan->{count},
|
||||
]
|
||||
}
|
||||
|
||||
if (
|
||||
intentCheck(
|
||||
$c,
|
||||
$data->{'payment_intent_id'},
|
||||
$data->{'tid'},
|
||||
$data->{'mq'}
|
||||
) == -1) {
|
||||
intentError($c,"api confirm error pre",2); return;
|
||||
}
|
||||
|
||||
$cplan = [
|
||||
'payment_method_options[card][installments][plan][type]'=>'fixed_count',
|
||||
'payment_method_options[card][installments][plan][interval]'=>'month',
|
||||
'payment_method_options[card][installments][plan][count]'=>$plan->{count},
|
||||
]
|
||||
unless ($plan==0);
|
||||
my $r = stripeAppi($api_confirm_path,$cplan);
|
||||
my $data=$c->mproc->intentCreate($c->req->json->{'tid'});
|
||||
if ($r==0){intentError($c,"api confirm error post",2); return;}
|
||||
if ($r->{'status'} ne "succeeded" ){intentError($c,"payment not completed,2"); return;}
|
||||
|
||||
$c->mproc->intentConfirm($data,$r);
|
||||
my $rtt = {
|
||||
'status'=>$r->{'status'},
|
||||
'plan' => $r->{'payment_method_options'}{'card'}{'installments'}{'plan'},
|
||||
@@ -194,11 +125,33 @@ sub intentConfirm{
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub intentError{ # e: error msg, stage: 0-userinfo, 1 icreate. 2 iconfirm
|
||||
my $c = shift;
|
||||
$c->render(json => { 'e'=>shift, 'stage'=>shift });
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub userCheck{
|
||||
my $c=shift;
|
||||
my $r = { 'userst' => $c->mproc->userDataSanity($c->req->json)};
|
||||
$c->render(json=>$r);
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub intentCheck{
|
||||
my ($c, $cid, $tid, $mq) = @_;
|
||||
my $stripe = stripeAppi("https://api.stripe.com/v1/payment_intents/$cid",0);
|
||||
my $data=$c->mproc->intentCreate($tid);
|
||||
return -1 unless ( $stripe->{'amount'} == ($data->{'precio'} * $mq)*100);
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub stripeAppi{
|
||||
my $sky='sk_test_GXWsfsoxy5336LrSw7SgTXNC00TV9O4Dbq';
|
||||
my ($path,$data) = @_;
|
||||
my $req = POST $path, $data;
|
||||
$req->authorization_basic($sky,'');
|
||||
my $req;
|
||||
if ($data == 0 ) { $req = POST $path;} # -.-
|
||||
else { $req = POST $path, $data;}
|
||||
$req->authorization_basic(Dojo::Conf::STRIPE_SK,'');
|
||||
$req->content_type('application/x-www-form-urlencoded');
|
||||
my $ua = LWP::UserAgent->new;
|
||||
my $res=$ua->request($req);
|
||||
@@ -210,71 +163,49 @@ sub stripeAppi{
|
||||
return $json->decode($res->decoded_content);
|
||||
}
|
||||
|
||||
# Admin =======================================================================
|
||||
|
||||
|
||||
sub admin_eventos{
|
||||
my $c=shift;
|
||||
if ( (my $t=$c->param('type') // "") =~/[ecp]/){
|
||||
my $id=$c->param('id');
|
||||
my $req=$c->param('req');
|
||||
if ( $req eq "Eliminar"){
|
||||
$c->dbv->event_del($id) if ($t eq 'e');
|
||||
$c->dbv->course_del($id) if ($t eq 'c');
|
||||
$c->dbv->place_del($id) if ($t eq 'p');
|
||||
}
|
||||
elsif( $req eq "Aceptar"){
|
||||
if($t eq 'e'){
|
||||
my @list=map{$c->param($_)}qw/eplace yini mini dini yend mend dend cost promo pen ecourse eimg een id/;
|
||||
$c->dbv->event_up(@list) if ($id ==0);
|
||||
$c->dbv->event_ch(@list) if ($id >0);
|
||||
}
|
||||
if($t eq 'c'){
|
||||
my @list=map{$c->param($_)}qw/cname csubjects cservices cen id/;
|
||||
$c->dbv->course_up(@list) if ($id ==0);
|
||||
$c->dbv->course_ch(@list) if ($id >0);
|
||||
}
|
||||
if($t eq 'p'){
|
||||
my @list=map{$c->param($_)}qw/pname paddr pobs pto pst pco plat plng pen id/;
|
||||
$c->dbv->place_up(@list) if ($id ==0);
|
||||
$c->dbv->place_ch(@list) if ($id >0);
|
||||
}
|
||||
}
|
||||
$c->redirect_to("/admin/eventos");
|
||||
}
|
||||
# Not used but maybe later ======================================================
|
||||
|
||||
$c->stash(
|
||||
courses=>$c->dbv->courses,
|
||||
places=>$c->dbv->places,
|
||||
months=>$c->dbv->months,
|
||||
events=>$c->dbv->events,
|
||||
img=>$c->dbv->eimgList,
|
||||
);
|
||||
$c->stash(template=>"home/admin/event");
|
||||
$c->stash(layout=>"admin");
|
||||
}
|
||||
sub admin_tienda{
|
||||
my $c=shift;
|
||||
$c->stash(u=>$c->dbv->user_heads);
|
||||
$c->stash(s=>$c->dbv->store_heads);
|
||||
$c->stash(template=>"home/admin/tienda");
|
||||
$c->stash(layout=>"admin");
|
||||
|
||||
}
|
||||
|
||||
sub admin_json{
|
||||
my $c=shift;
|
||||
my $id = $c->param('id');
|
||||
my $req = $c->param('dreq');
|
||||
my $json = "304";
|
||||
$json = $c->dbv->astore($id) if $req=~/tienda/;
|
||||
$json = $c->dbv->course($id) if $req=~/course/;
|
||||
$json = $c->dbv->place($id) if $req=~/place/;
|
||||
$json = $c->dbv->eventa($id) if $req=~/event/;
|
||||
$c->render(json=>$json);
|
||||
}
|
||||
|
||||
|
||||
#==============================================================================
|
||||
#sub storeppl{
|
||||
#my $c=shift;
|
||||
#if( defined($c->req->json) ){
|
||||
#my $oid = $c->req->json->{'orderID'} //0;
|
||||
#log( $oid );
|
||||
##credentials====
|
||||
#my $client='AQdZ1JJL-GNBgGTI3W6cXChmj6MnZsInRGlWeHw1kbGiE_49eTtZ2fPvEq9ersU2y6O5WpxccdsyAQw7';
|
||||
#my $secter='EBn8CNOCrJbVZ_fNllXB7oUIm9_vhtqrJMm2zSBGbxSyiiych3cHOIWOLAD5NVw4Z3dmNhmsHQwPsrZ0';
|
||||
#my $pauth='https://api.sandbox.paypal.com/v1/oauth2/token/';
|
||||
#my $porder='https://api.sandbox.paypal.com/v2/checkout/orders/';
|
||||
##=================
|
||||
##pre auth ====
|
||||
#my $ua = LWP::UserAgent->new;
|
||||
#my $req=POST $pauth, ["grant_type"=>"client_credentials"];
|
||||
#$req->authorization_basic($client,$secter);
|
||||
#$req->content_type('application/x-www-form-urlencoded');
|
||||
#my $res=$ua->request($req);
|
||||
#log("paypal pre auth error! $res->status_line") unless ($res->is_success );
|
||||
#my $json = JSON->new->utf8;
|
||||
#my $r=$json->decode($res->decoded_content);
|
||||
##==============
|
||||
|
||||
##order details ====
|
||||
#my $ub = LWP::UserAgent->new;
|
||||
#$ub->default_header('Content-Type'=> 'application/json' );
|
||||
#$ub->default_header('Authorization'=> 'Bearer ' . $r->{access_token} );
|
||||
#my $resb=$ub->get($porder.$oid);
|
||||
#log("paypal checkout error!") unless ($resb->is_success );
|
||||
#my $jsonb = JSON->new->utf8;
|
||||
#my $s=$jsonb->decode($resb->decoded_content);
|
||||
##===================
|
||||
#$c->rendered(200); #es default,nomas para enfatizar que puede ser 400 o 500
|
||||
## interesan create time, id, payer: email address, shippng address
|
||||
#}
|
||||
#else{
|
||||
#my $data=$c->dbg->store_id($c->param('id'));
|
||||
#$c->redirect_to('cal') if ($c->param('id')==4);
|
||||
#$c->redirect_to('store') unless ($data->{'id'});
|
||||
#$c->stash($data);
|
||||
#$c->stash(layout=>'default');
|
||||
#}
|
||||
#}
|
||||
|
||||
1;
|
||||
|
||||
19
lib/Dojo/Model/Data/spay/qIntentConfirm.q
Normal file
@@ -0,0 +1,19 @@
|
||||
insert into caja_evento
|
||||
(
|
||||
cliente_nombre,
|
||||
cliente_correo,
|
||||
cliente_comentario,
|
||||
tienda_evento_id,
|
||||
talla_id,
|
||||
cantidad,
|
||||
monto,
|
||||
etapa_id,
|
||||
entrega_id,
|
||||
pago_clave,
|
||||
plazo,
|
||||
fecha_pago
|
||||
)
|
||||
values (?,?,?,?,?,?,?,?,?,?,?,now())
|
||||
;
|
||||
|
||||
|
||||
10
lib/Dojo/Model/Data/spay/qIntentCreate.q
Normal file
@@ -0,0 +1,10 @@
|
||||
select
|
||||
t.precio as precio,
|
||||
c.nombre as nombre
|
||||
from
|
||||
tienda_evento as t
|
||||
inner join
|
||||
curso as c on t.curso_id=c.id
|
||||
where
|
||||
t.id = ?
|
||||
;
|
||||
@@ -1,30 +0,0 @@
|
||||
select
|
||||
t.id as tid,
|
||||
c.nombre as nombre,
|
||||
c.subnombre as subnombre,
|
||||
c.descripcion as descripcion,
|
||||
c.maestro as maestro,
|
||||
c.imagen_a as cimga,
|
||||
c.imagen_b as cimgb,
|
||||
c.imagen_c as cimgc,
|
||||
day(t.fecha_inicio) as dini,
|
||||
month(t.fecha_inicio) as mini,
|
||||
day(t.fecha_fin) as dfin,
|
||||
month(t.fecha_fin) as mfin,
|
||||
t.precio as precio,
|
||||
t.promocion as promo,
|
||||
t.promo_estado as promo_estado,
|
||||
t.playera_estado as playera_estado,
|
||||
t.cupo as cupo,
|
||||
l.nombre as lnombre,
|
||||
l.federativa as federativa,
|
||||
l.pais as pais,
|
||||
l.municipio as municipio
|
||||
from tienda_evento as t
|
||||
join curso as c on c.id = t.curso_id
|
||||
join lugar as l on l.id = t.lugar_id
|
||||
|
||||
where t.id=? and t.estado =1
|
||||
;
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
select
|
||||
id,
|
||||
objeto as "objeto",
|
||||
nombre as "nombre",
|
||||
precio as "precio",
|
||||
subnombre as "subnombre",
|
||||
promocion as "promocion",
|
||||
imagen as "imagen"
|
||||
from tienda where activo =1;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package Dojo::Model::Vdgproc; use Mojo::File 'path';
|
||||
use Mojo::JSON qw(decode_json encode_json);
|
||||
use Dojo::Support qw{month_num2txt log dmph} ;
|
||||
use Dojo::Support qw{ mtxt month_num2txt log dmph} ;
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
|
||||
|
||||
use Email::Valid;
|
||||
use Data::Dumper;
|
||||
use File::Basename;
|
||||
use Encode qw(decode_utf8 encode_utf8);
|
||||
use Text::Markdown qw{ markdown };
|
||||
@@ -15,24 +16,13 @@ my $data_path = path('lib/Dojo/Model/Data')->make_path;
|
||||
#just for fun
|
||||
|
||||
|
||||
# Tienda de eventos ===========================================================
|
||||
sub calendar_monthblock {
|
||||
my $r = _read ($data_path->child("cal/q1Block.q")->slurp);
|
||||
map { $_->{fecha}=month_num2txt($_->{month})." ".$_->{year} } @$r;
|
||||
return $r;
|
||||
}
|
||||
|
||||
sub mtxt {
|
||||
my ($di, $mi, $df, $mf)=@_; # dini,mini,dfin,mfin
|
||||
my $txt;
|
||||
if ($mi == $mf){
|
||||
if ($di == $df){ $txt = "$di de ".month_num2txt($mi);}
|
||||
else{ $txt = "Del $di al $df de ".month_num2txt($mi);}
|
||||
}
|
||||
else{
|
||||
$txt = "Del $di de ".month_num2txt($mi)." al $df de ".month_num2txt($mf);
|
||||
}
|
||||
return $txt;
|
||||
}
|
||||
sub calendar_events {
|
||||
my $r = _read ($data_path->child("cal/q3Event.q")->slurp);
|
||||
foreach (@$r) { $_->{fecha} = mtxt( $_->{dini},$_->{mini},$_->{dfin},$_->{mfin}) }
|
||||
@@ -48,29 +38,103 @@ sub event{
|
||||
|
||||
sub spay {
|
||||
my ($c,$class,$id) = @_;
|
||||
return _read ($data_path->child("/store/qIdStore.q")->slurp,$id)->[0];
|
||||
return _read ($data_path->child("spay/qIdStore.q")->slurp,$id)->[0];
|
||||
}
|
||||
|
||||
# 4000004840000008 3, 6, 9, 12, and 18 month installment plans available
|
||||
# "*p4000004840000008
|
||||
# 4242424242424242 No installment plans available.
|
||||
|
||||
#==============================================================================
|
||||
sub store_id {
|
||||
my ($c,$class,$id) = @_;
|
||||
my $r = _read ($data_path->child("/store/qEstore.q")->slurp,$id)->[0];
|
||||
my $r = _read ($data_path->child("store/qEstore.q")->slurp,$id)->[0];
|
||||
$r->{fecha} = mtxt( $r->{dini},$r->{mini},$r->{dfin},$r->{mfin});
|
||||
return $r;
|
||||
}
|
||||
|
||||
# Stripe payment process ==============================================================
|
||||
# ======================
|
||||
# 4000004840000008 3, 6, 9, 12, and 18 month installment plans available
|
||||
# "*p4000004840000008
|
||||
# 4242424242424242 No installment plans available.
|
||||
# ======================
|
||||
|
||||
sub intentCreate{
|
||||
my ($c,$id) = @_;
|
||||
my $q="select t.precio as precio, c.nombre as nombre from tienda_evento as t inner join curso as c on t.curso_id=c.id where t.id = ? ;";
|
||||
return _read ($q,$id)->[0];
|
||||
return _read ($data_path->child("spay/qIntentCreate.q")->slurp,$id)->[0];
|
||||
}
|
||||
|
||||
|
||||
sub intentConfirm{
|
||||
my ($c,$id) = @_;
|
||||
my $q="select t.precio as precio, c.nombre as nombre from tienda_evento as t inner join curso as c on t.curso_id=c.id where t.id = ? ;";
|
||||
return _read ($q,$id)->[0];
|
||||
my ($c,$data,$r) = @_;
|
||||
# cliente_nombre,cliente_correo,cliente_comentario,tienda_evento_id,talla_id,cantidad(1),monto,etapa_id(4),entrega(3),pago_clave,plazo,fecha_pago
|
||||
my $mq = $data->{'mq'};
|
||||
my $students = $data->{'students'};
|
||||
my $plan = 0;
|
||||
if (defined $data->{'selected_plan'}){
|
||||
$plan = $data->{'selected_plan'}->{'count'};
|
||||
}
|
||||
for (1..$mq){
|
||||
_write (
|
||||
$data_path->child("/spay/qIntentConfirm.q")->slurp,
|
||||
$$students[$_ -1][0],
|
||||
$$students[$_ -1][1],
|
||||
$$students[$_ -1][2],
|
||||
$data->{'tid'},
|
||||
$$students[$_ -1][3],
|
||||
$data->{'mq'},
|
||||
$r->{'amount'},
|
||||
4,
|
||||
3,
|
||||
$r->{'id'},
|
||||
$plan
|
||||
);
|
||||
} # falta plazo
|
||||
return ;
|
||||
}
|
||||
|
||||
# Check payment user info ==============
|
||||
# data:
|
||||
# ===============
|
||||
#'selected_plan' => { 'type' => 'fixed_count', 'count' => 6, 'interval' => 'month' },
|
||||
#'mq' => '2', # cantidad de alumnas
|
||||
#'req' => 'check',
|
||||
#'payment_intent_id' => 'pi_1G1luSFBHoXN2vhnkl3PIiL1',
|
||||
#'tid' => 80, #tienda id
|
||||
#'students' => [ [ 'User', 'me@me.com', 'obs', 'M' ], [ 'usr2', 'mail2', 'obs', 'G' ], undef, undef, undef, undef, undef, undef, undef, undef ] #arr(10)
|
||||
# ===============
|
||||
|
||||
sub intentSanity{
|
||||
my ($c,$d)=@_;
|
||||
if (defined $d->{'selected_plan'} ){
|
||||
return -1 unless defined ($d->{'selected_plan'}{'type'});
|
||||
return -1 unless defined ($d->{'selected_plan'}{'count'});
|
||||
return -1 unless defined ($d->{'selected_plan'}{'interval'});
|
||||
}
|
||||
return -1 unless defined ($d->{'tid'}) && $d->{'tid'} =~ /^\d+$/ ;
|
||||
return -1 unless defined ($d->{'req'}) && $d->{'req'} eq 'check';
|
||||
return -1 unless defined ($d->{'payment_intent_id'});
|
||||
return userDataSanity($c,$d) ;
|
||||
}
|
||||
|
||||
sub userDataSanity{
|
||||
my ($c,$d) = @_;
|
||||
return -1 unless (
|
||||
defined ($d->{'students'}) && # (nombre,mail,observaciones, talla)
|
||||
defined ($d->{'mq'}) &&
|
||||
$d->{'mq'} =~/^\d+$/ &&
|
||||
$d->{'mq'} < 10
|
||||
);
|
||||
my %h=qw(n 0 CH 1 M 2 G 3);
|
||||
my $mq = $d->{'mq'};
|
||||
my $students = $d->{'students'};
|
||||
for (1..$mq){
|
||||
return $_ unless defined( $$students[$_ -1][0] );
|
||||
return $_ unless defined( $$students[$_ -1][1] ) &&
|
||||
is_mail($$students[$_ -1][1] );
|
||||
$$students[$_ -1][3] = $h{$$students[$_ -1][3] // 'n'};
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub is_mail{
|
||||
return Email::Valid->address(shift);
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
@@ -107,16 +171,7 @@ sub place_ch{
|
||||
|
||||
#==============================================================================
|
||||
|
||||
#ayudas =====================================
|
||||
sub tst{
|
||||
|
||||
my $c=shift;
|
||||
my $d=$c->param('n');
|
||||
log("------log-------");
|
||||
log("$d");
|
||||
log("------log-------");
|
||||
return 0;
|
||||
}
|
||||
# lower level read =====================================
|
||||
|
||||
sub _read{
|
||||
my ($q,@bind)=@_;
|
||||
|
||||
@@ -2,7 +2,7 @@ package Dojo::Support;
|
||||
use strict;
|
||||
use warnings;
|
||||
use Exporter 'import';
|
||||
our @EXPORT = qw/ commify month_num2txt log dmph merge_hash load_module get_names /;
|
||||
our @EXPORT = qw/ mtxt commify month_num2txt log dmph merge_hash load_module get_names /;
|
||||
use Mojo::Base 'Mojolicious';
|
||||
|
||||
use File::Basename;
|
||||
@@ -17,6 +17,7 @@ sub log{
|
||||
my $log = Mojo::Log->new;
|
||||
$log->debug("============ ".shift." ===========");
|
||||
}
|
||||
|
||||
sub get_names{
|
||||
my $dir = shift;
|
||||
my @file_name;
|
||||
@@ -36,13 +37,26 @@ sub merge_hash{
|
||||
my $merger = Hash::Merge->new('LEFT_PRECEDENT');
|
||||
foreach (@_){
|
||||
$h= $merger->merge($h,$_);
|
||||
}
|
||||
return $h;
|
||||
}
|
||||
return $h;
|
||||
}
|
||||
|
||||
sub month_num2txt{
|
||||
return ("enero febrero marzo abril mayo junio julio agosto septiembre octubre noviembre diciembre" =~ m/\w+/g)[shift (@_) -1];
|
||||
}
|
||||
|
||||
sub mtxt {
|
||||
my ($di, $mi, $df, $mf)=@_; # dini,mini,dfin,mfin
|
||||
my $txt;
|
||||
if ($mi == $mf){
|
||||
if ($di == $df){ $txt = "$di de ".month_num2txt($mi);}
|
||||
else{ $txt = "Del $di al $df de ".month_num2txt($mi);}
|
||||
}
|
||||
else{
|
||||
$txt = "Del $di de ".month_num2txt($mi)." al $df de ".month_num2txt($mf);
|
||||
}
|
||||
return $txt;
|
||||
}
|
||||
|
||||
#put comas on price numbers
|
||||
sub commify {
|
||||
|
||||
|
Before Width: | Height: | Size: 118 KiB |
|
Before Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 185 KiB |
|
Before Width: | Height: | Size: 130 KiB |
|
Before Width: | Height: | Size: 5.8 KiB |
@@ -1,62 +0,0 @@
|
||||
article.heading{
|
||||
width:100%;
|
||||
height:55vh;
|
||||
min-height:350px;
|
||||
display: inline-block;
|
||||
background-color: #333333;
|
||||
text-align: center;
|
||||
margin-top: 50px;
|
||||
}
|
||||
p.heading{
|
||||
font-size:5em;
|
||||
color:white;
|
||||
color: white;
|
||||
margin: 20vh auto auto auto;
|
||||
}
|
||||
article.shop{
|
||||
justify-content:center;
|
||||
-webkit-justify-content:center;
|
||||
margin-top: 40px;
|
||||
}
|
||||
article.shop:hover{
|
||||
background-color:rgba(240,240,240);
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
a:link, a:visited {
|
||||
text-decoration: none;
|
||||
color:unset;
|
||||
}
|
||||
|
||||
|
||||
div.simage{
|
||||
flex:3;
|
||||
max-width:350px;
|
||||
transition: .5s ease;
|
||||
}
|
||||
div.simage:hover{
|
||||
transform:scale(1.2,1.2);
|
||||
}
|
||||
div.simage > img{
|
||||
max-width:70%;
|
||||
max-height:100%;
|
||||
margin:auto;
|
||||
display:block;
|
||||
}
|
||||
div.description{
|
||||
flex:2;
|
||||
max-width:250px;
|
||||
}
|
||||
p.description{ font-size:0.8em; }
|
||||
p.title{font-weight:bold;}
|
||||
p.promo{font-weight:bold; color:#C22A39;}
|
||||
article.separator{
|
||||
background-repeat: no-repeat;
|
||||
background-image: url(" #path img/separa.jpg");
|
||||
height: 20px;
|
||||
background-size: contain;
|
||||
background-position: center;
|
||||
margin-top:30px;
|
||||
}
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 493 KiB |
@@ -1,106 +0,0 @@
|
||||
section.item{
|
||||
background-size:cover;
|
||||
background-attachment: fixed;
|
||||
background-image:url("grulla_10.jpg");
|
||||
background-position:center;
|
||||
display:block;
|
||||
padding:50px 0px 0px 0px;
|
||||
|
||||
}
|
||||
section.transp{
|
||||
background-color:rgba(255,255,255,0.8);
|
||||
max-width: 1000px;
|
||||
margin: auto;
|
||||
padding: 20px 0px;
|
||||
}
|
||||
|
||||
article.iimage{
|
||||
flex:5 1;
|
||||
margin:auto;
|
||||
display:inline;
|
||||
padding:0px 5px;
|
||||
|
||||
}
|
||||
img.small{
|
||||
border-radius:20px;
|
||||
display:block;
|
||||
width:auto;
|
||||
height:100%;
|
||||
min-height:60vh;
|
||||
margin:auto;
|
||||
padding:15px;
|
||||
}
|
||||
article.iinfo{
|
||||
flex:4 1;
|
||||
margin:auto;
|
||||
padding: 5px 15px;
|
||||
}
|
||||
p.txt{
|
||||
background-color:white;
|
||||
font-size:1.2em;
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
section.ibottom{
|
||||
background: #C22A39;
|
||||
padding:40px;
|
||||
|
||||
}
|
||||
|
||||
section.description{
|
||||
background-color:white;
|
||||
justify-content: center;
|
||||
-webkit-justify-content: center;
|
||||
}
|
||||
|
||||
p.promo{
|
||||
color: #c22a39;
|
||||
font-size: 1.4em;
|
||||
text-align:right;
|
||||
margin-right:10%;
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
|
||||
p.elow{
|
||||
color: black;
|
||||
font-size: 1.4em;
|
||||
text-align:right;
|
||||
margin-right:10%;
|
||||
}
|
||||
|
||||
p.eldep{
|
||||
color: #c22a39;
|
||||
font-size: 1.4em;
|
||||
text-align:right;
|
||||
text-transform: uppercase;
|
||||
margin-right:10%;
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
div.ppl{
|
||||
background-color: rgba(0,0,0,0.8);
|
||||
border-radius: 25px;
|
||||
padding:20px;
|
||||
text-align: center;
|
||||
}
|
||||
p.nombre{
|
||||
font-size: 2.2em;
|
||||
color: white;
|
||||
text-align: left;
|
||||
margin: auto;
|
||||
text-decoration: underline;
|
||||
max-width:850px;
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
p.tit{
|
||||
font-size: 1.8em;
|
||||
color: white;
|
||||
text-align: center;
|
||||
margin: 30px auto;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,131 +0,0 @@
|
||||
|
||||
var stripe = Stripe('pk_test_wxFt0GhsUK2YsprkLXa2iFrQ00nfjAeucu');
|
||||
var elements = stripe.elements();
|
||||
var cardElement = elements.create('card', {
|
||||
style: {
|
||||
base: {
|
||||
//iconColor: '#c4f0ff',
|
||||
iconColor: '#64a0af',
|
||||
color: '#000000',
|
||||
fontWeight: 500,
|
||||
fontFamily: 'Roboto, Open Sans, Segoe UI, sans-serif',
|
||||
fontSize: '18px',
|
||||
fontSmoothing: 'antialiased',
|
||||
':-webkit-autofill': {
|
||||
color: '#fce883',
|
||||
},
|
||||
'::placeholder': {
|
||||
// color: '#87BBFD',
|
||||
color: '#87BBFD',
|
||||
},
|
||||
},
|
||||
invalid: {
|
||||
iconColor: '#8f577e',
|
||||
color: '#8F577E',
|
||||
},
|
||||
},
|
||||
});
|
||||
cardElement.mount('#card-element');
|
||||
|
||||
|
||||
var cardholderName = document.getElementById('cardholder-name');
|
||||
var cardButton = document.getElementById('card-button');
|
||||
|
||||
///*y este el codigo de validación de la tarjeta*/
|
||||
cardButton.addEventListener('click', function(ev) {
|
||||
document.getElementById('cover').hidden = false;
|
||||
document.getElementById("cover").style.opacity = "0.8";
|
||||
stripe.createPaymentMethod('card', cardElement, {
|
||||
billing_details: {name: cardholderName.value}
|
||||
})
|
||||
.then(function(result) {
|
||||
// Show error in payment form
|
||||
if (result.error) {
|
||||
document.getElementById("cover").style.opacity = "0";
|
||||
setTimeout(function(){ document.getElementById('cover').hidden = true;},500);
|
||||
console.log("network error");
|
||||
}
|
||||
// Otherwise send paymentMethod.id to your server (see Step 2)
|
||||
else {
|
||||
fetch('/xpay', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ payment_method_id: result.paymentMethod.id, req:"precheck"})
|
||||
})
|
||||
.then(function(result) {
|
||||
// Handle server response (see Step 3)
|
||||
result.json().then(function(json) { handleInstallmentPlans(json); })
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
///*presenta los planes de pago */
|
||||
const selectPlanForm = document.getElementById('installment-plan-form');
|
||||
let availablePlans = [];
|
||||
|
||||
const handleInstallmentPlans = async (response) => {
|
||||
if (response.error) { // Show error from server on payment form
|
||||
console.log("preauth response error");
|
||||
}
|
||||
else {
|
||||
// Store the payment intent ID.
|
||||
document.getElementById('payment-intent-id').value = response.intent_id;
|
||||
availablePlans = response.available_plans;
|
||||
// Show available installment options
|
||||
availablePlans.forEach((plan, idx) => {
|
||||
const newInput = document.getElementById('immediate-plan').cloneNode();
|
||||
newInput.setAttribute('value', idx);
|
||||
newInput.setAttribute('id', '');
|
||||
const label = document.createElement('label');
|
||||
label.appendChild(newInput);
|
||||
label.appendChild(
|
||||
document.createTextNode(`${plan.count} meses`),
|
||||
);
|
||||
selectPlanForm.appendChild(label);
|
||||
});
|
||||
document.getElementById('cinfo').hidden = true;
|
||||
document.getElementById('cplan').hidden = false;
|
||||
}
|
||||
document.getElementById("cover").style.opacity = "0";
|
||||
setTimeout(function(){ document.getElementById('cover').hidden = true;},500);
|
||||
};
|
||||
|
||||
// termina la transacción
|
||||
const confirmButton = document.getElementById('confirm-button');
|
||||
confirmButton.addEventListener('click', async (ev) => {
|
||||
document.getElementById('cover').hidden = false;
|
||||
document.getElementById("cover").style.opacity = "0.8";
|
||||
const selectedPlanIdx = selectPlanForm.installment_plan.value;
|
||||
const selectedPlan = availablePlans[selectedPlanIdx];
|
||||
const intentId = document.getElementById('payment-intent-id').value;
|
||||
const response = await fetch('/xpay', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({
|
||||
payment_intent_id: intentId,
|
||||
selected_plan: selectedPlan,
|
||||
req:"check"
|
||||
}),
|
||||
});
|
||||
const responseJson = await response.json();
|
||||
// Show success / error response.
|
||||
document.getElementById("cover").style.opacity = "0";
|
||||
setTimeout(function(){ document.getElementById('cover').hidden = true;},500);
|
||||
document.getElementById('cmsg').hidden = false;
|
||||
document.getElementById('cplan').hidden = true;
|
||||
var message;
|
||||
if (responseJson.status === "succeeded" && selectedPlan !== undefined) {
|
||||
message = `¡Tu compra a ${
|
||||
selectedPlan.count
|
||||
} meses sin intereses se ha realizado con éxito! `;
|
||||
} else if (responseJson.status === "succeeded") {
|
||||
message = "¡Tu compra se ha realizado con éxito!";
|
||||
} else {
|
||||
message = `Tenemos un problema para verificar tus datos.
|
||||
Por favor intenta de nuevo o comunícate con nosotros`;
|
||||
}
|
||||
|
||||
document.getElementById("status-message").innerText = message;
|
||||
});
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
html{font-family:"serif";}
|
||||
section.title{
|
||||
/*background-color:#2f2c2c;*/
|
||||
/*color:white;*/
|
||||
}
|
||||
|
||||
article.title{
|
||||
}
|
||||
|
||||
h2{
|
||||
}
|
||||
h1{
|
||||
}
|
||||
div#cover{
|
||||
background: black;
|
||||
z-index: 85;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
transition:opacity .4s linear;
|
||||
top:0px;
|
||||
opacity:0;
|
||||
}
|
||||
section.cardinfo{
|
||||
}
|
||||
div#details{
|
||||
min-width:504px;
|
||||
}
|
||||
form{
|
||||
text-align:center;
|
||||
}
|
||||
label{
|
||||
text-align:center;
|
||||
margin:auto;
|
||||
}
|
||||
input{
|
||||
display:block;
|
||||
margin:auto;
|
||||
}
|
||||
|
||||
button{
|
||||
}
|
||||
div#card-element{
|
||||
}
|
||||
|
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 122 KiB |
|
Before Width: | Height: | Size: 112 KiB After Width: | Height: | Size: 112 KiB |
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 104 KiB |
|
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 118 KiB |
|
Before Width: | Height: | Size: 171 KiB After Width: | Height: | Size: 171 KiB |
|
Before Width: | Height: | Size: 136 KiB After Width: | Height: | Size: 136 KiB |
|
Before Width: | Height: | Size: 140 KiB After Width: | Height: | Size: 140 KiB |
|
Before Width: | Height: | Size: 132 KiB After Width: | Height: | Size: 132 KiB |
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 124 KiB After Width: | Height: | Size: 124 KiB |
|
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 111 KiB |
|
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 105 KiB |
|
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 105 KiB |
|
Before Width: | Height: | Size: 148 KiB After Width: | Height: | Size: 148 KiB |
|
Before Width: | Height: | Size: 151 KiB After Width: | Height: | Size: 151 KiB |
|
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 59 KiB |
|
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 130 KiB |
|
Before Width: | Height: | Size: 128 KiB After Width: | Height: | Size: 128 KiB |
|
Before Width: | Height: | Size: 144 KiB After Width: | Height: | Size: 144 KiB |
|
Before Width: | Height: | Size: 493 KiB After Width: | Height: | Size: 493 KiB |
|
Before Width: | Height: | Size: 493 KiB After Width: | Height: | Size: 493 KiB |
@@ -2,6 +2,7 @@
|
||||
var it=1;
|
||||
var students = new Array(10);
|
||||
|
||||
/* price format (comas) */
|
||||
window.addEventListener('load', function() {
|
||||
document.getElementById('cu').innerHTML=cu.toLocaleString();
|
||||
document.getElementById('gt').innerHTML=cu.toLocaleString();
|
||||
@@ -12,19 +13,25 @@ mq.addEventListener('change',function() {
|
||||
var mult = cu*mq.value;
|
||||
document.getElementById('gt').innerHTML=mult.toLocaleString();
|
||||
});
|
||||
/* ====================== */
|
||||
|
||||
/* hide contact form, show card info fields */
|
||||
/* vars to hide contact form, show card info fields */
|
||||
var cinfob = document.getElementById('cinfob');
|
||||
var cinfo = document.getElementById('cinfo');
|
||||
var cform = document.getElementById('cform');
|
||||
var ccard = document.getElementById('ccard');
|
||||
/* ====================== */
|
||||
|
||||
/* back button ========== */
|
||||
cinfob.addEventListener('click', function(ev){
|
||||
it --;
|
||||
atof();
|
||||
if (it==1){cinfob.hidden=true;}
|
||||
|
||||
});
|
||||
/* ====================== */
|
||||
|
||||
/* fwd button============ */
|
||||
cinfo.addEventListener('click', function(ev){
|
||||
if (
|
||||
(document.forms["cform"]["mname"].value =="") ||
|
||||
@@ -33,18 +40,39 @@ cinfo.addEventListener('click', function(ev){
|
||||
else if ( mq.value > it) {
|
||||
students[it - 1]=ftoa();
|
||||
it ++;
|
||||
if(typeof students[it - 1]!== "undefined"){
|
||||
atof();
|
||||
}
|
||||
if(typeof students[it - 1]!== "undefined"){ atof(); }
|
||||
cinfob.hidden=false;
|
||||
}
|
||||
else {
|
||||
students[it - 1]=ftoa();
|
||||
cform.hidden = true;
|
||||
ccard.hidden = false;
|
||||
document.getElementById('cover').hidden = false;
|
||||
document.getElementById("cover").style.opacity = "0.8";
|
||||
fetch('/spay/userCheck', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ students:students, req:"precheck", mq:mq.value})
|
||||
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
if(data.userst == "0"){
|
||||
cform.hidden = true;
|
||||
ccard.hidden = false;
|
||||
}
|
||||
else{ alert("hay un error en los datos de alumnos"); }
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
|
||||
document.getElementById("cover").style.opacity = "0";
|
||||
setTimeout(function(){ document.getElementById('cover').hidden = true;},500);
|
||||
}
|
||||
});
|
||||
|
||||
/* ====================== */
|
||||
|
||||
/* save form to array=== */
|
||||
function ftoa(){
|
||||
var rad;
|
||||
if (document.getElementById('r2').checked) { rad = document.getElementById('r2').value; }
|
||||
@@ -63,17 +91,21 @@ function ftoa(){
|
||||
|
||||
return x;
|
||||
}
|
||||
/* ====================== */
|
||||
|
||||
/* load form from array=== */
|
||||
function atof(){
|
||||
document.forms["cform"]["mname"].value = students[it-1][0];
|
||||
document.forms["cform"]["mmail"].value = students[it-1][1];
|
||||
document.getElementById('obs').value = students[it-1][2];
|
||||
if(document.getElementById('r2').value == students[it-1][3]){ document.getElementById('r2').checked=true;}
|
||||
if(document.getElementById('r1').value == students[it-1][3]){ document.getElementById('r1').checked=true;}
|
||||
if(document.getElementById('r3').value == students[it-1][3]){ document.getElementById('r3').checked=true;}
|
||||
document.forms["cform"]["mname"].value = students[it-1][0];
|
||||
document.forms["cform"]["mmail"].value = students[it-1][1];
|
||||
document.getElementById('obs').value = students[it-1][2];
|
||||
if(document.getElementById('r2').value == students[it-1][3]){ document.getElementById('r2').checked=true;}
|
||||
if(document.getElementById('r1').value == students[it-1][3]){ document.getElementById('r1').checked=true;}
|
||||
if(document.getElementById('r3').value == students[it-1][3]){ document.getElementById('r3').checked=true;}
|
||||
}
|
||||
/* ====================== */
|
||||
|
||||
/* stripe magic begins here */
|
||||
/* ====================================================== */
|
||||
var stripe = Stripe('pk_test_wxFt0GhsUK2YsprkLXa2iFrQ00nfjAeucu');
|
||||
var elements = stripe.elements();
|
||||
var cardElement = elements.create('card', {
|
||||
@@ -125,7 +157,7 @@ cardButton.addEventListener('click', function(ev) {
|
||||
fetch('/spay/intentCreate', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ payment_method_id: result.paymentMethod.id, req:"precheck", qantity:mq.value, tid:tid})
|
||||
body: JSON.stringify({ payment_method_id: result.paymentMethod.id, req:"precheck", mq:mq.value, tid:tid})
|
||||
})
|
||||
.then(function(result) {
|
||||
// Handle server response (see Step 3)
|
||||
@@ -144,6 +176,7 @@ const handleInstallmentPlans = async (response) => {
|
||||
console.log("preauth response error");
|
||||
}
|
||||
else {
|
||||
// si avaliable plans es indefinido, se queda alli con el cover
|
||||
// Store the payment intent ID.
|
||||
document.getElementById('payment-intent-id').value = response.intent_id;
|
||||
availablePlans = response.available_plans;
|
||||
@@ -1,5 +1,5 @@
|
||||
% stash css=>["/home/admin/admin.css","/home/admin/event/event.css"];
|
||||
% stash js=>["/home/admin/event/event.js"];
|
||||
% stash css=>["/admin/admin.css","/admin/event/event.css"];
|
||||
% stash js=>["//admin/event/event.js"];
|
||||
<section class="name" flex> <article class="user">
|
||||
<p class="title">Editar Eventos</p>
|
||||
</article> </section>
|
||||
@@ -1,5 +1,5 @@
|
||||
% stash css=>["/home/admin/admin.css","/home/admin/home/admin.css"];
|
||||
% stash js=>["/home/admin/home/buttons.js","/home/admin/home/fb.js"];
|
||||
% stash css=>["/admin/admin.css","/admin/home/admin.css"];
|
||||
% stash js=>["/admin/home/buttons.js","/admin/home/fb.js"];
|
||||
<section class="title flex">
|
||||
<article class="title"> <p>Editar Casa</p> </article>
|
||||
</section>
|
||||
@@ -1,5 +1,5 @@
|
||||
% stash css=>["/home/admin/admin.css","/home/admin/mensajes/msg.css"];
|
||||
% stash js=>["/home/admin/mensajes/msg.js"];
|
||||
% stash css=>["/admin/admin.css","/admin/mensajes/msg.css"];
|
||||
% stash js=>["/admin/mensajes/msg.js"];
|
||||
<section class="flex messages">
|
||||
<article class="select">
|
||||
<select id="sentry" class="entry" size=10>
|
||||
@@ -1,12 +1,12 @@
|
||||
% stash css=>[
|
||||
% "/home/admin/admin.css",
|
||||
% "/home/admin/radio/admin.css",
|
||||
% "/home/admin/candySwitch/main.css",
|
||||
% "/home/admin/candySwitch/switch.css"
|
||||
% "/admin/admin.css",
|
||||
% "/admin/radio/admin.css",
|
||||
% "/admin/candySwitch/main.css",
|
||||
% "/admin/candySwitch/switch.css"
|
||||
% ];
|
||||
% stash js=>[
|
||||
% "/home/admin/radio/loadInfo.js",
|
||||
% "/home/admin/candySwitch/cSwitch.js"
|
||||
% "/admin/radio/loadInfo.js",
|
||||
% "/admin/candySwitch/cSwitch.js"
|
||||
% ];
|
||||
<section class="title flex">
|
||||
<article class="title"> <p>Radio</p> </article>
|
||||
@@ -1,5 +1,5 @@
|
||||
% stash css=>["/home/admin/admin.css","/home/admin/tienda/tienda.css"];
|
||||
% stash js=>["/home/admin/tienda/tienda.js"];
|
||||
% stash css=>["/admin/admin.css","/admin/tienda/tienda.css"];
|
||||
% stash js=>["/admin/tienda/tienda.js"];
|
||||
<section class="flex">
|
||||
<article class="select">
|
||||
<select id="suser" class="entry" size=10>
|
||||
@@ -1,56 +0,0 @@
|
||||
|
||||
% stash css => ["misc/xpay.css"];
|
||||
% stash js => ["misc/stripe.js"];
|
||||
<section class="header">
|
||||
<h2 class="head"><%== $header %></h2>
|
||||
</section>
|
||||
<section class="title">
|
||||
<article class="title">
|
||||
<h2><%= $title %></h2>
|
||||
<h1><%= $subtitle %></h1>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="payment flex">
|
||||
<div id="cover" hidden></div>
|
||||
<article id="cinfo" class="cardinfo">
|
||||
<div class="subtitle"><h1>Datos de la tarjeta</h1></div>
|
||||
<div id="details">
|
||||
<label>Nombre del titular </label>
|
||||
<input id="cardholder-name" type="text" placeholder="Cardholder name">
|
||||
<!-- placeholder for Elements -->
|
||||
<label>Numero de tarjeta </label>
|
||||
<div id="card-element"></div>
|
||||
<button id="card-button">Siguiente</button>
|
||||
</div>
|
||||
</article>
|
||||
<!-- opciones de plan -->
|
||||
<article id="cplan" class="plan" hidden>
|
||||
<div class="subtitle"><h1>Planes de pago</h1></div>
|
||||
<div id="plans" >
|
||||
<form id="installment-plan-form" >
|
||||
<label>
|
||||
<input id="immediate-plan" type="radio" name="installment_plan" value="-1" />
|
||||
Un solo pago
|
||||
</label>
|
||||
<input id="payment-intent-id" type="hidden" />
|
||||
</form>
|
||||
<button id="confirm-button">Confirmar Pago</button>
|
||||
</div>
|
||||
</article>
|
||||
<article id="cmsg" class="message" hidden>
|
||||
<div id="result">
|
||||
<p id="status-message"></p>
|
||||
</div>
|
||||
<div id="ccontact" hidden>
|
||||
<form id="fcontact">
|
||||
<label for="cname">Nombre</label>
|
||||
<input type="text" name="cname"></input>
|
||||
<label for="cmail">Correo</label>
|
||||
<input type="email" name="cmail"></input>
|
||||
<label for="ccomment">Comentarios</label>
|
||||
<input type="text" name="ccomment"></input>
|
||||
</form>
|
||||
</div>
|
||||
<article>
|
||||
</section>
|
||||
@@ -1,4 +1,4 @@
|
||||
% stash css=>["home/cal/cal.css/"];
|
||||
% stash css=>["proc/cal/cal.css/"];
|
||||
<section class="title"> <p>Próximos eventos</p></section>
|
||||
<section class="cal">
|
||||
% foreach (@$b) {
|
||||
@@ -19,7 +19,7 @@
|
||||
<p class="name"> <%= $d->{nombre} %></p>
|
||||
</article>
|
||||
<article class="image">
|
||||
<img class="small" src= "home/cal/img/<%= $d->{imagen_chica} %>">
|
||||
<img class="small" src= "proc/cal/img/<%= $d->{imagen_chica} %>">
|
||||
<article class="more"> ... </article>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
%stash css=>["/home/storep/storep.css"];
|
||||
<section class="item"> <section class="transp flex">
|
||||
<section class="ibottom">
|
||||
<p class="nombre"><%= $nombre %></p>
|
||||
<p class="tit"><%= $lmunicipio %>, <%= $lfederativa %></p>
|
||||
</section>
|
||||
<article class=iimage>
|
||||
<img class="small" src= "/home/store/img/<%= $cimga %>">
|
||||
</article>
|
||||
<article class=iinfo>
|
||||
<p class="txt"><%= $subnombre %></p>
|
||||
<p class="txt"><%= $descripcion %></p>
|
||||
<p class="promo"><%= $promocion %></p>
|
||||
<p class="precio">Precio:$<%= $precio %> pesos</p>
|
||||
<p class="existencia">
|
||||
<% if ($cupo > 10) { =%> <p class="eok"></p> <% } =%>
|
||||
<% elsif ($cupo >= 5) { =%> <p class="elow">¡Nos quedan pocos lugarel!</p> <% } =%>
|
||||
<% elsif ($cupo == 0) { =%> <p class="eldep">¡Agotado!</p> <% } =%>
|
||||
<div class=forms> </div>
|
||||
</article>
|
||||
</section>
|
||||
<section class="bdat"> </section>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
% stash css=> ["/home/event/event.css"];
|
||||
% stash css=> ["/proc/event/event.css"];
|
||||
<section class="event">
|
||||
<section class="eimage">
|
||||
</section>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
%stash css=>["/home/spay/storep.css"];
|
||||
%stash js => ["/home/spay/stripe.js"];
|
||||
%stash css=>["/proc/spay/storep.css"];
|
||||
%stash js => ["/proc/spay/stripe.js"];
|
||||
<script src="https://js.stripe.com/v3/"></script>
|
||||
<script type="text/javascript"> var cu=<%= $precio %>; var tid=<%= $tid %></script>
|
||||
<section class="ibottom">
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
<article class=iimage>
|
||||
<p class="txt"><%= $subnombre %></p>
|
||||
<img class="small" src= "/home/store/img/<%= $cimga %>">
|
||||
<img class="small" src= "/proc/store/img/<%= $cimga %>">
|
||||
<p class="txt"><%= $descripcion %></p>
|
||||
</article>
|
||||
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
% stash css=>["/home/store/shop.css"];
|
||||
<section class="shop">
|
||||
<article class="heading"> <p class="heading">TIENDA VIRTUAL</p> </article>
|
||||
% for (@$r){
|
||||
<a href="/storep/<%= $_->{id} %>">
|
||||
<article class="shop flex">
|
||||
<div class="simage" > <img src=<%= "$controller/$action/img/$_->{imagen} "%> ></div>
|
||||
<div class="description">
|
||||
<p class="title"> <%= $_->{objeto} %> </p>
|
||||
<p class="description"> <%= $_->{nombre} %> </p>
|
||||
% if ( $_->{precio} != -1){
|
||||
<p class="price"> $<%= $_->{precio} %> pesos </p>
|
||||
%}
|
||||
<p class="options"> <%= $_->{subnombre} %> </p>
|
||||
<p class="promo"> <%= $_->{promocion} %> </p>
|
||||
</div>
|
||||
</article>
|
||||
</a>
|
||||
<article class="separator"></article>
|
||||
%}
|
||||
</section>
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
<!--<head>-->
|
||||
<!--<meta name="viewport" content="width=device-width, initial-scale=1">-->
|
||||
<!--<meta http-equiv="X-UA-Compatible" content="IE=edge" />-->
|
||||
<!--</head>-->
|
||||
%stash css=>["/home/storep/storep.css"];
|
||||
<section class="item"> <section class="transp flex">
|
||||
<article class=iimage>
|
||||
<img class="small" src= "/home/store/img/<%= $imagen %>">
|
||||
</article>
|
||||
<article class=iinfo>
|
||||
<p class="txt"><%= $subnombre %></p>
|
||||
<p class="txt"><%= $descripcion %></p>
|
||||
<p class="promo"><%= $promocion %></p>
|
||||
<p class="precio">Precio:$<%= $precio %> pesos</p>
|
||||
<p class="existencia">
|
||||
<% if ($existencia > 10) { =%> <p class="eok"></p> <% } =%>
|
||||
<% elsif ($existencia >= 1) { =%> <p class="elow">¡Nos quedan pocos!</p> <% } =%>
|
||||
<% elsif ($existencia == 0) { =%> <p class="eldep">¡Agotado!</p> <% } =%>
|
||||
<div class=ppl>
|
||||
<div id="paypal-button-container"></div>
|
||||
</div>
|
||||
</article>
|
||||
</section> </section>
|
||||
<section class="ibottom">
|
||||
<p class="nombre"><%= $objeto %></p>
|
||||
<p class="tit"><%= $nombre %></p>
|
||||
</section>
|
||||
<section class="bdat"> </section>
|
||||
|
||||
|
||||
<script src="https://www.paypal.com/sdk/js?client-id=AQdZ1JJL-GNBgGTI3W6cXChmj6MnZsInRGlWeHw1kbGiE_49eTtZ2fPvEq9ersU2y6O5WpxccdsyAQw7¤cy=MXN"></script>
|
||||
<script>
|
||||
paypal.Buttons({
|
||||
// Set up the transaction
|
||||
createOrder: function(data, actions) {
|
||||
return actions.order.create({
|
||||
purchase_units: [{
|
||||
amount: {
|
||||
value: '0.18'
|
||||
}
|
||||
}]
|
||||
}); },
|
||||
onApprove: function(data, actions) {
|
||||
return actions.order.capture().then(function(details) {
|
||||
return fetch('/tst', {
|
||||
method: 'post',
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
orderID: data.orderID
|
||||
})
|
||||
})
|
||||
// .then(response=>response.json())
|
||||
// .then(data => {alert(data)})
|
||||
});
|
||||
}
|
||||
}).render('#paypal-button-container');
|
||||
</script>
|
||||
|
||||