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                                 },
17           )
18 %>
19
20
21 <SCRIPT TYPE="text/javascript">
22 % my $json = JSON->new->canonical;
23   var modulesForNamespace = <% $json->encode(\%modules_for_namespace) %>;
24   function changeNamespace(what) {
25     var ns = what.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 </SCRIPT>
35
36 <%init>
37
38 die "access denied"
39   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
40
41 my %modules =  (
42   '2CheckOut'             => 'Business::OnlinePayment',
43   'AuthorizeNet'          => 'Business::OnlinePayment',
44   'BankOfAmerica'         => 'Business::OnlinePayment', #deprecated?
45   'Beanstream'            => 'Business::OnlinePayment',
46   'Capstone'              => 'Business::OnlinePayment',
47   'Cardstream'            => 'Business::OnlinePayment',
48   'CashCow'               => 'Business::OnlinePayment',
49   'CyberSource'           => 'Business::OnlinePayment',
50   'eSec'                  => 'Business::OnlinePayment',
51   'eSelectPlus'           => 'Business::OnlinePayment',
52   'eWayShared'            => 'Business::OnlineThirdPartyPayment',
53   'ElavonVirtualMerchant' => 'Business::OnlinePayment',
54   'Exact'                 => 'Business::OnlinePayment',
55   'iAuthorizer'           => 'Business::OnlinePayment',
56   'Ingotz'                => 'Business::OnlinePayment',
57   'InternetSecure'        => 'Business::OnlinePayment',
58   'Interswitchng'         => 'Business::OnlineThirdPartyPayment',
59   'IPaymentTPG'           => 'Business::OnlinePayment',
60   'IPPay'                 => 'Business::OnlinePayment',
61   'Iridium'               => 'Business::OnlinePayment',
62   'Jettis'                => 'Business::OnlinePayment',
63   'Jety'                  => 'Business::OnlinePayment',
64   'LinkPoint'             => 'Business::OnlinePayment',
65   'MerchantCommerce'      => 'Business::OnlinePayment',
66   'Network1Financial'     => 'Business::OnlinePayment',
67   'OCV'                   => 'Business::OnlinePayment',
68   'OpenECHO'              => 'Business::OnlinePayment',
69   'PayConnect'            => 'Business::OnlinePayment',
70   'PayflowPro'            => 'Business::OnlinePayment',
71   'Paymentech'            => 'Business::BatchPayment',
72   'PaymenTech'            => 'Business::OnlinePayment',
73   'PaymentsGateway'       => 'Business::OnlinePayment',
74   'PayPal'                => 'Business::OnlinePayment',
75   #'PaySystems'            => 'Business::OnlinePayment',
76   'PlugnPay'              => 'Business::OnlinePayment',
77   'PPIPayMover'           => 'Business::OnlinePayment',
78   'Protx'                 => 'Business::OnlinePayment', #now SagePay
79   'PXPost'                => 'Business::OnlinePayment',
80   'SagePay'               => 'Business::OnlinePayment',
81   'SecureHostingUPG'      => 'Business::OnlinePayment',
82   'Skipjack'              => 'Business::OnlinePayment',
83   'StGeorge'              => 'Business::OnlinePayment',
84   'SurePay'               => 'Business::OnlinePayment',
85   'TCLink'                => 'Business::OnlinePayment',
86   'TransactionCentral'    => 'Business::OnlinePayment',
87   'TransFirsteLink'       => 'Business::OnlinePayment',
88   'Vanco'                 => 'Business::OnlinePayment',
89   'viaKLIX'               => 'Business::OnlinePayment',
90   'VirtualNet'            => 'Business::OnlinePayment',
91   'WesternACH'            => 'Business::OnlinePayment',
92   'WorldPay'              => 'Business::OnlinePayment',
93 );
94
95 my %modules_for_namespace;
96 for (keys %modules) {
97   $modules_for_namespace{$modules{$_}} ||= [];
98   push @{ $modules_for_namespace{$modules{$_}} }, $_;
99 }
100
101 my @actions = (
102                 'Normal Authorization',
103                 'Authorization Only',
104                 'Authorization Only,Post Authorization',
105               );
106
107 my $fields = [
108                {
109                  field               => 'gateway_namespace',
110                  type                => 'select',
111                  options             => [ qw(
112                    Business::OnlinePayment
113                    Business::BatchPayment
114                    Business::OnlineThirdPartyPayment
115                  ) ],
116                  labels       => {
117                    'Business::OnlinePayment' => 'Direct',
118                    'Business::BatchPayment'  => 'Batch',
119                    'Business::OnlineThirdPartyPayment'  => 'Hosted',
120                  },
121                  onchange => 'changeNamespace',
122                },
123                {
124                  field    => 'gateway_module',
125                  type     => 'select',
126                  options  => [ sort { lc($a) cmp lc ($b) } keys %modules ],
127                },
128                'gateway_username',
129                'gateway_password',
130                {
131                  field    => 'gateway_action',
132                  type     => 'select',
133                  options  => \@actions,
134                },
135                {
136                  field    => 'gateway_callback_url',
137                  type     => 'text',
138                  size     => 40,
139                },
140                {
141                  field               => 'gateway_options',
142                  type                => 'textarea',
143                  rows                => '8',
144                  cols                => '40', 
145                  curr_value_callback => sub { my($cgi, $object, $fref) = @_;
146                                               join("\r", $object->options );
147                                             },
148                },
149              ];
150
151 my $field_callback = sub {
152   my ($cgi, $object, $field_hashref ) = @_;
153   if ($object->gatewaynum) {
154     if ( $field_hashref->{field} =~ /gateway_(module|namespace)/ ) {
155       $field_hashref->{type} = 'fixed';
156     }
157   }
158 };
159
160 </%init>