public function __construct($client_id, $amount, $currency) { if (paymill_BENCHMARK) { paymill_doBenchmark(true, 'paymill_payment'); } // benchmark load_paymill(); // this function-call can and should be used whenever working with Paymill API if ($this->paymentData === false) { try { $GLOBALS['paymill_loader']->request_payment->setToken($_POST['paymillToken']); $GLOBALS['paymill_loader']->request_payment->setClient($client_id); $this->paymentData = $GLOBALS['paymill_loader']->request->create($GLOBALS['paymill_loader']->request_payment); // Use this for further payment processing if (is_object($this->paymentData) && $this->paymentData->getType() == 'creditcard') { $GLOBALS['paymill_loader']->request_preauth->setPayment($this->getPaymentID()); $GLOBALS['paymill_loader']->request_preauth->setAmount(round($amount)); $GLOBALS['paymill_loader']->request_preauth->setCurrency($currency); $this->preauthData = $GLOBALS['paymill_loader']->request->create($GLOBALS['paymill_loader']->request_preauth); // Use this for further payment processing, too } } catch (Exception $e) { $GLOBALS['paymill_loader']->paymill_errors->setError(__($e->getMessage(), 'paymill')); } } if (paymill_BENCHMARK) { paymill_doBenchmark(false, 'paymill_payment'); } // benchmark }
public function __construct() { load_paymill(); // this function-call can and should be used whenever working with Paymill API $GLOBALS['paymill_loader']->paymill_errors->setFunction('paymill_cart66_errorHandling'); $GLOBALS['paymill_source']['cart66_version'] = CART66_VERSION_NUMBER; }
public function __construct($client_email, $client_desc) { global $wpdb; load_paymill(); // this function-call can and should be used whenever working with Paymill API $client = false; // get client cache $sql = $wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'paymill_clients WHERE paymill_client_email=%s', array($client_email)); $client_cache = $wpdb->get_results($sql, ARRAY_A); if (count($client_cache) > 0 && ($client_cache[0]['paymill_client_email'] != $client_email || $client_cache[0]['paymill_client_description'] != $client_desc)) { // update client in paymill $GLOBALS['paymill_loader']->request_client->setId($client_cache[0]['paymill_client_id']); $GLOBALS['paymill_loader']->request_client->setEmail($client_email); $GLOBALS['paymill_loader']->request_client->setDescription($client_desc); // @todo: handle response $client = $GLOBALS['paymill_loader']->request->update($GLOBALS['paymill_loader']->request_client); // update local cache $wpdb->query($wpdb->prepare('UPDATE ' . $wpdb->prefix . 'paymill_clients SET paymill_client_description=%s WHERE paymill_client_email=%s', array($client_desc, $client_email))); do_action('paymill_paybutton_client_updated', array('client' => $client, 'client_email' => $client_email, 'client_desc' => $client_desc)); // try loading the client } elseif (count($client_cache) > 0) { try { $GLOBALS['paymill_loader']->request_client->setId($client_cache[0]['paymill_client_id']); $client = $GLOBALS['paymill_loader']->request->getOne($GLOBALS['paymill_loader']->request_client); } catch (Exception $e) { } // client does not exist in Paymill, so create } if ($client == false) { try { $GLOBALS['paymill_loader']->request_client = new $GLOBALS['paymill_loader']->request_client(); $GLOBALS['paymill_loader']->request_client->setEmail($client_email); $GLOBALS['paymill_loader']->request_client->setDescription($client_desc); // @todo: handle response $client = $GLOBALS['paymill_loader']->request->create($GLOBALS['paymill_loader']->request_client); } catch (Exception $e) { $GLOBALS['paymill_loader']->paymill_errors->setError(__($e->getMessage(), 'paymill')); } // insert new client in local cache if (get_current_user_id()) { $user_id = get_current_user_id(); } else { $user_id = 0; } $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'paymill_clients WHERE wp_member_id="%s"', array($user_id))); $sql = $wpdb->prepare('INSERT INTO ' . $wpdb->prefix . 'paymill_clients SET paymill_client_id="%s", paymill_client_email="%s", paymill_client_description="%s", wp_member_id="%s"', array($client->getId(), $client_email, $client_desc, $user_id)); $wpdb->query($sql); do_action('paymill_paybutton_client_created', array('client' => $client, 'client_email' => $client_email, 'client_desc' => $client_desc)); } $this->client = $client; }
function __construct() { parent::__construct(); load_paymill(); // this function-call can and should be used whenever working with Paymill API $GLOBALS['paymill_loader']->paymill_errors->setFunction('paymill_shopp_errorHandling'); if (!isset($this->settings['label'])) { $this->settings['label'] = 'Paymill'; } add_action('shopp_paymillshopp_sale', array(&$this, 'sale')); // Process sales $GLOBALS['paymill_source']['shopp_version'] = SHOPP_VERSION; }
function mgm_paymill() { load_paymill(); // this function-call can and should be used whenever working with Paymill API $GLOBALS['paymill_loader']->paymill_errors->setFunction('paymill_mgm_errorHandling'); // parent parent::__construct(); // set code $this->code = __CLASS__; // set module $this->module = str_replace('mgm_', '', $this->code); // set name $this->name = 'Paymill'; // logo $this->logo = plugins_url('', PAYMILL_DIR . 'paymill.php') . '/lib/img/logo.png'; // description $this->description = __('PAYMILL - Online payments made easy', 'paymill'); // supported buttons types $this->supported_buttons = array('subscription', 'buypost'); // trial support available ? $this->supports_trial = 'Y'; // cancellation support available ? $this->supports_cancellation = 'Y'; // do we depend on product mapping $this->requires_product_mapping = 'N'; // type of integration $this->hosted_payment = 'Y'; // credit card process onsite // if supports rebill status check $this->supports_rebill_status_check = 'N'; // default settings $this->_default_setting(); // set path parent::set_tmpl_path(PAYMILL_DIR . 'lib/tpl/mgm/'); // read settings $this->read(); }
public function __construct() { load_paymill(); // this function-call can and should be used whenever working with Paymill API $GLOBALS['paymill_loader']->paymill_errors->setFunction('paymill_woocommerce_errorHandling'); $GLOBALS['paymill_source']['woocommerce_version'] = isset($GLOBALS['woocommerce']) && is_object($GLOBALS['woocommerce']) && isset($GLOBALS['woocommerce']->version) ? $GLOBALS['woocommerce']->version : 0; $this->id = 'paymill'; $this->icon = plugins_url('', __FILE__) . '/../img/icon.png'; $this->logo = plugins_url('', __FILE__) . '/../img/logo.png'; $this->logo_small = plugins_url('', __FILE__) . '/../img/logo_small.png'; $this->has_fields = true; add_action('woocommerce_update_options_payment_gateways_' . $this->id, array(&$this, 'process_admin_options')); $this->has_fields = true; $this->init_form_fields(); $this->init_settings(); $this->title = $this->settings['title']; $this->description = $this->settings['description']; $this->supports = array('products', 'subscriptions', 'subscription_cancellation', 'subscription_suspension', 'subscription_reactivation'); }
/** constructor */ function __construct() { parent::WP_Widget('paymill_pay_button_widget', 'Paymill Pay Button', array('description' => __('Shows a Paymill Payment Button.', 'paymill'))); load_paymill(); // this function-call can and should be used whenever working with Paymill API $GLOBALS['paymill_loader']->paymill_errors->setFunction('paymill_pay_button_errorHandling'); }
function paymill_install() { load_paymill(); // this function-call can and should be used whenever working with Paymill API global $wpdb; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; if ($wpdb->get_var('SHOW TABLES LIKE ' . $wpdb->prefix . 'paymill_clients') == $wpdb->prefix . 'paymill_clients') { $wpdb->query('ALTER TABLE ' . $wpdb->prefix . 'paymill_clients DROP INDEX paymill_client_id'); //$wpdb->query('ALTER TABLE `'.$wpdb->prefix.'paymill_clients` ADD INDEX wp_member_id(`wp_member_id`)'); } $sql = 'CREATE TABLE ' . $wpdb->prefix . 'paymill_clients ( paymill_client_id varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, paymill_client_email varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, paymill_client_description longtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, wp_member_id int(11) NOT NULL, UNIQUE KEY wp_member_id (paymill_client_id,wp_member_id));'; $sql .= 'CREATE TABLE ' . $wpdb->prefix . 'paymill_transactions ( paymill_transaction_id varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, paymill_payment_id varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, paymill_client_id varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, paymill_transaction_time int(11) NOT NULL, paymill_transaction_data longtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, woocommerce_order_id int(11) NOT NULL, pay_button_order_id int(11) NOT NULL, shopplugin_order_id int(11) NOT NULL, marketpress_order_id int(11) NOT NULL, UNIQUE KEY paymill_transaction_id (paymill_transaction_id));'; $sql .= 'CREATE TABLE ' . $wpdb->prefix . 'paymill_cache_offers ( `id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `name` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `amount` int(11) NOT NULL, `currency` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `interval` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `trial_period_days` int(11) NOT NULL, UNIQUE KEY id (id));'; $sql .= 'CREATE TABLE ' . $wpdb->prefix . 'paymill_subscriptions ( paymill_sub_id varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, woo_user_id varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, woo_offer_id varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, mgm_user_id varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, mgm_offer_id varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, UNIQUE KEY paymill_sub_id (paymill_sub_id));'; dbDelta($sql); // get webhooks list /*$GLOBALS['paymill_loader']->request_webhook->setId(get_option('paymill_webhook_id')); $webhook = $GLOBALS['paymill_loader']->request->getOne($GLOBALS['paymill_loader']->request_webhook);*/ if (!get_option('paymill_db_version')) { add_option('paymill_db_version', PAYMILL_VERSION); } elseif (get_option('paymill_db_version') != PAYMILL_VERSION) { update_option('paymill_db_version', PAYMILL_VERSION); } }
public function offerCreate($params) { if (paymill_BENCHMARK) { paymill_doBenchmark(true, 'paymill_subscription_offerCreate'); } // benchmark load_paymill(); // this function-call can and should be used whenever working with Paymill API try { $GLOBALS['paymill_loader']->request_offer->setAmount(round($params['amount'])); $GLOBALS['paymill_loader']->request_offer->setCurrency($params['currency']); $GLOBALS['paymill_loader']->request_offer->setInterval($params['interval']); $GLOBALS['paymill_loader']->request_offer->setName($params['name']); $GLOBALS['paymill_loader']->request_offer->setTrialPeriodDays($params['trial_period_days']); $output = $GLOBALS['paymill_loader']->request->create($GLOBALS['paymill_loader']->request_offer); $offerID = $output->getId(); $this->offerGetList(true); //$output = $this->offerGetDetailByID($offerID); $output = $offerID; } catch (Exception $e) { $GLOBALS['paymill_loader']->paymill_errors->setError(__($e->getMessage(), 'paymill')); $output = false; } if (paymill_BENCHMARK) { paymill_doBenchmark(false, 'paymill_subscription_offerCreate'); } // benchmark return $output; }
<?php // this is required for getting API work spl_autoload_register(function ($class) { load_paymill(); // this function-call can and should be used whenever working with Paymill API $GLOBALS['paymill_loader']->load_class_file($class); }); // there may be more elegant ways for autoloading, but I'm new to namespaces and I'm rare of time atm. // @todo: review for better way of autoloading Paymill API classes. class paymill_loader { public $translation = array('request' => array('lib/api/lib/Paymill/Request.php', 'Paymill\\Request'), 'request_client' => array('lib/api/lib/Paymill/Models/Request/Client.php', 'Paymill\\Models\\Request\\Client'), 'request_offer' => array('lib/api/lib/Paymill/Models/Request/Offer.php', 'Paymill\\Models\\Request\\Offer'), 'request_payment' => array('lib/api/lib/Paymill/Models/Request/Payment.php', 'Paymill\\Models\\Request\\Payment'), 'request_preauth' => array('lib/api/lib/Paymill/Models/Request/Preauthorization.php', 'Paymill\\Models\\Request\\Preauthorization'), 'request_refund' => array('lib/api/lib/Paymill/Models/Request/Refund.php', 'Paymill\\Models\\Request\\Refund'), 'request_subscription' => array('lib/api/lib/Paymill/Models/Request/Subscription.php', 'Paymill\\Models\\Request\\Subscription'), 'request_transaction' => array('lib/api/lib/Paymill/Models/Request/Transaction.php', 'Paymill\\Models\\Request\\Transaction'), 'request_webhook' => array('lib/api/lib/Paymill/Models/Request/Webhook.php', 'Paymill\\Models\\Request\\Webhook'), 'response_base' => array('lib/api/lib/Paymill/Models/Response/Base.php'), 'response_client' => array('lib/api/lib/Paymill/Models/Response/Client.php', 'Paymill\\Models\\Response\\Client'), 'response_error' => array('lib/api/lib/Paymill/Models/Response/Error.php', 'Paymill\\Models\\Response\\Error'), 'response_offer' => array('lib/api/lib/Paymill/Models/Response/Offer.php', 'Paymill\\Models\\Response\\Offer'), 'response_payment' => array('lib/api/lib/Paymill/Models/Response/Payment.php', 'Paymill\\Models\\Response\\Payment'), 'response_preauth' => array('lib/api/lib/Paymill/Models/Response/Preauthorization.php', 'Paymill\\Models\\Response\\Preauthorization'), 'response_refund' => array('lib/api/lib/Paymill/Models/Response/Refund.php', 'Paymill\\Models\\Response\\Refund'), 'response_subscription' => array('lib/api/lib/Paymill/Models/Response/Subscription.php', 'Paymill\\Models\\Response\\Subscription'), 'response_transaction' => array('lib/api/lib/Paymill/Models/Response/Transaction.php', 'Paymill\\Models\\Response\\Transaction'), 'response_webhook' => array('lib/api/lib/Paymill/Models/Response/Webhook.php', 'Paymill\\Models\\Response\\Webhook'), 'Paymill\\Models\\Response\\Base' => array('lib/api/lib/Paymill/Models/Response/Base.php'), 'Paymill\\Services\\Util' => array('lib/api/lib/Paymill/Services/Util.php'), 'Paymill\\Models\\Response\\Client' => array('lib/api/lib/Paymill/Models/Response/Client.php', 'Paymill\\Models\\Response\\Client'), 'Paymill\\Models\\Response\\Error' => array('lib/api/lib/Paymill/Models/Response/Error.php', 'Paymill\\Models\\Response\\Error'), 'Paymill\\Models\\Response\\Offer' => array('lib/api/lib/Paymill/Models/Response/Offer.php', 'Paymill\\Models\\Response\\Offer'), 'Paymill\\Models\\Response\\Payment' => array('lib/api/lib/Paymill/Models/Response/Payment.php', 'Paymill\\Models\\Response\\Payment'), 'Paymill\\Models\\Response\\Preauthorization' => array('lib/api/lib/Paymill/Models/Response/Preauthorization.php', 'Paymill\\Models\\Response\\Preauthorization'), 'Paymill\\Models\\Response\\Refund' => array('lib/api/lib/Paymill/Models/Response/Refund.php', 'Paymill\\Models\\Response\\Refund'), 'Paymill\\Models\\Response\\Subscription' => array('lib/api/lib/Paymill/Models/Response/Subscription.php', 'Paymill\\Models\\Response\\Subscription'), 'Paymill\\Models\\Response\\Transaction' => array('lib/api/lib/Paymill/Models/Response/Transaction.php', 'Paymill\\Models\\Response\\Transaction'), 'Paymill\\Models\\Response\\Webhook' => array('lib/api/lib/Paymill/Models/Response/Webhook.php', 'Paymill\\Models\\Response\\Webhook'), 'paymill_errors' => array('lib/errors.inc.php', 'paymill_errors')); public function __construct() { // make sure to load some dependencies require_once PAYMILL_DIR . 'lib/api/lib/Paymill/API/CommunicationAbstract.php'; require_once PAYMILL_DIR . 'lib/api/lib/Paymill/API/Curl.php'; require_once PAYMILL_DIR . 'lib/api/lib/Paymill/Models/Request/Base.php'; require_once PAYMILL_DIR . 'lib/api/lib/Paymill/Models/Response/Error.php'; require_once PAYMILL_DIR . 'lib/api/lib/Paymill/Services/PaymillException.php'; require_once PAYMILL_DIR . 'lib/api/lib/Paymill/Services/ResponseHandler.php'; } public function __get($name) { return $this->load_class($name); } public function load_class($name) { if ($this->load_class_file($name)) { return $this->init_class($name);
/** * Runs when your class is instantiated. Use to setup your plugin instead of __construct() */ function on_creation() { global $mp; $settings = get_option('mp_settings'); //set names here to be able to translate $this->admin_name = __('Paymill for WordPress', 'paymill'); $this->public_name = $settings['gateways']['paymill-for-wordpress']['name'] ? $settings['gateways']['paymill-for-wordpress']['name'] : 'Paymill'; //button img $this->method_img_url = $this->method_button_img_url = $settings['gateways']['paymill-for-wordpress']['image-url']; load_paymill(); // this function-call can and should be used whenever working with Paymill API $GLOBALS['paymill_loader']->paymill_errors->setFunction('paymill_marketpress_errorHandling'); $GLOBALS['paymill_source']['marketpress_version'] = $mp->version; }