src/Forms/OrderActionsForm.php
protected function getCCFields(array $gateways)
    {
        $fieldFactory = new GatewayFieldsFactory(null, array('Card'));
        $onsiteGateways = array();
        $allRequired = array();
        foreach ($gateways as $gateway => $title) {
            if (!GatewayInfo::isOffsite($gateway)) {
                $required = GatewayInfo::requiredFields($gateway);
                $onsiteGateways[$gateway] = $fieldFactory->getFieldName($required);
                $allRequired += $required;
            }
        }

        $allRequired = array_unique($allRequired);
        $allRequired = $fieldFactory->getFieldName(array_combine($allRequired, $allRequired));

        if (empty($onsiteGateways)) {
            return null;
        }

        $ccFields = $fieldFactory->getCardFields();

        // Remove all the credit card fields that aren't required by any gateway
        foreach ($ccFields->dataFields() as $name => $field) {
            if ($name && !in_array($name, $allRequired)) {
                $ccFields->removeByName($name, true);
            }
        }

        $lookupField = LiteralField::create(
            '_CCLookupField',
            sprintf(
                '<span class="gateway-lookup" data-gateways=\'%s\'></span>',
                json_encode($onsiteGateways, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP)
            )
        );

        $ccFields->push($lookupField);

        return CompositeField::create($ccFields)->setTag('fieldset')->addExtraClass('credit-card');
    }
protected function getCCFields(array $gateways)
    {
        $fieldFactory = new GatewayFieldsFactory(null, array('Card'));
        $onsiteGateways = array();
        $allRequired = array();
        foreach ($gateways as $gateway => $title) {
            if (!GatewayInfo::isOffsite($gateway)) {
                $required = GatewayInfo::requiredFields($gateway);
                $onsiteGateways[$gateway] = $fieldFactory->getFieldName($required);
                $allRequired += $required;
            }
        }

        $allRequired = array_unique($allRequired);
        $allRequired = $fieldFactory->getFieldName(array_combine($allRequired, $allRequired));

        if (empty($onsiteGateways)) {
            return null;
        }

        $ccFields = $fieldFactory->getCardFields();

        // Remove all the credit card fields that aren't required by any gateway
        foreach ($ccFields->dataFields() as $name => $field) {
            if ($name && !in_array($name, $allRequired)) {
                $ccFields->removeByName($name, true);
            }
        }

        $lookupField = LiteralField::create(
            '_CCLookupField',
            sprintf(
                '<span class="gateway-lookup" data-gateways=\'%s\'></span>',
                json_encode($onsiteGateways, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP)
            )
        );

        $ccFields->push($lookupField);

        return CompositeField::create($ccFields)->setTag('fieldset')->addExtraClass('credit-card');
    }
Get credit card fields for the given gateways

@param  array $gateways
@return CompositeField|null