payment_check and sequencenumber

This commit is contained in:
Rainer Gümpelein 2022-02-18 20:23:45 +01:00
parent 435f6c1aa5
commit 9eec83fa3d
5 changed files with 69 additions and 33 deletions

View file

@ -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;