+<SCRIPT TYPE="text/javascript">
+ var modulesForNamespace = <% $json->encode(\%modules) %>;
+ function changeNamespace() {
+ if (document.getElementById('gatewaynum').value) {
+ return true;
+ }
+ var ns = document.getElementById('gateway_namespace').value;
+ var select_module = document.getElementById('gateway_module');
+ select_module.options.length = 0;
+ for (var x in modulesForNamespace[ns]) {
+ var o = document.createElement('option');
+ o.value = o.text = modulesForNamespace[ns][x];
+ select_module.add(o, null);
+ }
+ }
+ window.onload = changeNamespace;
+</SCRIPT>
+
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my $json = Cpanel::JSON::XS->new;
+$json->canonical(1);
+my %modules = (
+ 'Business::OnlinePayment' => [
+ '2CheckOut',
+ 'AuthorizeNet',
+ 'BankOfAmerica', #deprecated?
+ 'Beanstream',
+ 'Braintree',
+ 'Capstone',
+ 'CardFortress',
+ 'Cardstream',
+ 'CashCow',
+ 'CyberSource',
+ 'eSec',
+ 'eSelectPlus',
+ 'ElavonVirtualMerchant',
+ 'eWay',
+ 'Exact',
+ 'FirstDataGlobalGateway',
+ 'GlobalPayments',
+ 'iAuthorizer',
+ 'Ingotz',
+ 'InternetSecure',
+ #'IPaymentTPG',
+ 'IPPay',
+ 'Iridium',
+ 'Jettis',
+ 'Jety',
+ 'LinkPoint',
+ 'Litle',
+ 'MerchantCommerce',
+ 'Network1Financial',
+ 'NMI',
+ 'OCV',
+ 'Ogone',
+ 'OpenECHO',
+ 'PaperlessTrans',
+ 'PayConnect',
+ 'PayflowPro',
+ 'PaymenTech',
+ 'PaymentsGateway',
+ 'PayPal',
+ #'PaySystems',
+ 'PlugnPay',
+ 'PPIPayMover',
+ 'Protx', #now SagePay
+ 'PXPost',
+ 'SagePay',
+ 'SecureHostingUPG',
+ 'Skipjack',
+ 'StGeorge',
+ 'SurePay',
+ 'SynapseGateway',
+ 'TCLink',
+ 'TransactionCentral',
+ 'TransFirsteLink',
+ 'USAePay',
+ 'Vanco',
+ 'viaKLIX',
+ 'VirtualNet',
+ 'vSecureProcessing',
+ 'WesternACH',
+ 'WorldPay',
+ ],
+ 'Business::OnlineThirdPartyPayment' => [
+ #'eWayShared', support currently broken
+ 'FCMB',
+ #'Interswitchng', #incomplete?
+ 'PayPal',
+ ],
+ 'Business::BatchPayment' => [
+ 'BillBuddy',
+ 'CardFortress',
+ 'KeyBank',
+ 'Paymentech',
+ 'RBC',
+ 'TD_EFT',
+ ],
+);
+
+my @actions = (
+ 'Normal Authorization',
+ 'Authorization Only',
+ 'Authorization Only,Post Authorization',
+ );
+
+my $fields = [ {
+ field => 'gateway_namespace',
+ type => 'select',
+ options => [ qw(
+ Business::OnlinePayment
+ Business::BatchPayment
+ Business::OnlineThirdPartyPayment
+ ) ],
+ labels => {
+ 'Business::OnlinePayment' => 'Direct',
+ 'Business::BatchPayment' => 'Batch',
+ 'Business::OnlineThirdPartyPayment' => 'Hosted',
+ },
+ onchange => 'changeNamespace',
+ },
+ {
+ field => 'gateway_module',
+ type => 'select',
+ # does it even make sense to list all modules here?
+ options => [ sort { lc($a) cmp lc($b) }
+ map { @$_ } values %modules ],
+ },
+ 'gateway_username',
+ 'gateway_password',
+ {
+ field => 'gateway_action',
+ type => 'select',
+ options => \@actions,
+ },
+ {
+ field => 'gateway_callback_url',
+ type => 'text',
+ size => 40,
+ },
+ {
+ field => 'gateway_cancel_url',
+ type => 'text',
+ size => 40,
+ },
+ {
+ field => 'gateway_options',
+ type => 'textarea',
+ rows => '12',
+ cols => '40',
+ curr_value_callback => sub { my($cgi, $object, $fref) = @_;
+ join("\r", $object->options );
+ },
+ },
+ ];
+
+my $field_callback = sub {
+ my ($cgi, $object, $field_hashref ) = @_;
+ if ($object->gatewaynum) {
+ if ( $field_hashref->{field} eq 'gateway_module' ) {
+ if ($object->gateway_namespace eq 'Business::OnlinePayment' &&
+ $object->gateway_module ne 'CardFortress'
+ ) {
+ $field_hashref->{options} = [ $object->gateway_module, 'CardFortress' ]
+ } else {
+ $field_hashref->{type} = 'fixed';
+ }
+ } elsif ( $field_hashref->{field} eq 'gateway_namespace' ) {
+ $field_hashref->{type} = 'fixed';
+ $field_hashref->{formatted_value} = $object->namespace_description;
+ }
+ }
+};
+
+</%init>