R: [ic] Banca Sella interface tags

Valerio Santinelli valerio@got.it
Mon, 23 Oct 2000 09:03:47 +0200


Just before I read the message you sent me, I made an SQL-backed interface
for Banca Sella. If anybody is interested I could post my version on this
list.

Valerio Santinelli
Register.it Support Team

------------------------------------------------------------
 http://www.register.it/
 mailto:support@register.it

 Register.it by GOT.IT srl - Italy
------------------------------------------------------------



> -----Messaggio originale-----
> Da: interchange-users-admin@minivend.com
> [mailto:interchange-users-admin@minivend.com]Per conto di Massimiliano
> Ciancio
> Inviato: domenica 22 ottobre 2000 12.13
> A: interchange-users@minivend.com
> Oggetto: [ic] Banca Sella interface tags
>
>
> Hi all,
> I've developed an interface towards the italian online payment
> gateway Banca Sella for the http://www.ripani.com ecommerce (all
> comments and criticisms are well accepted!). Now I want to post my
> procedure to the mailing list in the hope that it may be useful to
> someone.
>
> Ok, now my solution.
> Banca Sella assignes two parameters to any account:
>       an account code (BS_COD_ES in my tags)
>       a terminal id (BS_TERM_ID).
> Moreover Banca Sella assignes two files of OTP (One Time Password):
> OTP.ric contains OTP that you must pass them when you require an online
> payment and that you must delete after passing them; OTP.ris instead
> contains password that you must verify and delete when you return from
> Banca Sella to your ecomm.
>
> The outline of the procedure is the following:
>
>                         returned params: a: transactionres (OK | KO)
>                                          b: BS id
>                                          c: OTP (verify and delete it)
>                                           |
>                                           v
>  ------------           -------------           ------------
> | your ecomm | ----->  | Banca Sella | ------> | your ecomm |
>  ------------     ^      -------------           ------------
>                   |
>
>  passed params: a: BS_COS_ES
>                 b: BS_TERM_ID * total_cost
>                 c: OTP (from OTP.ric file)
>                 d: BS id (your id identifing this transaction with BS)
>                   (it must not be the same with your order id)
>
> ---------------------------------
> In catalog.cfg you must insert the following tags:
>
> UserTag bs-prepare Routine <<EOR
> sub {
>
>     # account code
>     $Vend::Session->{bs_a} = $::Variable->{BS_COD_ES};
>
>     # price x terminal id
>     $Vend::Session->{bs_b} = $::Variable->{BS_TERM_ID} *
> $Tag->total_cost();
>
>     # select OTP.ric and deletes it (see man perlfaq5)
>     my ($otp,$addr);
>     open (FH, "+< $Vend::Cfg->{VendRoot}/$::Variable->{BS_OTP_RIC}") or
> die "Can't open file: $!";
>     flock(FH, 2) or die "Can't flock: $!";  # 2 = exclusive lock
>     while ( <FH> ) { $otp=$_; $addr = tell(FH) unless eof(FH); }
>     truncate(FH, $addr);
>     flock(FH, 8) or die "Can't unlock: $!";  # 8 = unlock
>     close(FH);
>     chomp $otp;
>     $Vend::Session->{bs_c} = $otp;
>
>     # banca sella order id
>     $File::CounterFile::DEFAULT_DIR = $Vend::Cfg->{VendRoot};
>     my $counter = new File::CounterFile $::Variable->{BS_COUNTER},
> "000000";
>     $Vend::Session->{bs_d} = $counter->inc;
>
>     # verifies if the number of OTP is less than the value of the
> BS_MIN_PWD variable
>     # and send an email if it is so
>     my $buffer;
>     my $lines = 0;
>     open(FH, "$Vend::Cfg->{VendRoot}/$::Variable->{BS_OTP_RIC}") or die
> "Can't open file: $!";
>     while (sysread FH, $buffer, 4096) {
>         $lines += ($buffer =~ tr/\n//);
>     }
>     close(FH);
>
>     if ($lines < $::Variable->{BS_MIN_PWD}) {
>         $Vend::Session->{bs_pwd_ending} = 1;
>     }
>     else {
>         $Vend::Session->{bs_pwd_ending} = 0;
>     }
>
>     return '';
> }
> EOR
>
> UserTag bs-confirm Order a b c
> UserTag bs-confirm addAttr
> UserTag bs-confirm Routine <<EOR
> sub {
>     # a=result, b=id_ord_bs, c=OTP.ris
>     my ($a,$b,$c) = @_;
>
>     $Vend::Session->{bs_a} = $a;
>     $Vend::Session->{bs_b} = $b;
>     $Vend::Session->{bs_c} = $c;
>     $Vend::Session->{bs_result} = 1;
>
>     # result verify
>     if ($a eq "KO") {
>         $Vend::Session->{bs_result} = 0;
>     }
>
>     # verify and delete OTP.ris
>     my $file="$Vend::Cfg->{VendRoot}/$::Variable->{BS_OTP_RIS}";
>     my $old = $file;
>     my $new = "$file.tmp.$$";
>
>     open(OLD, "< $old")         or die "can't open $old: $!";
>     open(NEW, "> $new")         or die "can't open $new: $!";
>
>     my $tmp;
>     my $found = 0;
>     while (<OLD>) {
>         $tmp = $_;
>         chomp($tmp);
>         if ($tmp eq $c) {
>             $found = 1;
>         }
>         else {
>             (print NEW $_)      or die "can't write to $new: $!";
>         }
>     }
>
>     close(OLD)                  or die "can't close $old: $!";
>     close(NEW)                  or die "can't close $new: $!";
>
>     rename($new, $old)          or die "can't rename $new to $old: $!";
>
>     if (!$found) {
>         $Vend::Session->{bs_result} = 0;
>     }
>
>     return '';
> }
> EOR
>
>
> -------------------------------------------
> moreover you must declare the following variables inside catalog.cfg
>
> # Banca sella
> #
> Variable    BS_COD_ES       11111111              (your ones!)
> Variable    BS_TERM_ID      11111111
> Variable    BS_OTP_RIC      etc/OTP.ric           (password files)
> Variable    BS_OTP_RIS      etc/OTP.ris
> Variable    BS_COUNTER      etc/bancasella.counter
> Variable    BS_MIN_PWD      500
> Variable    BS_MIN_PWD_MAIL the.email@at which.send.the.following.msg
> Variable    BS_MIN_PWD_TEXT The passwords are ending!
>
>
>