/** * Prepare Javascript for creating credit card tokens. * * @access public * * @param array $form * @param array $field_values * @param bool $is_ajax * * @return void */ public function register_creditcard_token_script($form, $field_values, $is_ajax) { if (!$this->enqueue_creditcard_token_script($form)) { return; } /* Prepare GFToken object. */ $gftoken = array('callback' => 'GF_' . str_replace(' ', '', $this->_short_title), 'feeds' => $this->creditcard_token_info($form), 'formId' => rgar($form, 'id'), 'hasPages' => GFCommon::has_pages($form), 'pageCount' => GFFormDisplay::get_max_page_number($form), 'responseField' => '#gf_' . str_replace('gravityforms', '', $this->_slug) . '_response'); /* Get needed fields. */ $gftoken['fields'] = $this->get_creditcard_token_entry_fields($gftoken['feeds']); $script = 'new GFToken( ' . json_encode($gftoken) . ' );'; GFFormDisplay::add_init_script($form['id'], 'GFToken', GFFormDisplay::ON_PAGE_RENDER, $script); }