From 9eec83fa3d31d54b0034237294a9377d46b3edca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rainer=20G=C3=BCmpelein?= Date: Fri, 18 Feb 2022 20:23:45 +0100 Subject: [PATCH] payment_check and sequencenumber --- copri4/main/css/local_style_2.css | 9 ++- copri4/main/src/Mod/Payment.pm | 63 ++++++++++++++----- copri4/main/src/Tpl/TransPositionen.pm | 25 ++++---- .../main/src/scripts/payone_post_Payment.pl | 1 + copri4/shareeweb-project/src/Lib/Mlogic.pm | 4 +- 5 files changed, 69 insertions(+), 33 deletions(-) create mode 120000 copri4/main/src/scripts/payone_post_Payment.pl diff --git a/copri4/main/css/local_style_2.css b/copri4/main/css/local_style_2.css index f7aaee0..cd4ba11 100755 --- a/copri4/main/css/local_style_2.css +++ b/copri4/main/css/local_style_2.css @@ -267,7 +267,14 @@ div#Oline { .element5:hover { background-color: #e6edf2; } - +.element6 { + margin:0.5em; + font-size:0.91em; + height: 1.7em; + padding:0.3em 0 0 0; + text-align:left; + border:0px; +} .elementwhite { background-color:white; color:black; diff --git a/copri4/main/src/Mod/Payment.pm b/copri4/main/src/Mod/Payment.pm index 06ebd6c..adc6357 100755 --- a/copri4/main/src/Mod/Payment.pm +++ b/copri4/main/src/Mod/Payment.pm @@ -132,9 +132,19 @@ sub preauthorizationSEPA_main { $ctt->{ct_name} = "$ctt->{ct_name}-1"; } } - $ctt->{reference} = $dbt->{operator}->{$varenv->{dbname}}->{oprefix} . "-S-" . $ctt->{ct_name}; + my $preauth_amount = 0; - if($ctadr->{c_id} && $ctt->{c_id} && $ctt->{int01} > 0){ + #for testing payment-data + if($ctt_rec->{c_id} && $ctt_rec->{c_id} == 1 && $ctt_rec->{reference}){ + $ctt = $ctt_rec; + $preauth_amount = $ctt->{int15};#int15 should only used for testing payment-data + }else{ + $preauth_amount = $ctt->{int01}; + $ctt->{reference} = $dbt->{operator}->{$varenv->{dbname}}->{oprefix} . "-S-" . $ctt->{ct_name}; + } + + + if($ctadr->{c_id} && $ctt->{c_id} && $preauth_amount > 0){ my $lastname = $ctadr->{txt01}; (my $firstname,$lastname) = split(/\s+/,$ctadr->{txt01}) if($ctadr->{txt01} =~ /\w\s+\w/i); @@ -151,7 +161,7 @@ sub preauthorizationSEPA_main { #$currency = "CHF" if($bcountry eq "CH"); $ctadr->{txt23} =~ s/\s//g; my $amount = 0; - $amount = $ctt->{int01} * 100 if($ctt->{int01}); + $amount = $preauth_amount * 100 if($preauth_amount); my $preauth_request = { request => 'preauthorization', clearingtype => 'elv', @@ -164,7 +174,6 @@ sub preauthorizationSEPA_main { country => "$ctadr->{txt10}", email => "$ctadr->{txt08}", telephonenumber => "$ctadr->{txt07}", - #sequencenumber => "0", amount => "$amount", currency => "$currency", iban => uc($ctadr->{txt22}), @@ -176,7 +185,7 @@ sub preauthorizationSEPA_main { $payoneret = $self->rpc("preauthorizationSEPA",$varenv,$request,$ctadr,$ctt,$owner) if($request); } return $payoneret; -} +}#end Request "preauthorizationSEPA" #Request "captureSEPA" @@ -199,23 +208,30 @@ sub captureSEPA_main { }; my $ctt = { c_id => 0 }; $ctt = $dbt->fetch_record($dbh,$pref); + my $TXID = $ctt->{txt16} || ""; + $TXID = $ctt_rec->{txid} if($ctt_rec->{txid}); + my $sequence = 1; + $sequence = $ctt_rec->{sequence} if($ctt_rec->{sequence}); + + #print Dumper($ctt); if($ctt->{c_id} && (!$ctt->{state} || $ctt->{int14})){ my $amount = 0; - $amount = $ctt->{int01} * 100 if($ctt->{int01}); + $amount = $ctt->{int01} * 100 if($ctt->{int01} != 0); my $currency = "EUR"; my $preauth_request = { request => 'capture', amount => "$amount", currency => "$currency", - txid => "$ctt->{txt16}" + txid => "$TXID", + sequencenumber => "$sequence" }; my $request = { %$payone_conf, %$preauth_request}; $payoneret = $self->rpc("captureSEPA",$varenv,$request,$ctadr,$ctt,$owner) if($request); } return $payoneret; -} +}#end Request "captureSEPA" #CC #Request "preauthorizationCC" @@ -248,9 +264,18 @@ sub preauthorizationCC_main { $ctt->{ct_name} = "$ctt->{ct_name}-1"; } } - $ctt->{reference} = $dbt->{operator}->{$varenv->{dbname}}->{oprefix} . "-C-" . $ctt->{ct_name}; + my $preauth_amount = 0; - if($ctadr->{c_id} && $ctt->{c_id} && $ctt->{int01} > 0){ + #for testing payment-data + if($ctt_rec->{c_id} && $ctt_rec->{c_id} == 1 && $ctt_rec->{reference}){ + $ctt = $ctt_rec; + $preauth_amount = $ctt->{int15};#int15 should only used for testing payment-data + }else{ + $preauth_amount = $ctt->{int01}; + $ctt->{reference} = $dbt->{operator}->{$varenv->{dbname}}->{oprefix} . "-C-" . $ctt->{ct_name}; + } + + if($ctadr->{c_id} && $ctt->{c_id} && $preauth_amount > 0){ my $lastname = $ctadr->{txt01}; (my $firstname,$lastname) = split(/\s+/,$ctadr->{txt01}) if($ctadr->{txt01} =~ /\w\s+\w/); chomp($firstname); @@ -261,7 +286,7 @@ sub preauthorizationCC_main { chomp($city); my $amount = 0; - $amount = $ctt->{int01} * 100 if($ctt->{int01}); + $amount = $preauth_amount * 100 if($preauth_amount); my $preauth_request = { request => 'preauthorization', clearingtype => 'cc', @@ -274,7 +299,6 @@ sub preauthorizationCC_main { country => "$ctadr->{txt10}", email => "$ctadr->{txt08}", telephonenumber => "$ctadr->{txt07}", - #sequencenumber => '0', amount => "$amount", currency => 'EUR', #Parameter ( personal data ) @@ -291,7 +315,7 @@ sub preauthorizationCC_main { $payoneret = $self->rpc("preauthorizationCC",$varenv,$request,$ctadr,$ctt,$owner) if($request); } return $payoneret; -} +}#end Request "preauthorizationCC" #Request "captureCC" sub captureCC_main { @@ -313,21 +337,26 @@ sub captureCC_main { }; my $ctt = { c_id => 0 }; $ctt = $dbt->fetch_record($dbh,$pref); + my $TXID = $ctt->{txt16}; + $TXID = $ctt_rec->{txid} if($ctt_rec->{txid}); + my $sequence = 1; + $sequence = $ctt_rec->{sequence} if($ctt_rec->{sequence}); if($ctt->{c_id} && (!$ctt->{state} || $ctt->{int14} || $ctt->{txt28})){ my $amount = 0; - $amount = $ctt->{int01} * 100 if($ctt->{int01}); + $amount = $ctt->{int01} * 100 if($ctt->{int01} != 0); my $preauth_request = { request => 'capture', amount => "$amount", currency => 'EUR', - txid => "$ctt->{txt16}" + txid => "$TXID", + sequencenumber => "$sequence" }; my $request = { %$payone_conf, %$preauth_request}; $payoneret = $self->rpc("captureCC",$varenv,$request,$ctadr,$ctt,$owner) if($request); } return $payoneret; -} +}#end Request "captureCC" #TODO #with previous preauthorization/ authorization and clearingtype=”elv”: @@ -492,7 +521,7 @@ sub rpc { print FILE "payone CAPTURE $now_dt\n $todo: txid=$txidval && ctt.c_id=$ctt->{c_id} && ctadr.c_id=$ctadr->{c_id}\n" if($debug); if($txidval && $ctt->{c_id} && $ctadr->{c_id} && $res->content =~ /settleaccount=/){ - #int01 and state will be set by "buchen" via Prelogic + #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; diff --git a/copri4/main/src/Tpl/TransPositionen.pm b/copri4/main/src/Tpl/TransPositionen.pm index 111cade..cd72a56 100755 --- a/copri4/main/src/Tpl/TransPositionen.pm +++ b/copri4/main/src/Tpl/TransPositionen.pm @@ -425,7 +425,7 @@ EOF my $m= 1 + $k - $n; $m++; print "\n"; - print "$payment_text\n"; + print "$payment_text\n"; print "\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"; @@ -493,24 +493,16 @@ EOF print $q->hidden(-name=>'printer_id', -value=>"PDF - Normalpapier", -override=>'1'); my $send_invoice_checkbox = 1; $send_invoice_checkbox = 0 if($ctt->{txt30}); - print $q->div({-class=>'element',-style=>'float:right;'}, + print $q->div({-class=>'element6',-style=>'float:right;'}, "buchen incl. drucken ",$but->checkbox("print_pdf","ct_trans","1","PDF drucken",""), " eMail Versand ",$but->checkbox("1","send_invoice","$send_invoice_checkbox","eMail Rechnung",""), $but->singlesubmit1("set_state","buchen"), - $but->selector("state","150px",$kind_of_payment,@_paymentstate)),"\n"; + $but->selector("state","250px",$kind_of_payment,@_paymentstate)),"\n"; } } - - my $praefix = "$ctt->{txt00}-$varenv{praefix}"; - if($ctt->{state} && $ctt->{int01}){ - - $ctt->{int01} =~ s/\./,/; - my $style = "color:red;" if($ctt->{int01} ne $sum_paid); - my $opos = ""; - $opos = "OPOS" if($ctt->{int14} eq "1"); - print $q->div({-style=>"float:right;padding:0.71em;font-size:0.81em;$style"},"[$opos $vibuchen_mtime Gebucht $ctt->{int01} € \"$ctt->{state}\"]") if($ctt->{state}); - } print $q->end_form; + + my $praefix = "$ctt->{txt00}-$varenv{praefix}"; print $q->div({-style=>"clear:both;height:0.1px;"},""),"\n"; if($ctt->{txt30}){ print $q->div({-style=>"padding:0.5em;font-size:0.81em;width:98%;text-align:right;"}, "$ctt->{txt30}"),"\n"; @@ -522,6 +514,13 @@ EOF print $q->div({-style=>"padding:0.5em;font-size:0.81em;width:98%;text-align:right;"}, "eMail wurde nicht versandt! Rechnung eMail ", $but->singlesubmit1("ct_trans","send_invoice_again","send_invoice_again")),"\n" if($users_dms->{u_id} == $dbt->{copri_conf}->{superu_id}); print $q->end_form; } + if($ctt->{state} && $ctt->{int01}){ + $ctt->{int01} =~ s/\./,/; + 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;"},"[$opos $vibuchen_mtime Gebucht $ctt->{int01} € \"$ctt->{state}\"]") if($ctt->{state}); + } if( -f "$varenv{pdf}/$praefix-$ctt->{ct_name}.pdf" && $varenv{metahost}){ print $q->div({-style=>"padding:0.5em;font-size:0.81em;width:98%;text-align:right;"}, "Download: ", $q->a({-href=>"$varenv{metahost}/pdf/$praefix-$ctt->{ct_name}.pdf", -target=>'_blank'},"$praefix-$ctt->{ct_name}.pdf")); diff --git a/copri4/main/src/scripts/payone_post_Payment.pl b/copri4/main/src/scripts/payone_post_Payment.pl new file mode 120000 index 0000000..f975fdd --- /dev/null +++ b/copri4/main/src/scripts/payone_post_Payment.pl @@ -0,0 +1 @@ +../../../../../sharee.bike/copri-bike/main/src/scripts/payone_post_Payment.pl \ No newline at end of file diff --git a/copri4/shareeweb-project/src/Lib/Mlogic.pm b/copri4/shareeweb-project/src/Lib/Mlogic.pm index 64cc35e..12a025b 100755 --- a/copri4/shareeweb-project/src/Lib/Mlogic.pm +++ b/copri4/shareeweb-project/src/Lib/Mlogic.pm @@ -47,8 +47,8 @@ sub tpl(){ if($users_sharee->{c_id} && $R::sharee_edit ne "delete_account2" && ($users_sharee->{c_id} eq $varenv->{superu_id} || $users_sharee->{c_id} eq "22262" || $dbt->{copri_conf}->{stage} eq "test")){ my $coo = $q->cookie('domcookie') || $q->param('sessionid') || ""; - my $api_test = "sharee_kn"; - #my $api_test = "sharee_fr01"; + #my $api_test = "sharee_kn"; + my $api_test = "sharee_fr01"; print $q->div({-style=>'float:right;text-align:right;height:25px;padding:6px 15px;background-color:white'},$q->a({-style=>"color:#$bgcolor1;", -href=>"$varenv->{metahost}/src/scripts/tests/index.pl?sessionid=$coo\&api_test=$api_test", -target=>'_blank'}," [ $api_test ] ")),"\n"; }