Merge branch 'master' of git.freeside.biz:/home/git/freeside
[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', support currently broken
97     #'Interswitchng',
98     'PayPal',
99     'FCMB',
100   ],
101   'Business::BatchPayment' => [
102     'KeyBank',
103     'Paymentech',
104     'TD_EFT',
105   ],
106 );
107
108 my @actions = (
109                 'Normal Authorization',
110                 'Authorization Only',
111                 'Authorization Only,Post Authorization',
112               );
113
114 my $fields = [
115                {
116                  field               => 'gateway_namespace',
117                  type                => 'select',
118                  options             => [ qw(
119                    Business::OnlinePayment
120                    Business::BatchPayment
121                    Business::OnlineThirdPartyPayment
122                  ) ],
123                  labels       => {
124                    'Business::OnlinePayment' => 'Direct',
125                    'Business::BatchPayment'  => 'Batch',
126                    'Business::OnlineThirdPartyPayment'  => 'Hosted',
127                  },
128                  onchange => 'changeNamespace',
129                },
130                {
131                  field    => 'gateway_module',
132                  type     => 'select',
133                  # does it even make sense to list all modules here?
134                  options  => [ sort { lc($a) cmp lc ($b) }
135                                map { @$_ } values %modules ],
136                },
137                'gateway_username',
138                'gateway_password',
139                {
140                  field    => 'gateway_action',
141                  type     => 'select',
142                  options  => \@actions,
143                },
144                {
145                  field    => 'gateway_callback_url',
146                  type     => 'text',
147                  size     => 40,
148                },
149                {
150                  field    => 'gateway_cancel_url',
151                  type     => 'text',
152                  size     => 40,
153                },
154                {
155                  field               => 'gateway_options',
156                  type                => 'textarea',
157                  rows                => '12',
158                  cols                => '40', 
159                  curr_value_callback => sub { my($cgi, $object, $fref) = @_;
160                                               join("\r", $object->options );
161                                             },
162                },
163              ];
164
165 my $field_callback = sub {
166   my ($cgi, $object, $field_hashref ) = @_;
167   if ($object->gatewaynum) {
168     if ( $field_hashref->{field} =~ /gateway_(module|namespace)/ ) {
169       $field_hashref->{type} = 'fixed';
170     }
171   }
172 };
173
174 </%init>