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 = Cpanel::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     'FirstDataGlobalGateway',
59     'iAuthorizer',
60     'Ingotz',
61     'InternetSecure',
62     'IPaymentTPG',
63     'IPPay',
64     'Iridium',
65     'Jettis',
66     'Jety',
67     'LinkPoint',
68     'MerchantCommerce',
69     'Network1Financial',
70     'OCV',
71     'OpenECHO',
72     'PayConnect',
73     'PayflowPro',
74     'PaymenTech',
75     'PaymentsGateway',
76     'PayPal',
77     #'PaySystems',
78     'PlugnPay',
79     'PPIPayMover',
80     'Protx', #now SagePay
81     'PXPost',
82     'SagePay',
83     'SecureHostingUPG',
84     'Skipjack',
85     'StGeorge',
86     'SurePay',
87     'TCLink',
88     'TransactionCentral',
89     'TransFirsteLink',
90     'Vanco',
91     'viaKLIX',
92     'VirtualNet',
93     'WesternACH',
94     'WorldPay',
95   ],
96   'Business::OnlineThirdPartyPayment' => [
97     #'eWayShared', support currently broken
98     #'Interswitchng',
99     'PayPal',
100     'FCMB',
101   ],
102   'Business::BatchPayment' => [
103     'KeyBank',
104     'Paymentech',
105     'TD_EFT',
106     'BillBuddy',
107   ],
108 );
109
110 my @actions = (
111                 'Normal Authorization',
112                 'Authorization Only',
113                 'Authorization Only,Post Authorization',
114               );
115
116 my $fields = [ {
117                  field               => 'gateway_namespace',
118                  type                => 'select',
119                  options             => [ qw(
120                    Business::OnlinePayment
121                    Business::BatchPayment
122                    Business::OnlineThirdPartyPayment
123                  ) ],
124                  labels       => {
125                    'Business::OnlinePayment' => 'Direct',
126                    'Business::BatchPayment'  => 'Batch',
127                    'Business::OnlineThirdPartyPayment'  => 'Hosted',
128                  },
129                  onchange => 'changeNamespace',
130                },
131                {
132                  field    => 'gateway_module',
133                  type     => 'select',
134                  # does it even make sense to list all modules here?
135                  options  => [ sort { lc($a) cmp lc ($b) }
136                                map { @$_ } values %modules ],
137                },
138                'gateway_username',
139                'gateway_password',
140                {
141                  field    => 'gateway_action',
142                  type     => 'select',
143                  options  => \@actions,
144                },
145                {
146                  field    => 'gateway_callback_url',
147                  type     => 'text',
148                  size     => 40,
149                },
150                {
151                  field    => 'gateway_cancel_url',
152                  type     => 'text',
153                  size     => 40,
154                },
155                {
156                  field               => 'gateway_options',
157                  type                => 'textarea',
158                  rows                => '12',
159                  cols                => '40', 
160                  curr_value_callback => sub { my($cgi, $object, $fref) = @_;
161                                               join("\r", $object->options );
162                                             },
163                },
164              ];
165
166 my $field_callback = sub {
167   my ($cgi, $object, $field_hashref ) = @_;
168   if ($object->gatewaynum) {
169     if ( $field_hashref->{field} eq 'gateway_module' ) {
170       $field_hashref->{type} = 'fixed';
171     } elsif ( $field_hashref->{field} eq 'gateway_namespace' ) {
172       $field_hashref->{type} = 'fixed';
173       $field_hashref->{formatted_value} = $object->namespace_description;
174     }
175   }
176 };
177
178 </%init>