payone sequence by form transaction

This commit is contained in:
Rainer Gümpelein 2022-02-19 13:20:23 +01:00
parent 9eec83fa3d
commit 32213a7b46
4 changed files with 27 additions and 26 deletions

View file

@ -74,7 +74,10 @@ sub mail_transport(){
my $boundary = 'frontier';
my $pdfpath = "$dbt->{copri_conf}->{basedir}/$sendref->{syshost}/pdf";
my $attachBinaryFile = "";
my $filesize = 0;
if(-f "$pdfpath/$sendref->{attachment}"){
$filesize = -s "$pdfpath/$sendref->{attachment}";
$attachBinaryFile = "$sendref->{attachment}";
}
@ -84,6 +87,7 @@ sub mail_transport(){
}
print EMA "\n$now_dt, start mailing to: $mail_to | subject: $subject\n";
print EMA "attachment: $pdfpath/$sendref->{attachment} | filesize: $filesize\n";
my $html = "<html><head><title>$subject</title></head><body style='text-align:left;border:0px solid silver;padding:15px;margin:2%;width:90%;'>\n";
$html .= "<div>$sendref->{message}</div>\n";

View file

@ -542,7 +542,7 @@ 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. Die Bankdaten müssen überarbeitet werden\n";
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;
@ -659,7 +659,7 @@ sub payone_capture(){
$db->updater("contenttrans","c_id",$ctt->{c_id},"int14","2","","","","","");#must be to capture
#in cron we set OPOS anyway. If payone captured, it will be set int14=null
if(!$state || $state !~ /payone/){
$db->updater("contenttrans","c_id",$ctt->{c_id},"txt22","cronjob fail","","","","","");
#$db->updater("contenttrans","c_id",$ctt->{c_id},"txt22","cronjob fail","","","","","");
$return_text = "Payment.pm can not preauthorization because of absent payment-data in ctadr.c_id:$ctadr->{c_id}, SEPA/CC:$ctadr->{int03}, $ctadr->{ct_name}, we exit\n";
return $return_text;
}
@ -694,11 +694,16 @@ sub payone_capture(){
my $praefix = "$ctt->{txt00}-$varenv->{praefix}";#like Rechnung-sharee_operator
my $wc_line= $ctt->{int04};#Adresse.Tabelle
my $topdf = "$varenv->{basedir}/src/wkhtmltopdf-amd64";
my $print_return = `$topdf --page-size A4 "$varenv->{wwwhost}/Printpreview?printer_id=PDF\&mandant_main_id=$mandant_id\&main_id=$main_id\&ct_name2print=$ctt->{ct_name}\&c_id4trans=$ctt->{c_id}\&u_id=$owner\&wc=$wc_line" $varenv->{pdf}/$praefix-$ctt->{ct_name}.pdf 2>&1`;
my $exit_code = 1;
my $print_return = "";
$print_return = `$topdf --page-size A4 "$varenv->{wwwhost}/Printpreview?printer_id=PDF\&mandant_main_id=$mandant_id\&main_id=$main_id\&ct_name2print=$ctt->{ct_name}\&c_id4trans=$ctt->{c_id}\&u_id=$owner\&wc=$wc_line" $varenv->{pdf}/$praefix-$ctt->{ct_name}.pdf 2>&1`;
$exit_code = $?;
sleep 2;
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
my $filesize = -s "$varenv->{pdf}/$praefix-$ctt->{ct_name}.pdf";
open(EMA, ">> $varenv->{logdir}/copri-print.log");
print EMA "$now_dt\n$topdf --page-size A4 \"$varenv->{wwwhost}/Printpreview?printer_id=PDF\&mandant_main_id=$mandant_id\&main_id=$main_id\&ct_name2print=$ctt->{ct_name}\&c_id4trans=$ctt->{c_id}\&u_id=$owner\&wc=$wc_line\" $varenv->{pdf}/$praefix-$ctt->{ct_name}.pdf\n";
print EMA "\n$now_dt\n$topdf --page-size A4 \"$varenv->{wwwhost}/Printpreview?printer_id=PDF\&mandant_main_id=$mandant_id\&main_id=$main_id\&ct_name2print=$ctt->{ct_name}\&c_id4trans=$ctt->{c_id}\&u_id=$owner\&wc=$wc_line\" $varenv->{pdf}/$praefix-$ctt->{ct_name}.pdf\nreturn: $print_return\nfilesize: $filesize\nexit_code: $exit_code\n";
#send_invoice infomail
if(-f "$varenv->{pdf}/$praefix-$ctt->{ct_name}.pdf"){

View file

@ -775,8 +775,9 @@ sub preinit(){
}
#Payone managemandate (txt16=txid means payment process ID)
#2022-02-19, disabled Formular trigger at all because trying payone sequence numbering
my $subset_state = $R::set_state || $ctt->{state};
if($R::c_idadr && $subset_state =~ /payone/){
if(1==2 && $R::c_idadr && $subset_state =~ /payone/){
my $ctadr = $db->get_content1("contentadr",$R::c_idadr);
#SEPA
@ -812,21 +813,6 @@ sub preinit(){
if(($R::ct_trans =~ /print_pdf|print/i) || ("$R::set_main_id" != "$rel->{main_id}")){
my $table = "contenttrans";
#zum Angebot den Warenbestand hochsetzen!
if(($ctt->{txt00} !~ /Angebot|Kostenvoranschlag|Auftrag|Storno/) && ($node->{node_name} =~ /Angebot|Kostenvoranschlag|Auftrag/) && ("$ctb->{txt02}" ne "aus")){
my ($cttpos,$rows) = $db->collect_contentpos("$table",$users_dms->{c_id4trans});
foreach my $id (sort { lc($cttpos->{$a}->{sort}) cmp lc($cttpos->{$b}->{sort}) } keys(%$cttpos)){
$u_rows += $db->update_content4comp("content",$cttpos->{$id}->{ct_name},"$cttpos->{$id}->{cc_id}","+","$cttpos->{$id}->{int03}","$users_dms->{kind_of_trans}","$cttpos->{$id}->{txt12}");
}
}
#vom Angebot zur Rechnung usw. den Warenbestand runtersetzen!
if(($ctt->{txt00} =~ /Angebot|Kostenvoranschlag|Auftrag/) && ($node->{node_name} !~ /Angebot|Kostenvoranschlag|Auftrag/) && ("$ctb->{txt02}" ne "aus")){
my ($cttpos,$rows) = $db->collect_contentpos("$table",$users_dms->{c_id4trans});
foreach my $id (sort { lc($cttpos->{$a}->{sort}) cmp lc($cttpos->{$b}->{sort}) } keys(%$cttpos)){
$u_rows += $db->update_content4comp("content",$cttpos->{$id}->{ct_name},"$cttpos->{$id}->{cc_id}","-","$cttpos->{$id}->{int03}","$users_dms->{kind_of_trans}","$cttpos->{$id}->{txt12}");
}
}
$u_rows += $db->update_content4change($table,$c_id,"",$R::set_main_id,"int12");#zusätzl. Formtyp
$db->update_content4change($table,$c_id,"",$node->{node_name},"txt00");#node_name
$db->update_content4change($table,$c_id,"",$ctb->{txt06},"txt13") if($ctb->{txt06});#vendor name
@ -866,8 +852,9 @@ sub preinit(){
my $payoneret = $payone->preauthorizationCC_main(\%varenv,$ctadr,$ctt,$users_dms->{u_id});
sleep 2;
}
#2018-10-18, check if preauth is done with txid (txt16)
$ctt = $db->get_content1("contenttrans",$c_id);
$ctt->{sequence} = $R::payone_sequence || 1;
#SEPA capture
if($ctt->{int03} == 1 && $ctt->{txt16} && $R::state =~ /SEPA/ && $state !~ /Zahlungseingang/){#SEPA

View file

@ -231,7 +231,7 @@ EOF
}
if(($c_idpos == $cttpos->{$id}->{c_id}) && ($R::trans2edit && $R::trans2edit =~ /transpos/)){
if($key =~ /ct_name/){
print $q->td({-class=>'element',-style=>"$set_style text-align:right;"}, $q->textfield(-class=>'etxt',-style=>"text-align:right;min-width:120px;",-name=>"ct_name",-default=>"$ct_pos", -override=>'1',-size=>10,-readonly=>'1'),"\n");
print $q->td({-class=>'element',-style=>"$set_style text-align:right;"}, $q->textfield(-class=>'etxt',-style=>"text-align:right;min-width:120px;",-name=>"ct_name",-default=>"$ct_pos", -override=>'1',-size=>10,-readonly=>'1')),"\n";
}elsif($key eq "int26"){
my $co2saving = "";
if($cttpos->{$id}->{int26}){
@ -248,7 +248,7 @@ EOF
}elsif($key =~ /int03/){
#TODO, autocalc Menge Preis by time-range
#Menge
print $q->td({-colspan=>'1',-class=>'element',-style=>"$txtstyle $set_style"},$q->textfield(-class=>'etxt',-style=>"$txtstyle",-name=>"col_$key",-default=>"$cttpos->{$id}->{$key}", -override=>'1',-size=>"$isize",-maxlength=>10, -autofocus=>1),"\n");
print $q->td({-colspan=>'1',-class=>'element',-style=>"$txtstyle $set_style"},$q->textfield(-class=>'etxt',-style=>"$txtstyle",-name=>"col_$key",-default=>"$cttpos->{$id}->{$key}", -override=>'1',-size=>"$isize",-maxlength=>10, -autofocus=>1)),"\n";
}elsif($key =~ /int02/){
#Einzelpreis
print $q->td({-class=>'element',-style=>"$txtstyle $set_style"},$q->textfield(-class=>'etxt',-style=>"$txtstyle",-name=>"col_$key",-default=>"$cttpos->{$id}->{$key}", -override=>'1',-size=>"$isize",-maxlength=>100),"\n");
@ -425,7 +425,7 @@ EOF
my $m= 1 + $k - $n;
$m++;
print "<tr>\n";
print "<td class='element6' colspan='$m'>$payment_text</td>\n";
print "<td colspan='$m'><div class='element6'>$payment_text</div></td>\n";
print "<td style='font-size:1em;' colspan='$n'>\n";
print $q->start_table({-class=>'list',-style=>'border-top:1px;border-style:solid;border-color:black;', -border=>'0', -width=>'100%',-align=>'center', -cellpadding=>'3', -cellspacing=>'0'}),"\n";
@ -470,6 +470,7 @@ EOF
#if(!$ctt->{close_time} && $varenv{Zahlungsweise} && $users_dms->{u_id} == $dbt->{copri_conf}->{superu_id}){
if($users_dms->{int03} == 2){
#only if user is also a primary DMS user with invoice rw
print $q->hidden(-name=>'printer_id', -value=>"PDF - Normalpapier", -override=>'1');
my $dbh_primary = $dbt->dbconnect_extern("sharee_primary");
my $users_dms_primary = { u_id => 0 };
$users_dms_primary = $dbt->select_users($dbh_primary,$users_dms->{u_id},"and int03=2");
@ -490,7 +491,11 @@ EOF
}
$kind_of_payment = "$ctt->{state}" if($ctt->{state});
print $q->hidden(-name=>'printer_id', -value=>"PDF - Normalpapier", -override=>'1');
#further payone capture are only allowed if OPOS && sequence && TXID is set
if($ctt->{int14} && $ctt->{int18} && $ctt->{txt16}){
print $q->div({-class=>'element6',-style=>'float:right;'},"seq", $q->textfield(-class=>'etxt',-name=>"payone_sequence",-default=>"", -override=>'1',-size=>"1",-maxlength=>1)),"\n";
}
my $send_invoice_checkbox = 1;
$send_invoice_checkbox = 0 if($ctt->{txt30});
print $q->div({-class=>'element6',-style=>'float:right;'},
@ -519,7 +524,7 @@ EOF
my $style = "color:red;" if($ctt->{int01} ne $sum_paid);
my $opos = "";
$opos = "OPOS" if($ctt->{int14} && $ctt->{int14} > 0);
print $q->div({-style=>"padding:0.5em;font-size:0.81em;width:98%;text-align:right;"},"[<span style='color:red;'>$opos</span> $vibuchen_mtime Gebucht $ctt->{int01} € \"$ctt->{state}\"]") if($ctt->{state});
print $q->div({-style=>"padding:0.5em;font-size:0.81em;width:98%;text-align:right;"},"<span style='color:red;'>$opos</span> $vibuchen_mtime Gebucht $ctt->{int01} € \"$ctt->{state}\"") if($ctt->{state});
}
if( -f "$varenv{pdf}/$praefix-$ctt->{ct_name}.pdf" && $varenv{metahost}){