save enhanced payment logging

This commit is contained in:
ragu 2022-12-16 08:37:05 +01:00
parent d786a0f30e
commit a645d292d5
13 changed files with 100 additions and 49 deletions

View file

@ -540,10 +540,12 @@ sub service_update(){
$update_pos->{int28} = 2 if($ctpos->{int28} && $ctpos->{int28} == 3);
#update bike charge on pos and content
if($q->param('charge_current_bars') =~ /^\d+$/){
if(looks_like_number($q->param('charge_current_bars'))){
my $max_bars = 5;
my $current_percent = $bw->battery_percent($max_bars,$q->param('charge_current_bars'));
$update_pos->{int19} = $current_percent;
#NO, because of service_work should also be deleted if > 50%
#$self->service_automatic($q,$current_percent) if($current_percent <= 50);
#update also bike charge
my $update_bike = {
@ -1534,7 +1536,7 @@ sub smartlock {
#only by system=Ilockit
if($record_pos->{int11} eq "2" && $q->param('voltage') && $q->param('voltage') =~ /(\d+)/){
$update_cc->{int14} = $1;
$self->service_automatic($q) if($1 <= 50);
$self->service_automatic($q,"") if($1 <= 50);
}
my $update_pos = {
@ -1604,18 +1606,26 @@ sub smartlock {
sub service_automatic {
my $self = shift;
my $q = shift || "";
my $current_percent = shift || 0;
my $station_id = "";
my $bike_id = "";
$station_id = $1 if($q->param('station') =~ /(\d+)/);#could be also 0
$bike_id = $1 if($q->param('bike') && $q->param('bike') =~ /(\d+)/);
my $authraw = { c_id => $owner };#default sys API
my $lock_charge = "Achtung, Fahrradschloss Ladung unter " . $q->param('voltage') . "%";
my $charge = "";
if(looks_like_number($q->param('voltage'))){
$charge = "Achtung, Schloss-Akku Ladung " . $q->param('voltage') . "%";
}
if(looks_like_number($q->param('charge_current_bars'))){
$charge = "Achtung, Fahr-Akku Ladung " . $current_percent . "%";
}
my $response = {};
if(looks_like_number($bike_id) || looks_like_number($station_id)){
$q->param(-name=>'request',-value=>"service_done");
$q->param(-name=>'work_id',-value=>"txt01");
$q->param(-name=>'work_val',-value=>"$lock_charge");
$q->param(-name=>'work_val',-value=>"$charge");
my $article = looks_like_number($bike_id) || looks_like_number($station_id);
#insert only new dataset if mtime > 10 days

View file

@ -952,8 +952,8 @@ sub update_record(){
$set .= " $key=null,";#we need this for null values in operators loop
}
}
if($key =~ /(mtime|atime|pay_time|invoice_time)$/){
if($value && $value =~ /^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}$/){
if($key =~ /(mtime|atime|pay_time|invoice_time|warn_time)$/){
if($value && $value =~ /^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}$|^\d{2}\.\d{2}\.\d{4}$/){
$set .= " $key='$value',";
}else{
$set .= " $key='now()',";

View file

@ -378,6 +378,8 @@ sub handler {
$return = $pl->set_workflow($users_dms,$R::c_id4trans,$R::set_main_id4workflow) if(looks_like_number($R::c_id4trans) && looks_like_number($R::tpl_id4trans) && looks_like_number($R::set_main_id4workflow));
}elsif($R::ct_trans =~ /set_accounting2invoice/){
$return = $pl->set_accounting2invoice($users_dms,$R::c_id4trans,$R::set_main_id4workflow) if(looks_like_number($R::c_id4trans) && looks_like_number($R::tpl_id4trans) && looks_like_number($R::set_main_id4workflow));
}elsif($R::ct_trans =~ /save_text|save_adr/){
$return = $pl->save_text2contenttrans($users_dms,$R::c_id4trans) if(looks_like_number($R::c_id4trans));
}elsif($R::detail_search && $R::detail_search eq "operator_accounting"){
my $ck4ex = "@R::ck4ex" || "";
$return = $pl->operator_accounting($users_dms,$users_sharee,$R::accounting_type,$ck4ex);
@ -440,14 +442,13 @@ sub handler {
#Payone Response POST (TransactionStatus)
#payone response ($R::pseudocardpan || $R::status)
if($users_sharee->{c_id} && ($R::pseudocardpan || $R::status)){
my $payone_return;
my $payone_return = "";
open(FILE,">>$varenv{logdir}/payone-return-post.log");
print FILE "<--- $now_dt from Indexsharee.pm \nPayone return-way by ajaxCall: $R::status\n";
my @keywords = $q->param;
foreach(@keywords){
my $val = $q->param($_);
print FILE "$_=$val\n";
#TODO, check errormessages. At first we have do indicate what comes from payone!
$payone_return .= "$_=$val\n";# if($_ =~ /error|message/i);
}
close(FILE);
@ -464,11 +465,12 @@ sub handler {
#CC
if($R::pseudocardpan && length($R::pseudocardpan) >= 19){#done by payone AJAX return
#if($R::status eq "APPROVED")
$now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
$update_adr->{txt22} = "";
$update_adr->{txt23} = "";
$update_adr->{ct_name} = $q->escapeHTML($R::pseudocardpan);
$update_adr->{txt27} = $q->escapeHTML($R::status);
$update_adr->{txt28} = "";
$update_adr->{txt28} = $now_dt . " pseudocardpan\n" . $q->escapeHTML($payone_return);
$update_adr->{int12} = 0;
$update_adr->{int03} = 2;
$dbt->update_record($dbh,$update_adr,$users_sharee) if($users_sharee->{c_id} > 0);
@ -511,7 +513,7 @@ sub handler {
print redirect("$varenv{wwwhost}/$varenv{mandant}/$varenv{profile}?$returnwww$session_and");
exit 0;
}else{
$update_adr->{txt28} = $q->escapeHTML($payone_return);
$update_adr->{txt28} = $now_dt . " else pseudocardpan\n" . $q->escapeHTML($payone_return);
$update_adr->{int12} = $vde_on_fail;
$dbt->update_record($dbh,$update_adr,$users_sharee) if($users_sharee->{c_id} > 0);
$dbt->update_operatorsloop($varenv{dbname},$users_sharee->{c_id},"update");

View file

@ -567,6 +567,7 @@ sub newline(){
my $not_used = shift || "";#old
my $editor = shift || "";
$txtxx =~ s/\r\n/<br \/>/g if(!$editor);
$txtxx =~ s/\n/<br \/>/g if(!$editor);
return $txtxx;
}

View file

@ -70,7 +70,7 @@ print<<EOF
background: $bg_color2;
}
.ui-widget-overlay {
background: #666 url("$varenv{metahost}/js/jquery-ui-1.12.1/images/ui-bg_diagonals-thick_20_666666_40x40.png") 50% 50% repeat;
background: #666 url("$varenv{metahost}/external/jquery-ui-1.12.1/images/ui-bg_diagonals-thick_20_666666_40x40.png") 50% 50% repeat;
opacity: .5;
filter: Alpha(Opacity=50);
}

View file

@ -75,7 +75,7 @@ print<<EOF
background: $bg_color2;
}
.ui-widget-overlay {
background: #666 url("$varenv{metahost}/js/jquery-ui-1.12.1/images/ui-bg_diagonals-thick_20_666666_40x40.png") 50% 50% repeat;
background: #666 url("$varenv{metahost}/external/jquery-ui-1.12.1/images/ui-bg_diagonals-thick_20_666666_40x40.png") 50% 50% repeat;
opacity: .5;
filter: Alpha(Opacity=50);
}

View file

@ -462,8 +462,6 @@ sub rpc {
print FILE "\n*** $now_dt (ctadr_id:$ctadr->{c_id}, ctt_id:$ctt->{c_id}) from payone_post.pl\n$httpReqServer \n" if($debug);
print FILE "---> request to payone $todo:\n$post\n";
#Payone CONFIGURATION TransactionStatus URL:
#https://tinkrpc.copri.eu/src/scripts/postread_server.pl
#Check the outcome of the response
if ($res->is_success) {
print FILE "<--- return from payone $todo:\n" . $res->content . "\n" if($debug);
@ -487,7 +485,8 @@ sub rpc {
$update_adr->{txt23} = $val if($key eq "bic");
$update_adr->{ct_name} = $val if($key eq "mandate_identification");
$update_adr->{txt27} = $val if($key eq "mandate_status");
$update_adr->{txt28} = $val if($key eq "mandate_text" && ($val =~ /SEPA/ || !$val));
#$update_adr->{txt28} = $val if($key eq "mandate_text" && ($val =~ /SEPA/ || !$val));
$update_adr->{txt28} = $now_dt . " $todo\n" . $q->escapeHTML($res->content);
}
$update_adr->{int12} = 0;#Vde
$dbt->update_record($dbh,$update_adr,$ctadr) if($ctadr->{c_id} > 0);
@ -513,15 +512,14 @@ sub rpc {
$update_ctt->{txt16} = $txidval;
$update_ctt->{txt22} = $ctt->{payone_reset} if($ctt->{payone_reset});
$update_ctt->{txt26} = $ctadr->{ct_name};#Mandat/pseudocp
$update_ctt->{txt28} = "";
$update_adr->{int12} = 0;
$update_adr->{int17} = $useridval if($useridval);
$update_adr->{txt28} = "";
}elsif($ctadr->{c_id}){
$update_ctt->{int14} = 1;#OPOS
$update_ctt->{txt28} = $now_dt . $res->content;
$update_adr->{int12} = $vde_on_fail;#Vde
}
#2022-12-15 save log for any
$update_ctt->{txt28} = $now_dt . " $todo\n" . $res->content . "\n" . $update_ctt->{txt28};
}
#Capture
@ -533,15 +531,13 @@ sub rpc {
if($txidval && $ctt->{c_id} && $ctadr->{c_id} && $res->content =~ /settleaccount=/){
#int01 and state will be set by "buchen" via Prelogic or via payone_cron/Payment payone_capture
$update_ctt->{int14} = "null";
$update_ctt->{txt28} = "";
$update_adr->{int12} = 0;
$update_adr->{txt28} = "";
}else{#because of Prelogic logic set it empty if no capture
$update_ctt->{int14} = 1;#OPOS
$update_ctt->{txt28} = $now_dt . $res->content;
$update_adr->{int12} = $vde_on_fail;#Vde
#system(`$varenv->{basedir}/src/Mod/newsletter_tink.pl "$varenv->{basedir}" "$varenv->{wwwhost}" "send_capture_fail" "$ctadr->{c_id}" "$ctt->{ct_name}"`);
}
$update_ctt->{txt28} = $now_dt . " $todo\n" . $res->content . "\n" . $update_ctt->{txt28};
}
}else{#not APPROVED
@ -552,24 +548,18 @@ sub rpc {
#errormessage=Amount no longer available --> disabled
if($res->content !~ /errorcode=911/){
my $payone_message = "$now_dt\n" . $res->content . "\nAufgrund der payone Ablehnung wurde der Verleih gesperrt.\n";
if($payoneLive == 1 && $ctadr->{c_id}){
$update_ctt->{txt28} = $payone_message;
$update_adr->{txt28} = $payone_message;
$update_ctt->{txt28} = $now_dt . " $todo\n" . $res->content . "\nVde.\n" . $update_ctt->{txt28};
$update_adr->{txt28} = $now_dt . " $todo\n" . $res->content . "\nVde.\n" . $update_adr->{txt28};
#never delete on state=occupied, in this case ist must delete it on available
if($res->content !~ /errorcode=80/){
$update_adr->{int12} = $vde_on_fail;#Vde
}
}
if($payoneLive == 1 && $ctt->{c_id}){
$update_adr->{txt28} = $payone_message;
}
}else{
if($payoneLive == 1 && $ctt->{c_id}){
my $payone_message = "$now_dt\n" . $res->content . "\n";
$update_ctt->{txt28} = $payone_message;
$update_adr->{txt28} = $payone_message;
$update_ctt->{txt28} = $now_dt . " $todo\n" . $res->content . "\n" . $update_ctt->{txt28};
$update_adr->{txt28} = $now_dt . " $todo\n" . $res->content . "\n" . $update_adr->{txt28};
}
}
}
@ -579,7 +569,7 @@ sub rpc {
print FILE "payone RPC end\n\n" if($debug);
close(FILE) if($debug);
#set contentadr owner and mtime only if Vde or error will be set by payone id's
#set contentadr owner and mtime only if Vde or payone-return will be set by payone id's
if((($update_adr->{int12} && $update_adr->{int12} > 0) || $update_adr->{txt28}) && ($owner == 178 || $owner == 179)){
$update_adr->{owner} = "$owner";
$update_adr->{mtime} = "now()";

View file

@ -52,6 +52,45 @@ my %varenv = $cf->envonline();
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
my $debug=1;
#save invoice address or text
sub save_text2contenttrans {
my $self = shift;
my $users_dms = shift;
my $c_id = shift;
$q->import_names('R');
my @keywords = $q->param;
my $dbh = "";
my $feedb = { message => "" };
my $ctt = { c_id => $c_id };
my $update_ctt = {
table => "contenttrans",
owner => $users_dms->{u_id},
mtime => "now()",
};
foreach(@keywords){
my $val = $q->param($_);
my $valxx = $q->escapeHTML("$val");
my @val = $q->param($_);
$valxx = $q->escapeHTML("@val");
if($_ =~ /txt|int|state|time/){
$update_ctt->{$_} = "$valxx";
}
}
$u_rows += $dbt->update_record($dbh,$update_ctt,$ctt);
#empty warn_time if warnstate not set
if(!$R::int06){
$dbt->update_one($dbh,$update_ctt,"warn_time=null",$c_id);
}
$feedb->{u_rows} = $u_rows;
return $feedb;
}#end save_text2contenttrans
#part or fee to invoice
sub insert_contenttranspos {
my $self = shift;
@ -965,3 +1004,4 @@ sub operator_accounting {
}
1;