17709c84c076749c3c078f5e9e95338b7bd555e3
[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                  field               => 'gateway_namespace',
115                  type                => 'select',
116                  options             => [ qw(
117                    Business::OnlinePayment
118                    Business::BatchPayment
119                    Business::OnlineThirdPartyPayment
120                  ) ],
121                  labels       => {
122                    'Business::OnlinePayment' => 'Direct',
123                    'Business::BatchPayment'  => 'Batch',
124                    'Business::OnlineThirdPartyPayment'  => 'Hosted',
125                  },
126                  onchange => 'changeNamespace',
127                },
128                {
129                  field    => 'gateway_module',
130                  type     => 'select',
131                  # does it even make sense to list all modules here?
132                  options  => [ sort { lc($a) cmp lc ($b) }
133                                map { @$_ } values %modules ],
134                },
135                'gateway_username',
136                'gateway_password',
137                {
138                  field    => 'gateway_action',
139                  type     => 'select',
140                  options  => \@actions,
141                },
142                {
143                  field    => 'gateway_callback_url',
144                  type     => 'text',
145                  size     => 40,
146                },
147                {
148                  field    => 'gateway_cancel_url',
149                  type     => 'text',
150                  size     => 40,
151                },
152                {
153                  field               => 'gateway_options',
154                  type                => 'textarea',
155                  rows                => '12',
156                  cols                => '40', 
157                  curr_value_callback => sub { my($cgi, $object, $fref) = @_;
158                                               join("\r", $object->options );
159                                             },
160                },
161              ];
162
163 my $field_callback = sub {
164   my ($cgi, $object, $field_hashref ) = @_;
165   if ($object->gatewaynum) {
166     if ( $field_hashref->{field} eq 'gateway_module' ) {
167       $field_hashref->{type} = 'fixed';
168     } elsif ( $field_hashref->{field} eq 'gateway_namespace' ) {
169       $field_hashref->{type} = 'fixed';
170       $field_hashref->{formatted_value} = $object->namespace_description;
171     }
172   }
173 };
174
175 </%init>