return false;
        }
        $matchingPatterns = array('visa' => '/^4[0-9]{12}(?:[0-9]{3})?$/', 'mastercard' => '/^5[1-5][0-9]{14}$/', 'amex' => '/^3[47][0-9]{13}$/', 'diners' => '/^3(?:0[0-5]|[68][0-9])[0-9]{11}$/', 'discover' => '/^6(?:011|5[0-9]{2})[0-9]{12}$/', 'jcb' => '/^(?:2131|1800|35\\d{3})\\d{11}$/');
        foreach ($matchingPatterns as $key => $pattern) {
            if (preg_match($pattern, $number)) {
                return $key;
            }
        }
        return false;
    }
    /**
     * Returns supported currencies by PayPal listed here:
     *
     * @access public
     * @param string $payment
     * @see https://developer.paypal.com/docs/integration/direct/rest_api_payment_country_currency_support/
     * @return array
     */
    public static function get_supported_currencies($payment)
    {
        if ($payment == 'account') {
            return array("AUD", "BRL", "CAD", "CZK", "DKK", "EUR", "HKD", "HUF", "ILS", "JPY", "MYR", "MXN", "TWD", "NZD", "NOK", "PHP", "PLN", "GBP", "SGD", "SEK", "CHF", "THB", "TRY", "USD");
        }
        if ($payment == 'card') {
            return array("USD", "GBP", "CAD", "EUR", "JPY");
        }
        return array();
    }
}
Realia_PayPal::init();
Beispiel #2
0
							<label for="payment-paypal-account">
								<span><?php 
        echo __('PayPal Account', 'realia');
        ?>
</span>
							</label>
						</div><!-- /.radio-wrapper -->
					</div><!-- /.payment-header -->
				</div><!-- /.payment -->
			<?php 
    }
    ?>

			<?php 
    if (in_array($currency_code, Realia_PayPal::get_supported_currencies('account')) || in_array($currency_code, Realia_PayPal::get_supported_currencies('card'))) {
        ?>

				<?php 
        if (!empty($payment_type)) {
            ?>
					<button type="submit" name="process-payment" class="btn pull-right">
						<?php 
            echo __('Proceed payment', 'realia');
            ?>
					</button>
				<?php 
        }
        ?>

			<?php