Payment sum_preauth fix

This commit is contained in:
Rainer Gümpelein 2022-02-17 13:41:16 +01:00
parent 7656e9d291
commit 435f6c1aa5

View file

@ -107,7 +107,7 @@ sub preauthorizationSEPA_main {
my $self = shift;
my $varenv = shift;
my $ctadr = shift;
my $ctt = shift;
my $ctt_rec = shift;
my $owner = shift || 0;
my $payoneret = "";
my $payone_conf = $dbt->{operator}->{$varenv->{dbname}}->{payone_conf} || $dbt->{payone_conf};
@ -118,25 +118,23 @@ sub preauthorizationSEPA_main {
table => "contenttrans",
fetch => "one",
template_id => 218,
c_id => $ctt->{c_id},
c_id => $ctt_rec->{c_id},
};
my $ctt_up = $dbt->fetch_record($dbh,$pref);
my $ctt = { c_id => 0 };
$ctt = $dbt->fetch_record($dbh,$pref);
$ctt->{ct_name} = $ctt_up->{ct_name};
if($ctt->{renewed}){
$ctt->{ct_name} = $ctt_up->{ct_name};
if($ctt_up->{ct_name} =~ /\d+-\d+/){
my ($ct_name,$subname) = split(/-/,$ctt_up->{ct_name});
if($ctt_rec->{renewed}){
if($ctt->{ct_name} =~ /\d+-\d+/){
my ($ct_name,$subname) = split(/-/,$ctt->{ct_name});
$subname++;
$ctt->{ct_name} = "$ct_name-$subname";
}else{
$ctt->{ct_name} = "$ctt_up->{ct_name}-1";
$ctt->{ct_name} = "$ctt->{ct_name}-1";
}
}
$ctt->{reference} = $dbt->{operator}->{$varenv->{dbname}}->{oprefix} . "-S-" . $ctt->{ct_name};
#2019-05-18, makes only sense if int15 alias $sum_preauth > 0
if($ctadr->{c_id} && $ctt->{c_id} && $ctt->{int15} > 0){
if($ctadr->{c_id} && $ctt->{c_id} && $ctt->{int01} > 0){
my $lastname = $ctadr->{txt01};
(my $firstname,$lastname) = split(/\s+/,$ctadr->{txt01}) if($ctadr->{txt01} =~ /\w\s+\w/i);
@ -153,7 +151,7 @@ sub preauthorizationSEPA_main {
#$currency = "CHF" if($bcountry eq "CH");
$ctadr->{txt23} =~ s/\s//g;
my $amount = 0;
$amount = $ctt->{int15} * 100 if($ctt->{int15});
$amount = $ctt->{int01} * 100 if($ctt->{int01});
my $preauth_request = {
request => 'preauthorization',
clearingtype => 'elv',
@ -186,10 +184,21 @@ sub captureSEPA_main {
my $self = shift;
my $varenv = shift;
my $ctadr = shift;
my $ctt = shift;
my $ctt_rec = shift;
my $owner = shift || 0;
my $payoneret = "";
my $payone_conf = $dbt->{operator}->{$varenv->{dbname}}->{payone_conf} || $dbt->{payone_conf};
my $dbh = "";
#to get actual data
my $pref = {
table => "contenttrans",
fetch => "one",
template_id => 218,
c_id => $ctt_rec->{c_id},
};
my $ctt = { c_id => 0 };
$ctt = $dbt->fetch_record($dbh,$pref);
if($ctt->{c_id} && (!$ctt->{state} || $ctt->{int14})){
my $amount = 0;
@ -214,7 +223,7 @@ sub preauthorizationCC_main {
my $self = shift;
my $varenv = shift;
my $ctadr = shift;
my $ctt = shift;
my $ctt_rec = shift;
my $owner = shift || 0;
my $payoneret = "";
my $payone_conf = $dbt->{operator}->{$varenv->{dbname}}->{payone_conf} || $dbt->{payone_conf};
@ -225,25 +234,23 @@ sub preauthorizationCC_main {
table => "contenttrans",
fetch => "one",
template_id => 218,
c_id => $ctt->{c_id},
c_id => $ctt_rec->{c_id},
};
my $ctt_up = $dbt->fetch_record($dbh,$pref);
my $ctt = { c_id => 0 };
$ctt = $dbt->fetch_record($dbh,$pref);
$ctt->{ct_name} = $ctt_up->{ct_name};
if($ctt->{renewed}){
$ctt->{ct_name} = $ctt_up->{ct_name};
if($ctt_up->{ct_name} =~ /\d+-\d+/){
my ($ct_name,$subname) = split(/-/,$ctt_up->{ct_name});
if($ctt_rec->{renewed}){
if($ctt->{ct_name} =~ /\d+-\d+/){
my ($ct_name,$subname) = split(/-/,$ctt->{ct_name});
$subname++;
$ctt->{ct_name} = "$ct_name-$subname";
}else{
$ctt->{ct_name} = "$ctt_up->{ct_name}-1";
$ctt->{ct_name} = "$ctt->{ct_name}-1";
}
}
$ctt->{reference} = $dbt->{operator}->{$varenv->{dbname}}->{oprefix} . "-C-" . $ctt->{ct_name};
#2019-05-18, makes only sense if int15 alias $sum_preauth > 0
if($ctadr->{c_id} && $ctt->{c_id} && $ctt->{int15} > 0){
if($ctadr->{c_id} && $ctt->{c_id} && $ctt->{int01} > 0){
my $lastname = $ctadr->{txt01};
(my $firstname,$lastname) = split(/\s+/,$ctadr->{txt01}) if($ctadr->{txt01} =~ /\w\s+\w/);
chomp($firstname);
@ -254,7 +261,7 @@ sub preauthorizationCC_main {
chomp($city);
my $amount = 0;
$amount = $ctt->{int15} * 100 if($ctt->{int15});
$amount = $ctt->{int01} * 100 if($ctt->{int01});
my $preauth_request = {
request => 'preauthorization',
clearingtype => 'cc',
@ -291,10 +298,21 @@ sub captureCC_main {
my $self = shift;
my $varenv = shift;
my $ctadr = shift;
my $ctt = shift;
my $ctt_rec = shift;
my $owner = shift || 0;
my $payoneret = "";
my $payone_conf = $dbt->{operator}->{$varenv->{dbname}}->{payone_conf} || $dbt->{payone_conf};
my $dbh = "";
#to get actual data
my $pref = {
table => "contenttrans",
fetch => "one",
template_id => 218,
c_id => $ctt_rec->{c_id},
};
my $ctt = { c_id => 0 };
$ctt = $dbt->fetch_record($dbh,$pref);
if($ctt->{c_id} && (!$ctt->{state} || $ctt->{int14} || $ctt->{txt28})){
my $amount = 0;
@ -618,11 +636,11 @@ sub payone_capture(){
}
#preauth
if($ctadr->{int03} && $ctadr->{int03} == 1 && $ctadr->{ct_name} && $ctadr->{ct_name} =~ /\w{2}-\d+/ && (!$ctt->{txt16} || $ctt->{int03} ne "1")){
if($ctadr->{int03} && $ctadr->{int03} == 1 && $ctadr->{ct_name} && $ctadr->{ct_name} =~ /\w{2}-\d+/ && !$ctt->{txt16}){
$self->preauthorizationSEPA_main($varenv,$ctadr,$ctt,$owner);
sleep 2;
}elsif($ctadr->{int03} && $ctadr->{int03} == 2 && $ctadr->{ct_name} && length($ctadr->{ct_name}) >= 19 && (!$ctt->{txt16} || $ctt->{int03} ne "2")){
}elsif($ctadr->{int03} && $ctadr->{int03} == 2 && $ctadr->{ct_name} && length($ctadr->{ct_name}) >= 19 && !$ctt->{txt16}){
$self->preauthorizationCC_main($varenv,$ctadr,$ctt,$owner);
sleep 2;
}
@ -639,7 +657,7 @@ sub payone_capture(){
$self->captureCC_main($varenv,$ctadr,$ctt,$owner);
}
else{
$return_text = "Payment.pm can not get TXID\n";
$return_text = "Payment.pm can not get TXID ($ctadr->{int03} && $ctadr->{ct_name} && !$ctt->{txt16})\n";
}
#wkhtml