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