fix some problems with ordering packages on alt. locations, #23189, #940
[freeside.git] / httemplate / edit / payment_gateway.html
1 <% include( 'elements/edit.html',
2             'table'          => 'payment_gateway',
3             'name_singular'  => 'Payment gateway',
4             'viewall_dir'    => 'browse',
5             'fields'         => $fields,
6             'field_callback' => $field_callback,
7             'labels'         => {
8                                   'gatewaynum'           => 'Gateway',
9                                   'gateway_namespace'    => 'Gateway type',
10                                   'gateway_module'       => 'Gateway',
11                                   'gateway_username'     => 'Username',
12                                   'gateway_password'     => 'Password',
13                                   'gateway_action'       => 'Action',
14                                   'gateway_options'      => 'Options (Name/Value pairs, <BR>one element per line)',
15                                   'gateway_callback_url' => 'Callback URL',
16                                   'gateway_cancel_url'   => 'Cancel URL',
17                                 },
18           )
19 %>
20
21
22 <SCRIPT TYPE="text/javascript">
23   var modulesForNamespace = <% $json->encode(\%modules) %>;
24   function changeNamespace() {
25     var ns = document.getElementById('gateway_namespace').value;
26     var select_module = document.getElementById('gateway_module');
27     select_module.options.length = 0;
28     for (var x in modulesForNamespace[ns]) {
29       var o = document.createElement('option');
30       o.value = o.text = modulesForNamespace[ns][x];
31       select_module.add(o, null);
32     }
33   }
34   window.onload = changeNamespace;
35 </SCRIPT>
36
37 <%init>
38
39 die "access denied"
40   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
41
42 my $json = JSON::XS->new;
43 $json->canonical(1);
44 my %modules = (
45   'Business::OnlinePayment' => [
46     '2CheckOut',
47     'AuthorizeNet',
48     'BankOfAmerica', #deprecated?
49     'Beanstream',
50     'Capstone',
51     'Cardstream',
52     'CashCow',
53     'CyberSource',
54     'eSec',
55     'eSelectPlus',
56     'ElavonVirtualMerchant',
57     'Exact',
58     'iAuthorizer',
59     'Ingotz',
60     'InternetSecure',
61     'IPaymentTPG',
62     'IPPay',
63     'Iridium',
64     'Jettis',
65     'Jety',
66     'LinkPoint',
67     'MerchantCommerce',
68     'Network1Financial',
69     'OCV',
70     'OpenECHO',
71     'PayConnect',
72     'PayflowPro',
73     'PaymenTech',
74     'PaymentsGateway',
75     'PayPal',
76     #'PaySystems',
77     'PlugnPay',
78     'PPIPayMover',
79     'Protx', #now SagePay
80     'PXPost',
81     'SagePay',
82     'SecureHostingUPG',
83     'Skipjack',
84     'StGeorge',
85     'SurePay',
86     'TCLink',
87     'TransactionCentral',
88     'TransFirsteLink',
89     'Vanco',
90     'viaKLIX',
91     'VirtualNet',
92     'WesternACH',
93     'WorldPay',
94   ],
95   'Business::OnlineThirdPartyPayment' => [
96     'eWayShared',
97     'Interswitchng',
98     'PayPal',
99   ],
100   'Business::BatchPayment' => [
101     'KeyBank',
102     'Paymentech',
103     'TD_EFT',
104   ],
105 );
106
107 my @actions = (
108                 'Normal Authorization',
109                 'Authorization Only',
110                 'Authorization Only,Post Authorization',
111               );
112
113 my $fields = [
114                {
115                  field               => 'gateway_namespace',
116                  type                => 'select',
117                  options             => [ qw(
118                    Business::OnlinePayment
119                    Business::BatchPayment
120                    Business::OnlineThirdPartyPayment
121                  ) ],
122                  labels       => {
123                    'Business::OnlinePayment' => 'Direct',
124                    'Business::BatchPayment'  => 'Batch',
125                    'Business::OnlineThirdPartyPayment'  => 'Hosted',
126                  },
127                  onchange => 'changeNamespace',
128                },
129                {
130                  field    => 'gateway_module',
131                  type     => 'select',
132                  # does it even make sense to list all modules here?
133                  options  => [ sort { lc($a) cmp lc ($b) }
134                                map { @$_ } values %modules ],
135                },
136                'gateway_username',
137                'gateway_password',
138                {
139                  field    => 'gateway_action',
140                  type     => 'select',
141                  options  => \@actions,
142                },
143                {
144                  field    => 'gateway_callback_url',
145                  type     => 'text',
146                  size     => 40,
147                },
148                {
149                  field    => 'gateway_cancel_url',
150                  type     => 'text',
151                  size     => 40,
152                },
153                {
154                  field               => 'gateway_options',
155                  type                => 'textarea',
156                  rows                => '12',
157                  cols                => '40', 
158                  curr_value_callback => sub { my($cgi, $object, $fref) = @_;
159                                               join("\r", $object->options );
160                                             },
161                },
162              ];
163
164 my $field_callback = sub {
165   my ($cgi, $object, $field_hashref ) = @_;
166   if ($object->gatewaynum) {
167     if ( $field_hashref->{field} =~ /gateway_(module|namespace)/ ) {
168       $field_hashref->{type} = 'fixed';
169     }
170   }
171 };
172
173 </%init>