mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2024-11-15 23:26:34 +01:00
APIpayone for transaction state
This commit is contained in:
parent
f852443c6d
commit
2fca1ea00d
3 changed files with 163 additions and 2 deletions
157
copri4/main/src/Mod/APIpayone.pm
Executable file
157
copri4/main/src/Mod/APIpayone.pm
Executable file
|
@ -0,0 +1,157 @@
|
||||||
|
package Mod::APIpayone;
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
||||||
|
#
|
||||||
|
#Server for payone to get payment state like p-saldo
|
||||||
|
#
|
||||||
|
use lib qw(/var/www/copri-bike/shareeapp-primary/src);
|
||||||
|
use warnings;
|
||||||
|
use strict;
|
||||||
|
use Exporter;
|
||||||
|
our @ISA = qw (Exporter);
|
||||||
|
|
||||||
|
use POSIX;
|
||||||
|
use CGI;
|
||||||
|
use Apache2::Const -compile => qw(OK );
|
||||||
|
use Scalar::Util qw(looks_like_number);
|
||||||
|
use LWP::UserAgent;
|
||||||
|
use XML::Simple qw(:strict);
|
||||||
|
|
||||||
|
use Lib::Config;
|
||||||
|
use Mod::DBtank;
|
||||||
|
use Mod::Basework;
|
||||||
|
use Mod::Shareework;
|
||||||
|
use Mod::APIfunc;
|
||||||
|
use Digest::MD5 qw(md5 md5_hex);
|
||||||
|
use Data::Dumper;
|
||||||
|
use Sys::Hostname;
|
||||||
|
my $hostname = hostname;
|
||||||
|
|
||||||
|
sub handler {
|
||||||
|
my ($r) = @_;
|
||||||
|
my $q = new CGI;
|
||||||
|
my $netloc = $q->url(-base=>1);
|
||||||
|
#$q->import_names('R');
|
||||||
|
my $cf = new Config;
|
||||||
|
my $dbt = new DBtank;
|
||||||
|
my $bw = new Basework;
|
||||||
|
my $tk = new Shareework;
|
||||||
|
my $apif = new APIfunc;
|
||||||
|
|
||||||
|
my %varenv = $cf->envonline();
|
||||||
|
my $oprefix = $dbt->{operator}->{$varenv{dbname}}->{oprefix};
|
||||||
|
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
|
||||||
|
my $owner=178;#payone id
|
||||||
|
my @keywords = $q->param;
|
||||||
|
my $user_agent = $q->user_agent();
|
||||||
|
my $dbh = "";
|
||||||
|
|
||||||
|
if(1==1){
|
||||||
|
foreach(@keywords){
|
||||||
|
if(length($_) > 40 || length($q->param($_)) > 400){
|
||||||
|
print "<text>Failure 19900: amount of characters in $_ exceeds</text>";
|
||||||
|
return Apache2::Const::OK;
|
||||||
|
exit 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$bw->log("APIpayone request:\n--> user-agent '$user_agent'",$q,"");
|
||||||
|
print $q->header( -charset => 'ISO-8859-1' );
|
||||||
|
print "TSOK";
|
||||||
|
|
||||||
|
open(FILE,">>$varenv{logdir}/APIpayone.log");
|
||||||
|
print FILE "\n*--> $now_dt on $varenv{syshost}\n";
|
||||||
|
print FILE "TSOK\n";
|
||||||
|
|
||||||
|
#check if transfer
|
||||||
|
my $txaction="";
|
||||||
|
my $receivable="";
|
||||||
|
my $txid="";
|
||||||
|
my $reference="";
|
||||||
|
my $cardexpiredate=0;
|
||||||
|
|
||||||
|
my $update_adr = {
|
||||||
|
table => "contentadr",
|
||||||
|
mtime => "now()",
|
||||||
|
owner => $owner
|
||||||
|
};
|
||||||
|
|
||||||
|
my $update_ctt = {
|
||||||
|
table => "contenttrans",
|
||||||
|
mtime => "now()",
|
||||||
|
pay_time => "now()",
|
||||||
|
owner => $owner,
|
||||||
|
int14 => 0,#OPOS
|
||||||
|
int16 => 0,#balance
|
||||||
|
int18 => 0,#sequencenumber
|
||||||
|
};
|
||||||
|
|
||||||
|
my $operator_prefix = "";
|
||||||
|
|
||||||
|
foreach(@keywords){
|
||||||
|
my $val = $q->param($_);
|
||||||
|
$val = $q->escapeHTML("$val");
|
||||||
|
print FILE "$_=$val\n";
|
||||||
|
|
||||||
|
$txaction = $val if($_ eq "txaction");
|
||||||
|
$receivable = $val if($_ eq "receivable");
|
||||||
|
$txid = $val if($_ eq "txid");
|
||||||
|
if($_ eq "reference"){
|
||||||
|
$update_ctt->{txt25} = $val;
|
||||||
|
if($val =~ /^(\w+)-/){
|
||||||
|
$operator_prefix = $1;
|
||||||
|
if($operator_prefix ne $oprefix){
|
||||||
|
my $operator_conf = $dbt->get_operator_conf($operator_prefix);
|
||||||
|
if(ref($operator_conf) eq "HASH" && $operator_conf->{oprefix} && $operator_conf->{database}->{dbname}){
|
||||||
|
print FILE "operator_prefix ----> $operator_prefix\n";
|
||||||
|
$dbh = $dbt->dbconnect_extern($operator_conf->{database}->{dbname});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$update_ctt->{int16} = $val if($_ eq "balance");
|
||||||
|
$update_ctt->{int18} = $val if($_ eq "sequencenumber");
|
||||||
|
|
||||||
|
#contentadr
|
||||||
|
$update_adr->{int24} = $val if($_ eq "cardexpiredate");
|
||||||
|
}
|
||||||
|
|
||||||
|
#do updates on invoice by payone transaction data on matching TXID
|
||||||
|
if($txid && looks_like_number($receivable) && looks_like_number($update_ctt->{int16})){
|
||||||
|
my $ctt = { c_id => 0 };
|
||||||
|
my $ctadr = { c_id => 0 };
|
||||||
|
my $fetch_ctt = {
|
||||||
|
table => "contenttrans",
|
||||||
|
fetch => "one",
|
||||||
|
txt16 => $q->escapeHTML($txid),
|
||||||
|
};
|
||||||
|
$ctt = $dbt->fetch_tablerecord($dbh,$fetch_ctt) if($txid);
|
||||||
|
$ctadr->{c_id} = $ctt->{int10} if($ctt->{int10});
|
||||||
|
|
||||||
|
if($ctt->{c_id} > 0){
|
||||||
|
|
||||||
|
#balance > 0 then payment fails
|
||||||
|
if($update_ctt->{int16} > 0){
|
||||||
|
$update_ctt->{int14} = 1;
|
||||||
|
$update_ctt->{txt23} = "$now_dt $txaction\nSaldo > 0 Meldung, Rücklastschrift oder Mahnung?\n" . $ctt->{txt23} if($ctt->{txt23} !~ /0 Meldung,/);#only once;
|
||||||
|
}else{
|
||||||
|
$update_ctt->{int14} = "=::null";
|
||||||
|
$update_ctt->{txt23} = "$now_dt $txaction\n" . $ctt->{txt23};
|
||||||
|
}
|
||||||
|
|
||||||
|
$dbt->update_record($dbh,$update_ctt,$ctt);
|
||||||
|
|
||||||
|
#set cardexpiredate
|
||||||
|
if($update_adr->{int24} > 0 && $ctadr->{c_id} > 0){
|
||||||
|
$dbt->update_record($dbh,$update_adr,$ctadr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
close(FILE);
|
||||||
|
|
||||||
|
return Apache2::Const::OK;
|
||||||
|
}
|
||||||
|
1;
|
|
@ -142,6 +142,9 @@ sub handler {
|
||||||
int01 => "$xmlref->{userID}",
|
int01 => "$xmlref->{userID}",
|
||||||
txt08 => "$xmlref->{emailID}",
|
txt08 => "$xmlref->{emailID}",
|
||||||
txt11 => "$pwmd5",
|
txt11 => "$pwmd5",
|
||||||
|
int04 => "1",
|
||||||
|
int13 => "1",
|
||||||
|
int14 => "1",
|
||||||
};
|
};
|
||||||
my $rows = $dbt->update_record($dbh,$update,$record);
|
my $rows = $dbt->update_record($dbh,$update,$record);
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ sub printpre(){
|
||||||
my $mandant_main_id = $R::mandant_main_id;
|
my $mandant_main_id = $R::mandant_main_id;
|
||||||
my $id=$R::id;
|
my $id=$R::id;
|
||||||
|
|
||||||
|
my $payone_conf = $dbt->{operator}->{$varenv{dbname}}->{payone_conf} || $dbt->{payone_conf};
|
||||||
my $ctf = $db->get_content1("contentuser","$mandant_main_id");
|
my $ctf = $db->get_content1("contentuser","$mandant_main_id");
|
||||||
my $ctrel = $db->get_ctrel("contentadr","",$lang,"",$id);
|
my $ctrel = $db->get_ctrel("contentadr","",$lang,"",$id);
|
||||||
|
|
||||||
|
@ -92,10 +93,10 @@ body,html {
|
||||||
print $q->start_table({-border=>'0', -cellpadding=>'3', -cellspacing=>'0'}),"\n";
|
print $q->start_table({-border=>'0', -cellpadding=>'3', -cellspacing=>'0'}),"\n";
|
||||||
print $q->Tr(),"\n";
|
print $q->Tr(),"\n";
|
||||||
print $q->td({-class=>'tdname1'}, "Zahlungsempfänger"),"\n";
|
print $q->td({-class=>'tdname1'}, "Zahlungsempfänger"),"\n";
|
||||||
print $q->td({-class=>'tdval1'}, "$dbt->{payone_conf}->{sepa_creditor_name}"),"\n";
|
print $q->td({-class=>'tdval1'}, "$payone_conf->{sepa_creditor_name}"),"\n";
|
||||||
print $q->Tr(),"\n";
|
print $q->Tr(),"\n";
|
||||||
print $q->td({-class=>'tdname1'}, "Gläubiger-Identifikationsnummer"),"\n";
|
print $q->td({-class=>'tdname1'}, "Gläubiger-Identifikationsnummer"),"\n";
|
||||||
print $q->td({-class=>'tdval1'}, "$dbt->{payone_conf}->{sepa_creditor_id}"),"\n";
|
print $q->td({-class=>'tdval1'}, "$payone_conf->{sepa_creditor_id}"),"\n";
|
||||||
print $q->Tr(),"\n";
|
print $q->Tr(),"\n";
|
||||||
print $q->td({-class=>'tdname1'}, "Mandatsreferenz"),"\n";
|
print $q->td({-class=>'tdname1'}, "Mandatsreferenz"),"\n";
|
||||||
print $q->td({-class=>'tdval1'}, "$ctrel->{ct_name}"),"\n";
|
print $q->td({-class=>'tdval1'}, "$ctrel->{ct_name}"),"\n";
|
||||||
|
|
Loading…
Reference in a new issue