payment_fields() 공개 메소드

Override this in your gateway if you have some.
public payment_fields ( )
 /**
  * Render the payment fields
  *
  * @since 4.0.0
  * @see WC_Payment_Gateway::payment_fields()
  * @see SV_WC_Payment_Gateway_Payment_Form class
  */
 public function payment_fields()
 {
     if ($this->supports_payment_form()) {
         $this->get_payment_form_instance()->render();
     } else {
         parent::payment_fields();
     }
 }
 /**
  * Sanitize payment fields
  * - some gateways include js in their payment fields
  *
  * @param WC_Payment_Gateway $gateway
  * @return mixed|string
  */
 protected function sanitize_payment_fields(WC_Payment_Gateway $gateway)
 {
     $html = '';
     if ($gateway->has_fields() || $gateway->get_description()) {
         ob_start();
         $gateway->payment_fields();
         $html = ob_get_contents();
         ob_end_clean();
         // remove script tags
         $html = $this->removeDomNodes($html, '//script');
     }
     return self::trim_html_string($html);
 }
예제 #3
0
    /**
     * Payment fields for Realex.
     *
     * @see WC_Payment_Gateway::payment_fields()
     */
    public function payment_fields()
    {
        if ($this->threedsecure->is_3dsecure_available() && (!is_checkout_pay_page() || isset($_GET['pay_for_order']))) {
            parent::payment_fields();
            ?>
			<style type="text/css">#payment ul.payment_methods li label[for='payment_method_realex'] img:nth-child(n+2) { margin-left:1px; }</style>
			<?php 
            return;
        }
        // default to new card
        $card_ref = 'new';
        if ($this->vault_available()) {
            // get the credit card tokens for the user
            $current_user = wp_get_current_user();
            $credit_cards = array();
            if ($current_user->ID) {
                $credit_cards = get_user_meta($current_user->ID, 'woocommerce_realex_cc', true);
            }
            // if there are saved cards, and one hasn't been selected, default to the first
            if ($credit_cards) {
                $card_ref = (object) current($credit_cards);
                $card_ref = $card_ref->ref;
            }
        }
        ?>
		<style type="text/css">#payment ul.payment_methods li label[for='payment_method_realex'] img:nth-child(n+2) { margin-left:1px; }</style>
		<fieldset>
			<?php 
        if ($this->description) {
            ?>
<p><?php 
            echo esc_html($this->description);
            ?>
 <?php 
            if ($this->is_test_mode()) {
                esc_html_e('TEST MODE ENABLED', 'woocommerce-gateway-realex');
            }
            ?>
</p><?php 
        }
        ?>

			<?php 
        if ($this->vault_available() && $credit_cards) {
            ?>
				<div>
					<p class="form-row form-row-first" style="width:65%;">
						<?php 
            foreach ($credit_cards as $credit_card) {
                $credit_card = (object) $credit_card;
                ?>
							<input type="radio" id="<?php 
                echo esc_attr($credit_card->ref);
                ?>
" name="realex_card_ref" style="width:auto;" value="<?php 
                echo esc_attr($credit_card->ref);
                ?>
" <?php 
                checked($credit_card->ref, $card_ref);
                ?>
 />
							<label style="display:inline;" for="<?php 
                echo esc_attr($credit_card->ref);
                ?>
">
								<?php 
                /* translators: Placeholders: %1$s - credit card type, %2$s - credit card last 4, %3$s - credit card expiration MM/YY */
                printf(esc_html__('%1$s ending in %2$s (%3$s)', 'woocommerce-gateway-realex'), $this->card_type_options[$credit_card->type], $credit_card->last4, $credit_card->expiration_month . '/' . $credit_card->expiration_year);
                ?>
							</label><br />
						<?php 
            }
            ?>
						<input type="radio" id="realex_new" name="realex_card_ref" style="width:auto;" <?php 
            checked('new', $card_ref);
            ?>
 value="0" /> <label style="display:inline;" for="realex_new"><?php 
            esc_html_e('Use Another Credit Card', 'woocommerce-gateway-realex');
            ?>
</label>
					</p>
					<p class="form-row form-row-last" style="width:30%;"><a class="button" href="<?php 
            echo esc_url(wc_get_page_permalink('myaccount'));
            ?>
#saved-cards"><?php 
            echo esc_html($this->managecards);
            ?>
</a></p>
					<div style="clear:both;"></div>
				</div>
				<div class="clear"></div>

			<?php 
        }
        ?>

			<div class="realex_vault_new" style="<?php 
        echo $card_ref == 'new' ? '' : 'display:none;';
        ?>
">
				<p class="form-row form-row-first">
					<label for="realex_accountNumber"><?php 
        echo __("Credit Card number", 'woocommerce-gateway-realex');
        ?>
 <span class="required">*</span></label>
					<input type="text" class="input-text" id="realex_accountNumber" name="realex_accountNumber" maxlength="19" autocomplete="off" />
				</p>
				<p class="form-row form-row-last">
					<label for="realex_cardType"><?php 
        _e('Card Type', 'woocommerce-gateway-realex');
        ?>
 <span class="required">*</span></label>
					<select name="realex_cardType" id="realex_cardType" style="width:auto;"><br />
						<option value="">
						<?php 
        foreach ($this->cardtypes as $type) {
            if (isset($this->card_type_options[$type])) {
                ?>
									<option value="<?php 
                echo esc_attr(preg_replace('/-.*$/', '', $type));
                ?>
" rel="<?php 
                echo esc_attr($type);
                ?>
"><?php 
                esc_html_e($this->card_type_options[$type], 'woocommerce-gateway-realex');
                ?>
</option>
									<?php 
            }
        }
        ?>
					</select>
				</p>
				<div class="clear"></div>

				<p class="form-row form-row-first">
					<label for="realex_expirationMonth"><?php 
        esc_html_e('Expiration date', 'woocommerce-gateway-realex');
        ?>
 <span class="required">*</span></label>
					<select name="realex_expirationMonth" id="realex_expirationMonth" class="woocommerce-select woocommerce-cc-month" style="width:auto;">
						<option value=""><?php 
        esc_attr_e('Month', 'woocommerce-gateway-realex');
        ?>
</option>
						<?php 
        foreach (range(1, 12) as $month) {
            ?>
							<option value="<?php 
            echo sprintf('%02d', $month);
            ?>
"><?php 
            echo sprintf('%02d', $month);
            ?>
</option>
						<?php 
        }
        ?>
					</select>
					<select name="realex_expirationYear" id="realex_expirationYear" class="woocommerce-select woocommerce-cc-year" style="width:auto;">
						<option value=""><?php 
        esc_attr_e('Year', 'woocommerce-gateway-realex');
        ?>
</option>
						<?php 
        foreach (range(date('Y'), date('Y') + 20) as $year) {
            ?>
							<option value="<?php 
            echo $year;
            ?>
"><?php 
            echo $year;
            ?>
</option>
						<?php 
        }
        ?>
					</select>
				</p>
				<?php 
        if ($this->cvv == 'yes') {
            ?>

				<p class="form-row form-row-last">
					<label for="realex_cvNumber"><?php 
            esc_html_e('Card security code', 'woocommerce-gateway-realex');
            ?>
 <span class="required">*</span></label>
					<input type="text" class="input-text" id="realex_cvNumber" name="realex_cvNumber" maxlength="4" style="width:60px" autocomplete="off" />
				</p>
				<?php 
        }
        ?>

				<?php 
        if (in_array('SWITCH', $this->get_real_cardtypes())) {
            ?>
					<?php 
            if ($this->cvv == 'no') {
                ?>
						<p class="form-row form-row-last" style="display:none;">
					<?php 
            } else {
                ?>
						<div class="clear"></div>
						<p class="form-row form-row-first" style="display:none;">
					<?php 
            }
            ?>
					<label for="realex_issueNumber"><?php 
            esc_html_e('Issue Number', 'woocommerce-gateway-realex');
            ?>
</label>
					<input type="text" class="input-text" id="realex_issueNumber" name="realex_issueNumber" maxlength="3" style="width:60px" autocomplete="off" />
					</p>
				<?php 
        }
        ?>
				<div class="clear"></div>

				<?php 
        if ($this->vault_available()) {
            ?>
					<?php 
            if (wc_realex()->is_subscriptions_active() && WC_Subscriptions_Cart::cart_contains_subscription() && in_array('subscriptions', $this->supports)) {
                ?>
						<input name="realex_vault_new" type="hidden" value="1" />
					<?php 
            } else {
                /* Normal behavior */
                ?>
						<div class="realex_create-account">
							<p class="form-row">
								<input id="realex_vault_new" name="realex_vault_new" type="checkbox" value="1" style="width:auto;" />
								<label for="realex_vault_new" style="display:inline;"><?php 
                echo esc_html($this->vaulttext);
                ?>
</label>
							</p>
						</div>
						<div class="clear"></div>
					<?php 
            }
            ?>
				<?php 
        }
        ?>
			</div>
		</fieldset>
		<?php 
    }
 /**
  * Sanitize payment fields
  * - some gateways include js in their payment fields
  * @param WC_Payment_Gateway $gateway
  * @return mixed|string
  */
 protected function sanitize_payment_fields(WC_Payment_Gateway $gateway)
 {
     $html = '';
     if ($gateway->has_fields() || $gateway->get_description()) {
         ob_start();
         $gateway->payment_fields();
         $html = ob_get_contents();
         ob_end_clean();
         // remove any javascript
         // note: DOMDocument causes more problems than it's worth
         //      $doc = new DOMDocument();
         //      $doc->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
         //      $script_tags = $doc->getElementsByTagName('script');
         //      $length = $script_tags->length;
         //      for ($i = 0; $i < $length; $i++) {
         //        $script_tags->item($i)->parentNode->removeChild($script_tags->item($i));
         //      }
         //      echo $doc->saveHTML();
         // simple preg_replace
         $html = preg_replace('/<script.+?<\\/script>/im', '', $html);
     }
     return $html;
 }
 /**
  * Render the payment fields
  *
  * @since 4.0.0
  * @see WC_Payment_Gateway::payment_fields()
  * @see SV_WC_Payment_Gateway_Payment_Form class
  */
 public function payment_fields()
 {
     if ($this->supports_payment_form()) {
         $form = new SV_WC_Payment_Gateway_Payment_Form($this);
         $form->render();
     } else {
         parent::payment_fields();
     }
 }