本文整理汇总了PHP中WC_Payment_Gateway类的典型用法代码示例。如果您正苦于以下问题:PHP WC_Payment_Gateway类的具体用法?PHP WC_Payment_Gateway怎么用?PHP WC_Payment_Gateway使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WC_Payment_Gateway类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: merge_settings
/**
* @param WC_Payment_Gateway $gateway
*/
public function merge_settings(WC_Payment_Gateway $gateway)
{
$data = $this->get_data();
if (isset($data['title'])) {
$gateway->title = $data['title'];
}
if (isset($data['description'])) {
$gateway->description = $data['description'];
}
$gateway->has_icon = $gateway->get_icon() != '';
$gateway->show_icon = isset($data['icon']) ? $data['icon'] : true;
}
示例2:
/**
* Amazon Payments Advanced is available if the following conditions are met (on top of WC_Payment_Gateway::is_available)
* 1) Login App mode is enabled and we have an access token from Amazon
* 2) Login App mode is *not* enabled and we have an order reference id
*
* @return bool
*/
function is_available()
{
$login_app_enabled = 'yes' === $this->enable_login_app;
$standard_mode_ok = !$login_app_enabled && !empty($this->reference_id);
$login_app_mode_ok = $login_app_enabled && !empty($this->access_token);
return parent::is_available() && ($standard_mode_ok || $login_app_mode_ok);
}
示例3: is_available
/**
* Checks for proper gateway configuration including:
*
* + gateway enabled
* + correct configuration (gateway specific)
* + any dependencies met
* + required currency
* + required country
*
* @since 1.0.0
* @see WC_Payment_Gateway::is_available()
* @return true if this gateway is available for checkout, false otherwise
*/
public function is_available()
{
// is enabled check
$is_available = parent::is_available();
// proper configuration
if (!$this->is_configured()) {
$is_available = false;
}
// all plugin dependencies met
if (count($this->get_plugin()->get_missing_dependencies()) > 0) {
$is_available = false;
}
// any required currencies?
if (!$this->currency_is_accepted()) {
$is_available = false;
}
// any required countries?
if ($this->countries && WC()->customer && WC()->customer->get_country() && !in_array(WC()->customer->get_country(), $this->countries)) {
$is_available = false;
}
/**
* Payment Gateway Is Available Filter.
*
* Allow actors to modify whether the gateway is available or not.
*
* @since 1.0.0
* @param bool $is_available
*/
return apply_filters('wc_gateway_' . $this->get_id() . '_is_available', $is_available);
}
示例4: is_available
/**
* Checks for proper gateway configuration including:
*
* + gateway enabled
* + correct configuration (gateway specific)
* + any dependencies met
* + required currency
* + required country
*
* @since 1.0.0
* @see WC_Payment_Gateway::is_available()
* @return true if this gateway is available for checkout, false otherwise
*/
public function is_available()
{
// is enabled check
$is_available = parent::is_available();
// proper configuration
if (!$this->is_configured()) {
$is_available = false;
}
// all plugin dependencies met
if (count($this->get_plugin()->get_missing_dependencies()) > 0) {
$is_available = false;
}
// any required currencies?
if (!$this->currency_is_accepted()) {
$is_available = false;
}
// any required countries?
if ($this->countries && WC()->customer && WC()->customer->get_country() && !in_array(WC()->customer->get_country(), $this->countries)) {
$is_available = false;
}
return apply_filters('wc_gateway_' . $this->get_id() . '_is_available', $is_available);
}
示例5: sanitize_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);
}
示例6: prepare_item_for_response
/**
* Prepare a payment gateway for response.
*
* @param WC_Payment_Gateway $gateway Payment gateway object.
* @param WP_REST_Request $request Request object.
* @return WP_REST_Response $response Response data.
*/
public function prepare_item_for_response($gateway, $request)
{
$order = (array) get_option('woocommerce_gateway_order');
$item = array('id' => $gateway->id, 'title' => $gateway->title, 'description' => $gateway->description, 'order' => isset($order[$gateway->id]) ? $order[$gateway->id] : '', 'enabled' => 'yes' === $gateway->enabled, 'method_title' => $gateway->get_method_title(), 'method_description' => $gateway->get_method_description(), 'settings' => $this->get_settings($gateway));
$context = !empty($request['context']) ? $request['context'] : 'view';
$data = $this->add_additional_fields_to_object($item, $request);
$data = $this->filter_response_by_context($data, $context);
$response = rest_ensure_response($data);
$response->add_links($this->prepare_links($gateway, $request));
/**
* Filter payment gateway objects returned from the REST API.
*
* @param WP_REST_Response $response The response object.
* @param WC_Payment_Gateway $gateway Payment gateway object.
* @param WP_REST_Request $request Request object.
*/
return apply_filters('woocommerce_rest_prepare_payment_gateway', $response, $gateway, $request);
}
示例7: is_available
/**
* Check if this gateway is enabled
*/
public function is_available()
{
if (!$this->api_key || !$this->mid) {
return false;
}
return parent::is_available();
}
示例8: init_settings
public function init_settings()
{
parent::init_settings();
$options_to_import = array('payapp_user_id', 'payapp_link_key', 'payapp_link_val', 'checkout_methods');
foreach ($options_to_import as $key) {
$this->settings[$key] = get_option(wskl_get_option_name($key));
}
$this->settings['enabled'] = wskl_yes_or_no(wskl_is_option_enabled('enable_sym_pg') && wskl_get_option('pg_agency') == 'payapp' && in_array($this->checkout_method, $this->get_option('checkout_methods')));
}
示例9: init_settings
public function init_settings()
{
parent::init_settings();
$options_to_import = array('iamport_user_code', 'iamport_rest_key', 'iamport_rest_secret', 'checkout_methods');
foreach ($options_to_import as $key) {
$this->settings[$key] = wskl_get_option($key);
}
$this->settings['enabled'] = wskl_yes_or_no(wskl_is_option_enabled('enable_sym_pg') && wskl_get_option('pg_agency') == 'iamport' && in_array($this->checkout_method, $this->settings['checkout_methods']));
}
示例10:
/**
* Check if gateway meets all the requirements to be used
*
* @access public
* @return bool
*/
function is_available()
{
// is enabled check
$is_available = parent::is_available();
// Required fields check
if (!$this->customer_api && !$this->customer_password) {
$is_available = false;
}
return apply_filters('woocommerce_eway_is_available', $is_available);
}
示例11: is_available
/**
* Check if the gateway is available for use
*
* @return bool
*/
public function is_available()
{
$is_available = parent::is_available();
// Only allow unencrypted connections when testing
if (!is_ssl() && !$this->testmode) {
$is_available = false;
}
// Required fields check
if (!$this->merchant_id || !$this->merchant_password) {
$is_available = false;
}
return $is_available;
}
示例12: admin_options
/**
* Admin Panel Options
* - Options for bits like 'title' and availability on a country-by-country basis
*
* @access public
* @return void
*/
public function admin_options()
{
parent::admin_options();
?>
<script type="text/javascript">
jQuery( '#woocommerce_paypal_pro_enable_3dsecure' ).change( function () {
var threedsec = jQuery( '#woocommerce_paypal_pro_centinel_pid, #woocommerce_paypal_pro_centinel_mid, #woocommerce_paypal_pro_centinel_pwd, #woocommerce_paypal_pro_liability_shift' ).closest( 'tr' );
if ( jQuery( this ).is( ':checked' ) ) {
threedsec.show();
} else {
threedsec.hide();
}
}).change();
</script>
<?php
}
示例13: process_admin_options
public function process_admin_options()
{
$post_data = $this->get_post_data();
$mode = 'live';
if ($post_data['woocommerce_' . $this->id . '_sandbox'] == '1') {
$mode = 'test';
}
$this->merchant_id = $post_data['woocommerce_' . $this->id . '_' . $mode . '_merchant_id'];
$this->private_key = $post_data['woocommerce_' . $this->id . '_' . $mode . '_private_key'];
$this->publishable_key = $post_data['woocommerce_' . $this->id . '_' . $mode . '_publishable_key'];
$env = $mode == 'live' ? 'Producton' : 'Sandbox';
if ($this->merchant_id == '' || $this->private_key == '' || $this->publishable_key == '') {
$settings = new WC_Admin_Settings();
$settings->add_error('You need to enter "' . $env . '" credentials if you want to use this plugin in this mode.');
} else {
$this->createWebhook();
}
return parent::process_admin_options();
}
示例14: is_available
/**
* Disables the gateway under any of these conditions:
* 1) If the cart does not contain a pre-order
* 2) If the pre-order amount is charged upfront
* 3) On the pay page
*
* @since 1.0
* @return bool
*/
public function is_available()
{
$is_available = parent::is_available();
// on checkout page
if (!is_page(woocommerce_get_page_id('pay')) || defined('WOOCOMMERCE_CHECKOUT') && WOOCOMMERCE_CHECKOUT) {
// not available if the cart does not contain a pre-order
if (WC_Pre_Orders_Cart::cart_contains_pre_order()) {
// not available when the pre-order amount is charged upfront
if (WC_Pre_Orders_Product::product_is_charged_upfront(WC_Pre_Orders_Cart::get_pre_order_product())) {
$is_available = false;
}
} else {
$is_available = false;
}
} else {
// not available on the pay page (for now)
$is_available = false;
}
return $is_available;
}
示例15: process_admin_options
public function process_admin_options()
{
$target_dir = IMAGE_FOLDER_URL;
$target_file = $target_dir . basename($_FILES["woocommerce_Pwacheckout_pwa_btn_img"]["name"]);
if ($_FILES["woocommerce_Pwacheckout_pwa_btn_img"]["name"]) {
try {
move_uploaded_file($_FILES["woocommerce_Pwacheckout_pwa_btn_img"]["tmp_name"], $target_file);
chmod($target_file, 0777);
} catch (Exception $e) {
echo 'error in uploading file';
}
}
$value = isset($_POST['woocommerce_Pwacheckout_pwa_delete_img']) ? $_POST['woocommerce_Pwacheckout_pwa_delete_img'] : 0;
if (!$value && $_FILES['woocommerce_Pwacheckout_pwa_btn_img']['name']) {
$_POST['woocommerce_Pwacheckout_pwa_btn_img_hidden'] = IMAGE_FOLDER_HTTPURL . $_FILES['woocommerce_Pwacheckout_pwa_btn_img']['name'];
} elseif ($value) {
$_POST['woocommerce_Pwacheckout_pwa_btn_img_hidden'] = '';
}
$_POST['woocommerce_Pwacheckout_pwa_delete_img'] = 0;
parent::process_admin_options();
}