fix options in gateway adding
[freeside.git] / httemplate / edit / process / payment_gateway.html
1 <%
2
3 my $gatewaynum = $cgi->param('gatewaynum');
4
5 my $old = qsearchs('payment_gateway',{'gatewaynum'=>$gatewaynum}) if $gatewaynum;
6
7 my $new = new FS::payment_gateway ( {
8   map {
9     $_, scalar($cgi->param($_));
10   } fields('payment_gateway')
11 } );
12
13 my @options = split(/\r?\n/, $cgi->param('gateway_options') );
14 pop @options
15   if scalar(@options) % 2 && $options[-1] =~ /^\s*$/;
16 my %options = @options;
17
18 my $error;
19 if ( $gatewaynum ) {
20   $error=$new->replace($old);
21 } else {
22   $error=$new->insert(\%options);
23   $gatewaynum=$new->getfield('gatewaynum');
24 }
25
26 if ( $error ) {
27   $cgi->param('error', $error);
28   print $cgi->redirect(popurl(2). "payment_gateway.html?". $cgi->query_string );
29 } else { 
30   print $cgi->redirect(popurl(3). "browse/payment_gateway.html");
31 }
32
33 %>