+ # get list of all gateways in table (not counting default gateway)
+ my $cache = {}; #cache for module info
+ my $sth = $dbh->prepare('SELECT DISTINCT gatewaynum FROM payment_gateway')
+ or die $dbh->errstr;
+ $sth->execute or die $sth->errstr;
+ my @gatewaynums;
+ while (my $row = $sth->fetchrow_hashref) {
+ push(@gatewaynums,$row->{'gatewaynum'});
+ }
+ $sth->finish;
+
+ # look for a gateway that can't tokenize
+ my $disallow_untokenized = 1;
+ foreach my $gatewaynum ('',@gatewaynums) {
+ my $gateway = FS::agent->payment_gateway( load_gatewaynum => $gatewaynum, nofatal => 1 );
+ if (!$gateway) { # already died if $gatewaynum
+ # no default gateway, no promise to tokenize
+ # can just load other gateways as-needeed below
+ $disallow_untokenized = 0;
+ last;
+ }
+ my $info = _token_check_gateway_info($cache,$gateway);
+ return $info unless ref($info); # means it's an error message
+ unless ($info->{'can_tokenize'}) {
+ # a configured gateway can't tokenize, that's all we need to know right now
+ # can just load other gateways as-needeed below
+ $disallow_untokenized = 0;
+ last;
+ }
+ }
+
+ my $oldAutoCommit = $FS::UID::AutoCommit;
+ local $FS::UID::AutoCommit = 0;