mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-02-22 19:56:29 +01:00
payment link request refactoring
This commit is contained in:
parent
6212b1aefb
commit
addf1ab6db
13 changed files with 227 additions and 194 deletions
|
@ -27,6 +27,7 @@ use Mod::DBtank;
|
||||||
use Mod::Callib;
|
use Mod::Callib;
|
||||||
use Mod::Basework;
|
use Mod::Basework;
|
||||||
use Mod::Pricing;
|
use Mod::Pricing;
|
||||||
|
use Mod::Payment;
|
||||||
use Mod::MailTransport;
|
use Mod::MailTransport;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
use Sys::Hostname;
|
use Sys::Hostname;
|
||||||
|
@ -37,6 +38,7 @@ my $dbt = new DBtank;
|
||||||
my $cal = new Callib;
|
my $cal = new Callib;
|
||||||
my $bw = new Basework;
|
my $bw = new Basework;
|
||||||
my $pri = new Pricing;
|
my $pri = new Pricing;
|
||||||
|
my $pay = new Payment;
|
||||||
my $mailtrans = new MailTransport;
|
my $mailtrans = new MailTransport;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
|
@ -3009,7 +3011,7 @@ sub auth_verify(){
|
||||||
#first prepaid account check (not save because without rental history)
|
#first prepaid account check (not save because without rental history)
|
||||||
if($auth_primary->{int03} == 3){
|
if($auth_primary->{int03} == 3){
|
||||||
my $prepaidhash = { prepaid_total => 0 };
|
my $prepaidhash = { prepaid_total => 0 };
|
||||||
$prepaidhash = $pri->collect_prepaid($dbh_primary,$auth_primary) if($auth_primary->{c_id});
|
$prepaidhash = $pay->collect_prepaid($dbh_primary,$auth_primary) if($auth_primary->{c_id});
|
||||||
if(!$prepaidhash->{prepaid_total} || $prepaidhash->{prepaid_total} < 0){
|
if(!$prepaidhash->{prepaid_total} || $prepaidhash->{prepaid_total} < 0){
|
||||||
my $vde = $auth_primary->{int12} || 1;
|
my $vde = $auth_primary->{int12} || 1;
|
||||||
$update_primary->{int12} = $vde;
|
$update_primary->{int12} = $vde;
|
||||||
|
|
|
@ -71,7 +71,7 @@ my $response = {
|
||||||
apiserver => "$apiserver",
|
apiserver => "$apiserver",
|
||||||
response => "$respreq",
|
response => "$respreq",
|
||||||
uri_primary => "$dbt->{primary}->{sharee_primary}->{primaryApp}",
|
uri_primary => "$dbt->{primary}->{sharee_primary}->{primaryApp}",
|
||||||
copri_version => "4.1.23.26",
|
copri_version => "4.1.23.28",
|
||||||
user_id => "",
|
user_id => "",
|
||||||
authcookie => "",
|
authcookie => "",
|
||||||
new_authcoo => "0",
|
new_authcoo => "0",
|
||||||
|
|
|
@ -553,10 +553,9 @@ sub handler {
|
||||||
if($users_sharee->{c_id} && $R::sharee_edit && $R::sharee_edit =~ /save_transact/){
|
if($users_sharee->{c_id} && $R::sharee_edit && $R::sharee_edit =~ /save_transact/){
|
||||||
$returnwww = $shwo->save_transact($q,$users_sharee->{c_id},$coo,$aowner);
|
$returnwww = $shwo->save_transact($q,$users_sharee->{c_id},$coo,$aowner);
|
||||||
}
|
}
|
||||||
#we do it in PayoneLink.pm
|
if($users_sharee->{c_id} && $R::sharee_edit && $R::sharee_edit =~ /generate_payonelink/ && $R::prepaid_amount && $R::prepaid_amount =~ /\d+/){
|
||||||
#if($users_sharee->{c_id} && $R::sharee_edit && $R::sharee_edit =~ /generate_payonelink/){
|
system("$dbt->{copri_conf}->{basedir}/$varenv{syshost}/src/scripts/payonelink.pl '$varenv{syshost}' '$users_sharee->{c_id}' '$R::prepaid_amount' '$aowner' &");
|
||||||
# $returnwww = $pay->generate_payonelink($q,\%varenv,$users_sharee,$R::prepaid_id,$R::prepaid_amount,$aowner);
|
}
|
||||||
#}
|
|
||||||
|
|
||||||
if($returnwww && $returnwww =~ /failure::(.*)/){
|
if($returnwww && $returnwww =~ /failure::(.*)/){
|
||||||
$returnwww =~ s/::/=/g;
|
$returnwww =~ s/::/=/g;
|
||||||
|
|
|
@ -101,7 +101,7 @@ sub country_code(){
|
||||||
'DK' => 'Dänemark',
|
'DK' => 'Dänemark',
|
||||||
'EE' => 'Estland',
|
'EE' => 'Estland',
|
||||||
'IE' => 'Irland',
|
'IE' => 'Irland',
|
||||||
'EL' => 'Griechenland',
|
'GR' => 'Griechenland',
|
||||||
'ES' => 'Spanien',
|
'ES' => 'Spanien',
|
||||||
'FR' => 'Frankreich',
|
'FR' => 'Frankreich',
|
||||||
'HR' => 'Kroatien',
|
'HR' => 'Kroatien',
|
||||||
|
|
|
@ -187,8 +187,8 @@ sub mail_feedback2garage {
|
||||||
my $sendref = $self->sendrefhash();
|
my $sendref = $self->sendrefhash();
|
||||||
|
|
||||||
$sendref->{mail_to} = $crecord_content->{fleed_email};
|
$sendref->{mail_to} = $crecord_content->{fleed_email};
|
||||||
$sendref->{subject} = "sharee.bike Werkstatt Meldung";
|
$sendref->{subject} = "sharee.bike App Meldung";
|
||||||
$sendref->{message} = "Es ist folgende sharee.bike App-Meldung zu Mietrad $contentpos->{ct_name} an Station $contentpos->{int04} eingegangen:\n\n$contentpos->{txt01}\n\nFreundliche Grüße,\nIhr sharee.bike Mietradsystem";
|
$sendref->{message} = "Es ist folgende sharee.bike App Nachricht zu Mietrad $contentpos->{ct_name} an Station $contentpos->{int04} eingegangen:\n\n$contentpos->{txt01}\n\nFreundliche Grüße,\nIhr sharee.bike Mietradsystem";
|
||||||
$sendref->{message} =~ s/\n/\<br \/\>/g;#TOD prepare_content
|
$sendref->{message} =~ s/\n/\<br \/\>/g;#TOD prepare_content
|
||||||
|
|
||||||
my ($smtp,$mailxconf) = $self->mail_connect($sendref);
|
my ($smtp,$mailxconf) = $self->mail_connect($sendref);
|
||||||
|
|
|
@ -52,7 +52,7 @@ sub mobox3(){
|
||||||
|
|
||||||
if($R::node2edit eq "edit_relation" || $R::rel_edit =~ /_relation/){
|
if($R::node2edit eq "edit_relation" || $R::rel_edit =~ /_relation/){
|
||||||
$title = "Node Editor";
|
$title = "Node Editor";
|
||||||
$height = "400";
|
$height = "500";
|
||||||
$width = "600";
|
$width = "600";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,11 @@ sub admin_tpl(){
|
||||||
}elsif($key =~ /fleed_/){
|
}elsif($key =~ /fleed_/){
|
||||||
print $q->Tr();
|
print $q->Tr();
|
||||||
print $q->td({-class=>'left_italic_cms'},"$des"),"\n";
|
print $q->td({-class=>'left_italic_cms'},"$des"),"\n";
|
||||||
print $q->td({-class=>'content1_cms'},$q->textfield(-class=>'etxt',-name=>"$key",-default=>"$node_meta->{$key}",-override=>'1',-size=>"$isize",-maxlength=>120)),"\n";
|
if($isize eq "area"){
|
||||||
|
print $q->td({-class=>'content1_cms', -colspan=>'3'},$q->textarea(-class=>"etxt", -style=>'border: 1px solid silver;', -name=>"$key", -override=>'1',-default=>"$node_meta->{$key}",-rows=>"2",-cols=>25)),"\n";
|
||||||
|
}else{
|
||||||
|
print $q->td({-class=>'content1_cms'},$q->textfield(-class=>'etxt',-name=>"$key",-default=>"$node_meta->{$key}",-override=>'1',-size=>"$isize",-maxlength=>120)),"\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1176,6 +1176,152 @@ sub payone_capture {
|
||||||
return ($retval,$return_text);
|
return ($retval,$return_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#payment-type prepaid request
|
||||||
|
sub prepaid_request {
|
||||||
|
my $self = shift;
|
||||||
|
my $dbh = shift;
|
||||||
|
my $ctadr = shift || {};
|
||||||
|
my $owner = shift;
|
||||||
|
|
||||||
|
my $feedb = {
|
||||||
|
u_rows => 0,
|
||||||
|
prepaid_account => "",
|
||||||
|
prepaid_id => 0,
|
||||||
|
message => "",
|
||||||
|
};
|
||||||
|
|
||||||
|
if($ctadr->{c_id}){
|
||||||
|
my $pref_ctt = {
|
||||||
|
table => "contenttrans",
|
||||||
|
fetch => "one",
|
||||||
|
main_id => 300023,
|
||||||
|
template_id => 219,#prepaid tpl
|
||||||
|
int10 => "$ctadr->{c_id}",
|
||||||
|
state => "is::null",
|
||||||
|
close_time => "is::null",
|
||||||
|
};
|
||||||
|
my $ctt_prepaid = { c_id => 0 };
|
||||||
|
$ctt_prepaid = $dbt->fetch_record($dbh,$pref_ctt);
|
||||||
|
if(!$ctt_prepaid->{c_id}){
|
||||||
|
my $ct_id = $dbt->insert_contenttrans($dbh,$ctadr,"300023","219","----","$owner");
|
||||||
|
$pref_ctt->{c_id} = $ct_id;
|
||||||
|
$ctt_prepaid = $dbt->fetch_record($dbh,$pref_ctt) if($pref_ctt->{c_id});
|
||||||
|
my $update_adr = {
|
||||||
|
table => "contentadr",
|
||||||
|
mtime => "now()",
|
||||||
|
owner => $owner,
|
||||||
|
int18 => 3,#pay_ack
|
||||||
|
ct_name => "Prepaid-$ctt_prepaid->{c_id}",
|
||||||
|
};
|
||||||
|
$feedb->{u_rows} = $dbt->update_record($dbh,$update_adr,$ctadr);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $pos_id = 0;
|
||||||
|
my $cttpos = { c_id => 0 };
|
||||||
|
if($ctt_prepaid->{c_id} > 0){
|
||||||
|
|
||||||
|
my $posref = {
|
||||||
|
table => "contenttrans",
|
||||||
|
table_pos => "contenttranspos",
|
||||||
|
fetch => "one",
|
||||||
|
keyfield => "c_id",
|
||||||
|
ca_id => "$ctadr->{c_id}",
|
||||||
|
int02 => "is::null",#0
|
||||||
|
};
|
||||||
|
$cttpos = $dbt->collect_post($dbh,$posref);
|
||||||
|
|
||||||
|
if(!$cttpos->{c_id}){
|
||||||
|
#pseudo part. not available in content
|
||||||
|
my $ct = {
|
||||||
|
c_id => 0,
|
||||||
|
barcode => 0,
|
||||||
|
ca_id => $ctadr->{c_id},
|
||||||
|
ct_id => $ctt_prepaid->{c_id},
|
||||||
|
int02 => 0,#prepaid price on request is 0
|
||||||
|
txt01 => 'Prepaid Position',
|
||||||
|
int16 => 4,#fibumark for prepaid
|
||||||
|
template_id => 219,
|
||||||
|
};
|
||||||
|
|
||||||
|
$cttpos->{c_id} = $dbt->insert_pos($dbh,$ctt_prepaid->{c_id},$ct,"",$ctadr,"","","","0",$owner,"");
|
||||||
|
$dbt->update_one($dbh,{table => 'contenttranspos',c_id => $cttpos->{c_id}},"barcode = $cttpos->{c_id},ct_name = '$ctt_prepaid->{c_id}-$cttpos->{c_id}'");
|
||||||
|
$feedb->{prepaid_id} = $ctt_prepaid->{c_id} . "-" . $cttpos->{c_id};
|
||||||
|
}
|
||||||
|
|
||||||
|
$feedb->{prepaid_account} = $ctt_prepaid->{c_id};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $feedb;
|
||||||
|
}#end prepaid_request
|
||||||
|
|
||||||
|
|
||||||
|
#primary collect prepaid
|
||||||
|
sub collect_prepaid {
|
||||||
|
my $self = shift;
|
||||||
|
my $dbh = shift;
|
||||||
|
my $ctadr = shift || {};
|
||||||
|
|
||||||
|
my $prepaidhash = {
|
||||||
|
prepaid_total => 0,
|
||||||
|
prepaid_id => 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
if($ctadr->{c_id}){
|
||||||
|
#all un-booked or opos
|
||||||
|
my $posref = {
|
||||||
|
table => "contenttrans",
|
||||||
|
table_pos => "contenttranspos",
|
||||||
|
fetch => "all",
|
||||||
|
keyfield => "c_id",
|
||||||
|
ca_id => "$ctadr->{c_id}",
|
||||||
|
'ct.state' => "is::null",#selects int04 is null OR int14 >= 1
|
||||||
|
'ct.close_time' => "is::null",
|
||||||
|
};
|
||||||
|
my $cttpos = { c_id => 0 };
|
||||||
|
$cttpos = $dbt->collect_post($dbh,$posref);
|
||||||
|
foreach my $id (sort { $cttpos->{$b}->{c_id} <=> $cttpos->{$a}->{c_id} } keys(%$cttpos)){
|
||||||
|
#print $cttpos->{$id}->{barcode} . ":" . $cttpos->{$id}->{int02},"<br>";
|
||||||
|
|
||||||
|
if($cttpos->{$id}->{barcode} && $cttpos->{$id}->{int02} == 0){
|
||||||
|
$prepaidhash->{invoice_id} = $cttpos->{$id}->{ct_id};
|
||||||
|
$prepaidhash->{number} = $cttpos->{$id}->{c_id};
|
||||||
|
$prepaidhash->{prepaid_id} = $cttpos->{$id}->{ct_id} . "-" . $cttpos->{$id}->{c_id};#payone reference
|
||||||
|
$prepaidhash->{description} = $cttpos->{$id}->{txt01};
|
||||||
|
$prepaidhash->{response_log} = $cttpos->{$id}->{txt25};
|
||||||
|
$prepaidhash->{payone_link} = $cttpos->{$id}->{txt30};
|
||||||
|
if($cttpos->{$id}->{txt25} =~ /(\d{2}\.\d{2}\.\d{4}\s\d{2}:\d{2}).*mailing/){
|
||||||
|
$prepaidhash->{mail_datetime} = $1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($cttpos->{$id}->{int02} && $cttpos->{$id}->{int02} != 0){
|
||||||
|
$prepaidhash->{prepaid_total} += $cttpos->{$id}->{int02};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($prepaidhash->{invoice_id} && $ctadr->{int03} && $ctadr->{int03} == 3 && (!$ctadr->{int12} || $ctadr->{int12} != 2)){
|
||||||
|
my $update_adr = {
|
||||||
|
table => "contentadr",
|
||||||
|
ct_name => "Prepaid-$prepaidhash->{invoice_id}",
|
||||||
|
pay_time => "now()",#just to see who changes at what time
|
||||||
|
};
|
||||||
|
|
||||||
|
#for int12 vde update we need also open operator invoices to get saldo balance
|
||||||
|
#int12 => "1",
|
||||||
|
|
||||||
|
#if($prepaidhash->{prepaid_total} > 0){
|
||||||
|
#$update_adr->{int12} = "null";
|
||||||
|
#}else{
|
||||||
|
# $update_adr->{int12} = "1";
|
||||||
|
#}
|
||||||
|
$dbt->update_record($dbh,$update_adr,$ctadr);
|
||||||
|
$dbt->update_operatorsloop("",$ctadr->{c_id},"update");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$bw->log("Pricing prepaidhash:",$prepaidhash,"");
|
||||||
|
return $prepaidhash;
|
||||||
|
}#end collect prepaid
|
||||||
|
|
||||||
#request "payone-link"
|
#request "payone-link"
|
||||||
sub generate_payonelink {
|
sub generate_payonelink {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
@ -1193,6 +1339,7 @@ sub generate_payonelink {
|
||||||
my $dbh = "";
|
my $dbh = "";
|
||||||
|
|
||||||
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
|
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
|
||||||
|
my $view_dt = strftime "%d.%m.%Y %H:%M:%S", localtime;
|
||||||
open(FILE,">>$varenv->{logdir}/payonelink.log");
|
open(FILE,">>$varenv->{logdir}/payonelink.log");
|
||||||
print FILE "\n*** $now_dt 'generate_payonelink' ctadr:$ctadr->{c_id}|$ctadr->{txt08}\n";
|
print FILE "\n*** $now_dt 'generate_payonelink' ctadr:$ctadr->{c_id}|$ctadr->{txt08}\n";
|
||||||
|
|
||||||
|
@ -1227,7 +1374,7 @@ sub generate_payonelink {
|
||||||
mode => "$dbt->{payonelink_conf}->{mode}",
|
mode => "$dbt->{payonelink_conf}->{mode}",
|
||||||
notifyUrl => "$dbt->{payonelink_conf}->{notifyUrl}",
|
notifyUrl => "$dbt->{payonelink_conf}->{notifyUrl}",
|
||||||
description => "Ihr vorbereiteter sharee.bike Prepaid/Vorkasse Auftrag",
|
description => "Ihr vorbereiteter sharee.bike Prepaid/Vorkasse Auftrag",
|
||||||
paymentMethods => ['visa', 'mastercard', 'giropay'],
|
paymentMethods => ['visa', 'mastercard'],
|
||||||
reference => "$reference",
|
reference => "$reference",
|
||||||
shoppingCart => [{
|
shoppingCart => [{
|
||||||
type => "goods",
|
type => "goods",
|
||||||
|
@ -1267,6 +1414,7 @@ sub generate_payonelink {
|
||||||
mtime => "now()",
|
mtime => "now()",
|
||||||
owner => "$aowner",
|
owner => "$aowner",
|
||||||
};
|
};
|
||||||
|
$update_pos->{txt01} = "$prepaidhash->{description}. Payone-Link generiert $view_dt";
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
$response_in = decode_json($ret_json);
|
$response_in = decode_json($ret_json);
|
||||||
|
@ -1286,9 +1434,8 @@ sub generate_payonelink {
|
||||||
my $rows = $dbt->update_record($dbh,$update_pos,$ctpos) if($ctpos->{c_id});
|
my $rows = $dbt->update_record($dbh,$update_pos,$ctpos) if($ctpos->{c_id});
|
||||||
|
|
||||||
my $cms_message_key = "email-payonelink";
|
my $cms_message_key = "email-payonelink";
|
||||||
if(!$varenv->{cms}->{$cms_message_key}->{txt}){
|
if($ctpos->{c_id}){
|
||||||
$feedb->{message} = "failure::Achtung, '$cms_message_key' ist nicht vorhanden. Es wurde keine eMail versandt!";
|
print FILE "$dbt->{copri_conf}->{basedir}/$varenv->{syshost}/src/scripts/mailTransportcms.pl '$varenv->{syshost}' 'send_payonelink' '$ctadr->{c_id}' '$ctpos->{c_id}' '' '$cms_message_key' '' '$app_name'";
|
||||||
}elsif($ctpos->{c_id}){
|
|
||||||
system("$dbt->{copri_conf}->{basedir}/$varenv->{syshost}/src/scripts/mailTransportcms.pl '$varenv->{syshost}' 'send_payonelink' '$ctadr->{c_id}' '$ctpos->{c_id}' '' '$cms_message_key' '' '$app_name'");
|
system("$dbt->{copri_conf}->{basedir}/$varenv->{syshost}/src/scripts/mailTransportcms.pl '$varenv->{syshost}' 'send_payonelink' '$ctadr->{c_id}' '$ctpos->{c_id}' '' '$cms_message_key' '' '$app_name'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1342,4 +1489,3 @@ sub rpcpayone_postjson {
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,84 +48,6 @@ my %varenv = $cf->envonline();
|
||||||
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
|
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
|
||||||
my $debug=1;
|
my $debug=1;
|
||||||
|
|
||||||
#payment-type prepaid request
|
|
||||||
sub prepaid_request {
|
|
||||||
my $self = shift;
|
|
||||||
my $dbh = shift;
|
|
||||||
my $ctadr = shift || {};
|
|
||||||
my $owner = shift;
|
|
||||||
|
|
||||||
my $feedb = {
|
|
||||||
u_rows => 0,
|
|
||||||
prepaid_account => "",
|
|
||||||
prepaid_id => 0,
|
|
||||||
message => "",
|
|
||||||
};
|
|
||||||
|
|
||||||
if($ctadr->{c_id}){
|
|
||||||
my $pref_ctt = {
|
|
||||||
table => "contenttrans",
|
|
||||||
fetch => "one",
|
|
||||||
main_id => 300023,
|
|
||||||
template_id => 219,#prepaid tpl
|
|
||||||
int10 => "$ctadr->{c_id}",
|
|
||||||
state => "is::null",
|
|
||||||
close_time => "is::null",
|
|
||||||
};
|
|
||||||
my $ctt_prepaid = { c_id => 0 };
|
|
||||||
$ctt_prepaid = $dbt->fetch_record($dbh,$pref_ctt);
|
|
||||||
if(!$ctt_prepaid->{c_id}){
|
|
||||||
my $ct_id = $dbt->insert_contenttrans($dbh,$ctadr,"300023","219","----","$owner");
|
|
||||||
$pref_ctt->{c_id} = $ct_id;
|
|
||||||
$ctt_prepaid = $dbt->fetch_record($dbh,$pref_ctt) if($pref_ctt->{c_id});
|
|
||||||
my $update_adr = {
|
|
||||||
table => "contentadr",
|
|
||||||
mtime => "now()",
|
|
||||||
owner => $owner,
|
|
||||||
int18 => 3,#pay_ack
|
|
||||||
ct_name => "Prepaid-$ctt_prepaid->{c_id}",
|
|
||||||
};
|
|
||||||
$feedb->{u_rows} = $dbt->update_record($dbh,$update_adr,$ctadr);
|
|
||||||
}
|
|
||||||
|
|
||||||
my $pos_id = 0;
|
|
||||||
my $cttpos = { c_id => 0 };
|
|
||||||
if($ctt_prepaid->{c_id} > 0){
|
|
||||||
|
|
||||||
my $posref = {
|
|
||||||
table => "contenttrans",
|
|
||||||
table_pos => "contenttranspos",
|
|
||||||
fetch => "one",
|
|
||||||
keyfield => "c_id",
|
|
||||||
ca_id => "$ctadr->{c_id}",
|
|
||||||
int02 => "is::null",#0
|
|
||||||
};
|
|
||||||
$cttpos = $dbt->collect_post($dbh,$posref);
|
|
||||||
|
|
||||||
if(!$cttpos->{c_id}){
|
|
||||||
#pseudo part. not available in content
|
|
||||||
my $ct = {
|
|
||||||
c_id => 0,
|
|
||||||
barcode => 0,
|
|
||||||
ca_id => $ctadr->{c_id},
|
|
||||||
ct_id => $ctt_prepaid->{c_id},
|
|
||||||
int02 => 0,#prepaid price on request is 0
|
|
||||||
txt01 => 'Prepaid Position',
|
|
||||||
int16 => 4,#fibumark for prepaid
|
|
||||||
template_id => 219,
|
|
||||||
};
|
|
||||||
|
|
||||||
$cttpos->{c_id} = $dbt->insert_pos($dbh,$ctt_prepaid->{c_id},$ct,"",$ctadr,"","","","0",$owner,"");
|
|
||||||
$dbt->update_one($dbh,{table => 'contenttranspos',c_id => $cttpos->{c_id}},"barcode = $cttpos->{c_id},ct_name = '$ctt_prepaid->{c_id}-$cttpos->{c_id}'");
|
|
||||||
$feedb->{prepaid_id} = $ctt_prepaid->{c_id} . "-" . $cttpos->{c_id};
|
|
||||||
}
|
|
||||||
|
|
||||||
$feedb->{prepaid_account} = $ctt_prepaid->{c_id};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $feedb;
|
|
||||||
}#end prepaid_request
|
|
||||||
|
|
||||||
#select rentals for messaging user if bike > 12h ... occupied
|
#select rentals for messaging user if bike > 12h ... occupied
|
||||||
sub longterm_occupied {
|
sub longterm_occupied {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
|
@ -634,74 +634,6 @@ sub operator_accounting2calc {
|
||||||
return $oac;
|
return $oac;
|
||||||
}
|
}
|
||||||
|
|
||||||
#primary collect prepaid
|
|
||||||
sub collect_prepaid {
|
|
||||||
my $self = shift;
|
|
||||||
my $dbh = shift;
|
|
||||||
my $ctadr = shift || {};
|
|
||||||
|
|
||||||
my $prepaidhash = {
|
|
||||||
prepaid_total => 0,
|
|
||||||
prepaid_id => 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
if($ctadr->{c_id}){
|
|
||||||
#all un-booked or opos
|
|
||||||
my $posref = {
|
|
||||||
table => "contenttrans",
|
|
||||||
table_pos => "contenttranspos",
|
|
||||||
fetch => "all",
|
|
||||||
keyfield => "c_id",
|
|
||||||
ca_id => "$ctadr->{c_id}",
|
|
||||||
'ct.state' => "is::null",#selects int04 is null OR int14 >= 1
|
|
||||||
'ct.close_time' => "is::null",
|
|
||||||
};
|
|
||||||
my $cttpos = { c_id => 0 };
|
|
||||||
$cttpos = $dbt->collect_post($dbh,$posref);
|
|
||||||
foreach my $id (sort { $cttpos->{$b}->{c_id} <=> $cttpos->{$a}->{c_id} } keys(%$cttpos)){
|
|
||||||
#print $cttpos->{$id}->{barcode} . ":" . $cttpos->{$id}->{int02},"<br>";
|
|
||||||
|
|
||||||
if($cttpos->{$id}->{barcode} && $cttpos->{$id}->{int02} == 0){
|
|
||||||
$prepaidhash->{invoice_id} = $cttpos->{$id}->{ct_id};
|
|
||||||
$prepaidhash->{number} = $cttpos->{$id}->{c_id};
|
|
||||||
$prepaidhash->{prepaid_id} = $cttpos->{$id}->{ct_id} . "-" . $cttpos->{$id}->{c_id};#payone reference
|
|
||||||
$prepaidhash->{description} = $cttpos->{$id}->{txt01};
|
|
||||||
$prepaidhash->{response_log} = $cttpos->{$id}->{txt25};
|
|
||||||
$prepaidhash->{payone_link} = $cttpos->{$id}->{txt30};
|
|
||||||
if($cttpos->{$id}->{txt25} =~ /(\d{2}\.\d{2}\.\d{4}\s\d{2}:\d{2}).*mailing/){
|
|
||||||
$prepaidhash->{mail_datetime} = $1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if($cttpos->{$id}->{int02} && $cttpos->{$id}->{int02} != 0){
|
|
||||||
$prepaidhash->{prepaid_total} += $cttpos->{$id}->{int02};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($prepaidhash->{invoice_id} && $ctadr->{int03} && $ctadr->{int03} == 3 && (!$ctadr->{int12} || $ctadr->{int12} != 2)){
|
|
||||||
my $update_adr = {
|
|
||||||
table => "contentadr",
|
|
||||||
ct_name => "Prepaid-$prepaidhash->{invoice_id}",
|
|
||||||
pay_time => "now()",#just to see who changes at what time
|
|
||||||
};
|
|
||||||
|
|
||||||
#for int12 vde update we need also open operator invoices to get saldo balance
|
|
||||||
#int12 => "1",
|
|
||||||
|
|
||||||
#if($prepaidhash->{prepaid_total} > 0){
|
|
||||||
#$update_adr->{int12} = "null";
|
|
||||||
#}else{
|
|
||||||
# $update_adr->{int12} = "1";
|
|
||||||
#}
|
|
||||||
$dbt->update_record($dbh,$update_adr,$ctadr);
|
|
||||||
$dbt->update_operatorsloop("",$ctadr->{c_id},"update");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$bw->log("Pricing prepaidhash:",$prepaidhash,"");
|
|
||||||
return $prepaidhash;
|
|
||||||
}#end collect prepaid
|
|
||||||
|
|
||||||
|
|
||||||
#sum of primary prepaid
|
#sum of primary prepaid
|
||||||
sub primary_sum_prepaid {
|
sub primary_sum_prepaid {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
49
copri4/main/src/scripts/payonelink.pl
Executable file
49
copri4/main/src/scripts/payonelink.pl
Executable file
|
@ -0,0 +1,49 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
||||||
|
#
|
||||||
|
##forking payone request to generate an mail payone-link
|
||||||
|
|
||||||
|
use vars qw($syshost);
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
$syshost = $ARGV[0] || exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
use lib "/var/www/copri-bike/$syshost/src";
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use POSIX;
|
||||||
|
use Scalar::Util qw(looks_like_number);
|
||||||
|
use Lib::Config;
|
||||||
|
use Mod::DBtank;
|
||||||
|
use Mod::Payment;
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
|
my $cf = new Config;
|
||||||
|
my %varenv = $cf->envonline();
|
||||||
|
my $dbt = new DBtank;
|
||||||
|
my $pay = new Payment;
|
||||||
|
my $now_dt = strftime("%Y-%m-%d %H:%M:%S",localtime(time));
|
||||||
|
|
||||||
|
my $adrc_id = $ARGV[1] || "";
|
||||||
|
my $prepaid_amount = $ARGV[2] || "";
|
||||||
|
my $aowner = $ARGV[3] || "196";
|
||||||
|
my $dbh = "";
|
||||||
|
|
||||||
|
my $dbh = $dbt->dbconnect();
|
||||||
|
my $authref = {
|
||||||
|
table => "contentadr",
|
||||||
|
fetch => "one",
|
||||||
|
template_id => "202",
|
||||||
|
c_id => "$adrc_id",
|
||||||
|
};
|
||||||
|
my $users_sharee = { c_id => 0 };
|
||||||
|
$users_sharee = $dbt->fetch_record($dbh,$authref) if($adrc_id);
|
||||||
|
|
||||||
|
my $prepaidhash = {};
|
||||||
|
$prepaidhash = $pay->collect_prepaid($dbh,$users_sharee);
|
||||||
|
my $ret_json = $pay->generate_payonelink(\%varenv,$users_sharee,$prepaidhash,$prepaid_amount,$aowner);
|
||||||
|
|
|
@ -10,8 +10,6 @@ use CGI ':standard';
|
||||||
use Mod::Buttons;
|
use Mod::Buttons;
|
||||||
use Mod::Basework;
|
use Mod::Basework;
|
||||||
use Mod::DBtank;
|
use Mod::DBtank;
|
||||||
use Mod::Prelib;
|
|
||||||
use Mod::Pricing;
|
|
||||||
use Mod::Payment;
|
use Mod::Payment;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
|
@ -36,8 +34,6 @@ sub tpl(){
|
||||||
my $bw = new Basework;
|
my $bw = new Basework;
|
||||||
my $dbt = new DBtank;
|
my $dbt = new DBtank;
|
||||||
my $but = new Buttons;
|
my $but = new Buttons;
|
||||||
my $pl = new Prelib;
|
|
||||||
my $pri = new Pricing;
|
|
||||||
my $pay = new Payment;
|
my $pay = new Payment;
|
||||||
|
|
||||||
$q->import_names('R');
|
$q->import_names('R');
|
||||||
|
@ -56,26 +52,20 @@ sub tpl(){
|
||||||
my $payable_check=0;
|
my $payable_check=0;
|
||||||
$payable_check = $bw->isuser_rentable($ctadr,$varenv);
|
$payable_check = $bw->isuser_rentable($ctadr,$varenv);
|
||||||
my $prepaidhash = {};
|
my $prepaidhash = {};
|
||||||
$prepaidhash = $pri->collect_prepaid($dbh,$ctadr) if($ctadr->{c_id});
|
$prepaidhash = $pay->collect_prepaid($dbh,$ctadr) if($ctadr->{c_id});
|
||||||
if(!$prepaidhash->{prepaid_id} && $ctadr->{c_id}){
|
if(!$prepaidhash->{prepaid_id} && $ctadr->{c_id}){
|
||||||
$feedb = $pl->prepaid_request($dbh,$ctadr,$aowner);
|
$feedb = $pay->prepaid_request($dbh,$ctadr,$aowner);
|
||||||
$prepaidhash = $pri->collect_prepaid($dbh,$ctadr);
|
$prepaidhash = $pay->collect_prepaid($dbh,$ctadr);
|
||||||
}
|
}
|
||||||
|
|
||||||
my $ret_json = "";
|
|
||||||
|
|
||||||
print $q->start_form(),"\n";
|
print $q->start_form(),"\n";
|
||||||
print $q->hidden(-name=>"sessionid",-override=>1,-value=>"$R::sessionid");
|
print $q->hidden(-name=>"sessionid",-override=>1,-value=>"$R::sessionid");
|
||||||
|
|
||||||
print "<div class='form-group' style='clear:both;'>\n";
|
print "<div class='form-group' style='clear:both;'>\n";
|
||||||
print $q->div({-class=>'content_title3'},"$varenv->{cms}->{'iframe-prepaid-account'}->{txt}"),"\n";
|
print $q->div({-class=>'content_title3'},"$varenv->{cms}->{'iframe-prepaid-account'}->{txt}"),"\n";
|
||||||
|
#print Dumper($prepaidhash);
|
||||||
if($prepaidhash->{prepaid_id}){
|
|
||||||
#print $q->hidden(-name=>"prepaid_id",-override=>1,-value=>"$prepaidhash->{prepaid_id}");
|
if($prepaidhash->{prepaid_id} || ($R::sharee_edit eq "generate_payonelink" && $R::prepaid_amount =~ /\d+/)){
|
||||||
if($ctadr->{c_id} && $R::sharee_edit && $R::sharee_edit =~ /generate_payonelink/){
|
|
||||||
$ret_json = $pay->generate_payonelink($varenv,$ctadr,$prepaidhash,$R::prepaid_amount,$aowner);
|
|
||||||
$prepaidhash = $pri->collect_prepaid($dbh,$ctadr);
|
|
||||||
}
|
|
||||||
$prepaidhash->{prepaid_total} = sprintf('%.2f',$prepaidhash->{prepaid_total});
|
$prepaidhash->{prepaid_total} = sprintf('%.2f',$prepaidhash->{prepaid_total});
|
||||||
$prepaidhash->{prepaid_total} =~ s/\./,/;
|
$prepaidhash->{prepaid_total} =~ s/\./,/;
|
||||||
$varenv->{cms}->{'iframe-prepaid-prolog'}->{txt} =~ s/\n/<br \/>/g;
|
$varenv->{cms}->{'iframe-prepaid-prolog'}->{txt} =~ s/\n/<br \/>/g;
|
||||||
|
@ -88,11 +78,9 @@ sub tpl(){
|
||||||
print $q->div({-class=>'content2'}, "$varenv->{cms}->{'iframe-failure-contact-hotline'}->{txt} $prepaidhash->{prepaid_id}"),"\n";
|
print $q->div({-class=>'content2'}, "$varenv->{cms}->{'iframe-failure-contact-hotline'}->{txt} $prepaidhash->{prepaid_id}"),"\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$ret_json || $ret_json =~ /failure/){
|
|
||||||
my $required="required";
|
my $required="required";
|
||||||
print $q->div({-class=>'content2', -style=>'color:#c83434;'}, "$varenv->{cms}->{'iframe-prepaid-failure'}->{txt}"),"\n" if($ret_json =~ /failure/);
|
if($prepaidhash->{payone_link} || ($R::sharee_edit eq "generate_payonelink" && $R::prepaid_amount =~ /\d+/)){
|
||||||
|
|
||||||
if($prepaidhash->{payone_link}){
|
|
||||||
$varenv->{cms}->{'iframe-prepaid-emailinfo'}->{txt} =~ s/\n/<br \/>/g;
|
$varenv->{cms}->{'iframe-prepaid-emailinfo'}->{txt} =~ s/\n/<br \/>/g;
|
||||||
$varenv->{cms}->{'iframe-prepaid-emailinfo'}->{txt} =~ s/::mail_datetime::/$prepaidhash->{mail_datetime}/g;
|
$varenv->{cms}->{'iframe-prepaid-emailinfo'}->{txt} =~ s/::mail_datetime::/$prepaidhash->{mail_datetime}/g;
|
||||||
$varenv->{cms}->{'iframe-prepaid-emailinfo'}->{txt} =~ s/::email::/$ctadr->{txt08}/g;
|
$varenv->{cms}->{'iframe-prepaid-emailinfo'}->{txt} =~ s/::email::/$ctadr->{txt08}/g;
|
||||||
|
@ -109,18 +97,7 @@ sub tpl(){
|
||||||
print $q->div({-style=>'margin-top:1em;text-align:center;'},"<button type='submit' name='sharee_edit' value='generate_payonelink' class='btn btn-primary btn-lg btn-block' style='border:1px solid #$bgcolor1;background-color:#$bgcolor1;'>$varenv->{cms}->{'iframe-next-prepaid'}->{txt}</button>"),"\n";
|
print $q->div({-style=>'margin-top:1em;text-align:center;'},"<button type='submit' name='sharee_edit' value='generate_payonelink' class='btn btn-primary btn-lg btn-block' style='border:1px solid #$bgcolor1;background-color:#$bgcolor1;'>$varenv->{cms}->{'iframe-next-prepaid'}->{txt}</button>"),"\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
}elsif($ret_json){
|
print $q->div({-class=>'content2', -style=>'padding-top:50px;font-size:0.91em;'}, "$varenv->{cms}->{'iframe-prepaid-footer'}->{txt}"),"\n";
|
||||||
#payone-link mailing will be done by $pay->generate_payonelink
|
|
||||||
$varenv->{cms}->{'iframe-prepaid-emailinfo'}->{txt} =~ s/\n/<br \/>/g;
|
|
||||||
$varenv->{cms}->{'iframe-prepaid-emailinfo'}->{txt} =~ s/::mail_datetime::/$prepaidhash->{mail_datetime}/g;
|
|
||||||
$varenv->{cms}->{'iframe-prepaid-emailinfo'}->{txt} =~ s/::email::/$ctadr->{txt08}/g;
|
|
||||||
$varenv->{cms}->{'iframe-prepaid-emailinfo'}->{txt} =~ s/::payone_link::/<b><a href='$prepaidhash->{payone_link}' target='_blank'>Test $prepaidhash->{payone_link}<\/a><\/b>/g if($ctadr->{c_id} eq $dbt->{copri_conf}->{superu_id});
|
|
||||||
$varenv->{cms}->{'iframe-prepaid-emailinfo'}->{txt} =~ s/::app_name::/<b>$dbt->{merchant_ids}->{$varenv->{merchant_id}}->{app_name}<\/b>/g;
|
|
||||||
print $q->div({-class=>'content2', -style=>'color:#009899;'}, "$varenv->{cms}->{'iframe-prepaid-emailinfo'}->{txt}"),"\n";
|
|
||||||
print $q->div({-style=>'margin-top:1em;text-align:center;'},"<button type='submit' name='sharee_edit' value='save_account' class='btn btn-primary btn-lg btn-block' style='border:1px solid #$bgcolor1;background-color:#$bgcolor1;'>$varenv->{cms}->{'iframe-next'}->{txt}</button>"),"\n";
|
|
||||||
|
|
||||||
}
|
|
||||||
print $q->div({-class=>'content2', -style=>'padding-top:50px;font-size:0.81em;'}, "$varenv->{cms}->{'iframe-prepaid-footer'}->{txt}"),"\n";
|
|
||||||
|
|
||||||
print "</div>\n";
|
print "</div>\n";
|
||||||
print $q->end_form,"\n";
|
print $q->end_form,"\n";
|
||||||
|
|
|
@ -12,6 +12,7 @@ use Mod::Libenz;
|
||||||
use Mod::DBtank;
|
use Mod::DBtank;
|
||||||
use Mod::APIfunc;
|
use Mod::APIfunc;
|
||||||
use Mod::Pricing;
|
use Mod::Pricing;
|
||||||
|
use Mod::Payment;
|
||||||
use Tpl::AccountSubmenu;
|
use Tpl::AccountSubmenu;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
|
@ -35,6 +36,7 @@ sub tpl {
|
||||||
my $dbt = new DBtank;
|
my $dbt = new DBtank;
|
||||||
my $apif = new APIfunc;
|
my $apif = new APIfunc;
|
||||||
my $pri = new Pricing;
|
my $pri = new Pricing;
|
||||||
|
my $pay = new Payment;
|
||||||
my $submenu = new AccountSubmenu;
|
my $submenu = new AccountSubmenu;
|
||||||
my $path = $q->path_info();
|
my $path = $q->path_info();
|
||||||
my $dbh = "";
|
my $dbh = "";
|
||||||
|
@ -196,7 +198,7 @@ sub tpl {
|
||||||
}
|
}
|
||||||
if($ctadr->{int03} == 3){
|
if($ctadr->{int03} == 3){
|
||||||
my $prepaidhash = { prepaid_total => 0 };
|
my $prepaidhash = { prepaid_total => 0 };
|
||||||
$prepaidhash = $pri->collect_prepaid($dbh,$ctadr);
|
$prepaidhash = $pay->collect_prepaid($dbh,$ctadr);
|
||||||
$prepaidhash->{prepaid_total} = sprintf('%.2f',$prepaidhash->{prepaid_total});
|
$prepaidhash->{prepaid_total} = sprintf('%.2f',$prepaidhash->{prepaid_total});
|
||||||
$prepaidhash->{prepaid_total} =~ s/\./,/;
|
$prepaidhash->{prepaid_total} =~ s/\./,/;
|
||||||
$varenv->{cms}->{'iframe-prepaid-sum'}->{txt} =~ s/\n/<br \/>/g;
|
$varenv->{cms}->{'iframe-prepaid-sum'}->{txt} =~ s/\n/<br \/>/g;
|
||||||
|
|
Loading…
Add table
Reference in a new issue