+ diff --git a/lib/Dojo.pm b/lib/Dojo.pm index fb3a2d9..cefbe55 100755 --- a/lib/Dojo.pm +++ b/lib/Dojo.pm @@ -27,7 +27,7 @@ use Dojo::Model::Users; $r->any('/contact')->to('home#contact'); $r->any('/contact2')->to('home#contact2'); $r->any('/pang')->to('home#pang'); - $r->any('/tst')->to('home#tst'); + # $r->any('/tst')->to('home#tst'); # ============================================================================= diff --git a/lib/Dojo/Controller/Home.pm b/lib/Dojo/Controller/Home.pm index b7f2a1d..d30d08f 100755 --- a/lib/Dojo/Controller/Home.pm +++ b/lib/Dojo/Controller/Home.pm @@ -10,38 +10,44 @@ use Data::Dumper; #========================= sub tst{ my $c=shift; - #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/2'; - #================= - #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); -#============== + 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); + #============== - -my $ub = LWP::UserAgent->new; -$ub->default_header('Authorization'=> 'Bearer ' . $r->{access_token} ); -my $resb=$ub->get($porder); -log("paypal checkout error!") unless ($resb->is_success ); - -my $jsonb = JSON->new->utf8; -my $s=$jsonb->decode($resb->decoded_content); - - - - - - $c->stash(res=>" $r->{expires_in} $s->{name}"); - $c->stash(layout=>'default'); + #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 %f=('descripcion',' Había una vez un lobito bueno al que maltrataban todos los corderos','precio','33','promo','si!','existencia','3','nombre','Super master evil man','titulo'=>'venganzas del medievo'); + $c->stash(%f); + $c->stash(res=> "no"); + $c->stash(layout=>'default'); + } #$c->render(text=> $c->config->{radio}{'channel'}); } diff --git a/public/home/event/event.css b/public/home/event/event.css index 91a087c..6b9c5a4 100755 --- a/public/home/event/event.css +++ b/public/home/event/event.css @@ -1,4 +1,4 @@ -section.eimage{ +section.item{ background-size:cover; height:80vh; background-attachment: fixed; diff --git a/public/home/tst/grulla_10.jpg b/public/home/tst/grulla_10.jpg new file mode 100755 index 0000000..5e7a690 Binary files /dev/null and b/public/home/tst/grulla_10.jpg differ diff --git a/public/home/tst/tst.css b/public/home/tst/tst.css index e69de29..af077aa 100755 --- a/public/home/tst/tst.css +++ b/public/home/tst/tst.css @@ -0,0 +1,106 @@ +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; +} + + diff --git a/templates/home/tst.html.ep b/templates/home/tst.html.ep index 9c3fc5e..3052997 100755 --- a/templates/home/tst.html.ep +++ b/templates/home/tst.html.ep @@ -2,42 +2,58 @@ -
- <%= url_for("$controller/$action/img") %> - %= url_for->path('/meself') -
--<%= $res %> -
- - +%stash css=>["/home/tst/tst.css"]; +
+ <%= $descripcion %>
+<%= $promo %>
+Precio:$<%= $precio %> pesos
++ <% if ($existencia > 10) { =%>
<% } =%> + <% elsif ($existencia >= 1) { =%>¡Nos quedan pocos!
<% } =%> + <% elsif ($existencia == 0) { =%>¡Agotado!
<% } =%> +<%= $nombre %>
+<%= $titulo %>
+