RT# 82949 - changes section name from fees to pricing, better opiton
[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     if (document.getElementById('gatewaynum').value) {
26       return true;
27     }
28     var ns = document.getElementById('gateway_namespace').value;
29     var select_module = document.getElementById('gateway_module');
30     select_module.options.length = 0;
31     for (var x in modulesForNamespace[ns]) {
32       var o = document.createElement('option');
33       o.value = o.text = modulesForNamespace[ns][x];
34       select_module.add(o, null);
35     }
36   }
37   window.onload = changeNamespace;
38 </SCRIPT>
39
40 <%init>
41
42 die "access denied"
43   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
44
45 my $json = Cpanel::JSON::XS->new;
46 $json->canonical(1);
47 my %modules = (
48   'Business::OnlinePayment' => [
49     '2CheckOut',
50     'AuthorizeNet',
51     'BankOfAmerica', #deprecated?
52     'Beanstream',
53     'Braintree',
54     'Capstone',
55     'CardFortress',
56     'Cardstream',
57     'CashCow',
58     'CyberSource',
59     'eSec',
60     'eSelectPlus',
61     'ElavonVirtualMerchant',
62     'eWay',
63     'Exact',
64     'FirstDataGlobalGateway',
65     'GlobalPayments',
66     'iAuthorizer',
67     'Ingotz',
68     'InternetSecure',
69     #'IPaymentTPG',
70     'IPPay',
71     'Iridium',
72     'Jettis',
73     'Jety',
74     'LinkPoint',
75     'Litle',
76     'MerchantCommerce',
77     'Network1Financial',
78     'NMI',
79     'OCV',
80     'Ogone',
81     'OpenECHO',
82     'PaperlessTrans',
83     'PayConnect',
84     'PayflowPro',
85     'PaymenTech',
86     'PaymentsGateway',
87     'PayPal',
88     #'PaySystems',
89     'PlugnPay',
90     'PPIPayMover',
91     'Protx', #now SagePay
92     'PXPost',
93     'SagePay',
94     'SecureHostingUPG',
95     'Skipjack',
96     'StGeorge',
97     'SurePay',
98     'SynapseGateway',
99     'TCLink',
100     'TransactionCentral',
101     'TransFirsteLink',
102     'USAePay',
103     'Vanco',
104     'viaKLIX',
105     'VirtualNet',
106     'vSecureProcessing',
107     'WesternACH',
108     'WorldPay',
109   ],
110   'Business::OnlineThirdPartyPayment' => [
111     #'eWayShared', support currently broken
112     'FCMB',
113     #'Interswitchng', #incomplete?
114     'PayPal',
115   ],
116   'Business::BatchPayment' => [
117     'BillBuddy',
118     'CardFortress',
119     'KeyBank',
120     'Paymentech',
121     'RBC',
122     'TD_EFT',
123   ],
124 );
125
126 my @actions = (
127                 'Normal Authorization',
128                 'Authorization Only',
129                 'Authorization Only,Post Authorization',
130               );
131
132 my $fields = [ {
133                  field               => 'gateway_namespace',
134                  type                => 'select',
135                  options             => [ qw(
136                    Business::OnlinePayment
137                    Business::BatchPayment
138                    Business::OnlineThirdPartyPayment
139                  ) ],
140                  labels       => {
141                    'Business::OnlinePayment' => 'Direct',
142                    'Business::BatchPayment'  => 'Batch',
143                    'Business::OnlineThirdPartyPayment'  => 'Hosted',
144                  },
145                  onchange => 'changeNamespace',
146                },
147                {
148                  field    => 'gateway_module',
149                  type     => 'select',
150                  # does it even make sense to list all modules here?
151                  options  => [ sort { lc($a) cmp lc($b) }
152                                map { @$_ } values %modules ],
153                },
154                'gateway_username',
155                'gateway_password',
156                {
157                  field    => 'gateway_action',
158                  type     => 'select',
159                  options  => \@actions,
160                },
161                {
162                  field    => 'gateway_callback_url',
163                  type     => 'text',
164                  size     => 40,
165                },
166                {
167                  field    => 'gateway_cancel_url',
168                  type     => 'text',
169                  size     => 40,
170                },
171                {
172                  field               => 'gateway_options',
173                  type                => 'textarea',
174                  rows                => '12',
175                  cols                => '40', 
176                  curr_value_callback => sub { my($cgi, $object, $fref) = @_;
177                                               join("\r", $object->options );
178                                             },
179                },
180              ];
181
182 my $field_callback = sub {
183   my ($cgi, $object, $field_hashref ) = @_;
184   if ($object->gatewaynum) {
185     if ( $field_hashref->{field} eq 'gateway_module' ) {
186       if ($object->gateway_namespace eq 'Business::OnlinePayment' &&
187           $object->gateway_module ne 'CardFortress'
188       ) {
189         $field_hashref->{options} = [ $object->gateway_module, 'CardFortress' ]
190       } else {
191         $field_hashref->{type} = 'fixed';
192       }
193     } elsif ( $field_hashref->{field} eq 'gateway_namespace' ) {
194       $field_hashref->{type} = 'fixed';
195       $field_hashref->{formatted_value} = $object->namespace_description;
196     }
197   }
198 };
199
200 </%init>