예제 #1
0
function woo_reactivated_subscription_paymill($order, $product_id)
{
    global $wpdb;
    $client_cache = $wpdb->get_results($wpdb->prepare('SELECT paymill_sub_id FROM ' . $wpdb->prefix . 'paymill_subscriptions WHERE woo_user_id=%s AND woo_offer_id=%s', array($order->user_id, $order->id . '_' . $product_id)), ARRAY_A);
    if (!isset($client_cache[0]['paymill_sub_id'])) {
        error_log("could not find paymill sub while trying to reactivate {$order->user_id} {$order->id} {$product_id}");
    }
    $subscriptions = new paymill_subscriptions('woocommerce');
    $subscriptions->unpause($client_cache[0]['paymill_sub_id']);
    error_log("\n\n########################################################################################################################\n\n", 3, PAYMILL_DIR . 'lib/debug/PHP_errors.log');
    error_log(date(DATE_RFC822) . ' - Subscription ' . $client_cache[0]['paymill_sub_id'] . ' from order ' . $order . ' with product ' . $product_id . ' reactivated through function woo_reactivated_subscription_paymill' . "\n\n", 3, PAYMILL_DIR . 'lib/debug/PHP_errors.log');
    error_log("\n\n########################################################################################################################\n\n", 3, PAYMILL_DIR . 'lib/debug/PHP_errors.log');
}
예제 #2
0
    private function print_config_form_fields($args)
    {
        if (paymill_BENCHMARK) {
            paymill_doBenchmark(true, 'paymill_field_pay_button_option');
        }
        // benchmark
        // setup of value fields
        $option = '';
        $value = '';
        $id = '';
        $page = $args['page'];
        if (isset($args['desc']) && empty($args['id'])) {
            $option = '[' . $args['desc'] . ']';
            if (isset($this->{$page}[$args['desc']])) {
                if (isset($args['group'])) {
                    $value = esc_attr($this->{$page}[$args['group']][$args['desc']]);
                } else {
                    $value = esc_attr($this->{$page}[$args['desc']]);
                }
            }
        } elseif (isset($args['id']) && isset($args['desc'][$args['id']])) {
            $option = '[' . $args['group'] . '][' . $args['id'] . '][' . $args['desc'] . ']';
            if (isset($args['group'])) {
                if (isset($this->{$page}[$args['group']][$args['id']][$args['desc']])) {
                    $value = esc_attr($this->{$page}[$args['group']][$args['id']][$args['desc']]);
                } else {
                    $value = '';
                }
            } else {
                if (isset($this->{$page}[$args['id']][$args['desc']])) {
                    $value = esc_attr($this->{$page}[$args['id']][$args['desc']]);
                } else {
                    $value = '';
                }
            }
        } else {
            $value = '';
        }
        // show settings
        $descriptions['payments_display'] = __('Check the boxes which payment types should be announced on payment form', 'paymill');
        $descriptions['products_desc'] = __('Detailed description of the product', 'paymill');
        $descriptions['products_price'] = __('Gross Price of the product, e.g. 40 or 6.99', 'paymill');
        $descriptions['products_offer'] = __('If you have created a subscription in your <a href="https://app.paymill.com/de-de#!/offers">Paymill Cockpit</a>, you can select it here. If selected, it will overwrite the following settings for this product. Important: For Performance purposes, subscription plans will be cached. Open this page to recache it.', 'paymill');
        $descriptions['products_vat'] = __('Value-Added-Tax Rate in &#37; for the product, e.g. 19 or 7', 'paymill');
        $descriptions['products_delivery'] = __('Delivery Time of the product, e.g. 2 Days or 1 Week', 'paymill');
        $descriptions['products_quantityhide'] = __('Hide quantity select field, quantity will be set to 1', 'paymill');
        $descriptions['products_freeamount'] = __('Allow free amounts (donation feature)', 'paymill');
        if ($args['desc'] == 'payments_display') {
            echo $descriptions[$args['desc']] . '<br />';
            $payment_types = array('amex', 'cb', 'dc', 'discover', 'elv', 'jcb', 'maestro', 'mastercard', 'sepa', 'unionpay', 'visa');
            foreach ($payment_types as $type) {
                if (isset($this->{$page}[$args['desc']][$type])) {
                    $checked = esc_attr($this->{$page}[$args['desc']][$type]);
                } else {
                    $checked = false;
                }
                echo '
					<fieldset style="float:left;margin-right:20px;">
						<label for="' . $this->setting_keys[$page] . '[' . $args['desc'] . '][' . $type . ']">
						<input
							' . ($checked == 1 ? 'checked="checked"' : '') . '
							type="checkbox"
							name="' . $this->setting_keys[$page] . '[' . $args['desc'] . '][' . $type . ']"
							id="' . $this->setting_keys[$page] . '[' . $args['desc'] . '][' . $type . ']"
							value="1" />
							
							<img src="' . plugins_url('', __FILE__) . '/img/logos/' . $type . '.png" style="vertical-align:middle;" alt="' . $type . '" />
						</label><br />
					</fieldset>
					';
            }
        } elseif ($args['desc'] == 'products_offer') {
            // products_offer
            $subscriptions = new paymill_subscriptions('pay_button');
            $offers = $subscriptions->offerGetList(true);
            if (count($offers) > 0) {
                echo '<select class="regular-text code" name="' . $this->setting_keys[$page] . $option . $id . '">';
                echo '<option value="">' . __('Optional: Select Subscription Plan', 'paymill') . '</option>';
                foreach ($offers as $offer) {
                    if ($value == $offer['id']) {
                        $selected = ' selected="selected"';
                    } else {
                        $selected = '';
                    }
                    echo '
						<option value="' . $offer['id'] . '"' . $selected . '>' . $offer['name'] . ' / ' . $offer['amount'] / 100 . ' ' . $offer['currency'] . ' / ' . __($offer['interval'], 'paymill') . '</option>
					';
                }
                echo '</select>';
            }
        } elseif ($args['desc'] == 'products_quantityhide' || $args['desc'] == 'no_default_css') {
            // products_quantityhide, no_default_css
            echo '
					<input
					type="checkbox"
					name="' . $this->setting_keys[$page] . $option . '"
					value="1"
					class="regular-text code" ' . ($value ? 'checked="checked"' : '') . ' />
				';
        } elseif ($args['desc'] == 'pci_dss_3') {
            // pci_dss_3
            echo '
					<select name="' . $this->setting_keys[$page] . $option . '">
						<option value="0">' . __('embedded PayFrame (requires PCI SAQ A)', 'paymill') . '</option>
						<option value="1"' . ($value ? ' selected="selected"' : '') . '>' . __('direct integration (requires PCI SAQ A-EP)', 'paymill') . '</option>
					</select>
				';
        } elseif ($args['desc'] == 'fields_show') {
            echo __('You may want to gather some additional information from your customers. Select them here:', 'paymill') . '<br />';
            $fields_show = array('shipping', 'company_name', 'forename', 'surname', 'street', 'number', 'state', 'zip', 'city', 'phone');
            foreach ($fields_show as $field) {
                if (isset($this->{$page}[$args['desc']][$field])) {
                    $checked = esc_attr($this->{$page}[$args['desc']][$field]);
                } else {
                    $checked = false;
                }
                echo '
					<fieldset style="float:left;margin-right:20px;">
						<label for="' . $this->setting_keys[$page] . '[' . $args['desc'] . '][' . $field . ']">
						<input
							' . ($checked == 1 ? 'checked="checked"' : '') . '
							type="checkbox"
							name="' . $this->setting_keys[$page] . '[' . $args['desc'] . '][' . $field . ']"
							id="' . $this->setting_keys[$page] . '[' . $args['desc'] . '][' . $field . ']"
							value="1" />
							' . __($field, 'paymill') . '
						</label><br />
					</fieldset>
					';
            }
            echo '<div style="clear:both;"></div>';
        } else {
            echo '
					<input
					type="text"
					name="' . $this->setting_keys[$page] . $option . '"
					value="' . $value . '"
					class="regular-text code" />
				';
        }
        if (paymill_BENCHMARK) {
            paymill_doBenchmark(false, 'paymill_field_pay_button_option');
        }
        // benchmark
    }