function module_setting_box() { // make local extract($_REQUEST); // get module $module_class = mgm_get_module($module, 'payment'); // load settings box echo $module_class->settings_box(); }
function module_settings() { // make local extract($_REQUEST); // get module $module_class = mgm_get_module($module, 'autoresponder'); // update if (isset($update) && $update == 'true') { // settings update echo $module_class->settings_update(); } else { // load settings form $module_class->settings(); } }
/** * Callback for payment_gateways field * prints all active modules, javascript callback and json data shows per pack * or filtered * * @param array $field * @param string $name * @param string $value * @return string */ function field_payment_gateways_callback($field, $name, $value) { // display as $dispaly_as_selectbox = $this->_get_subscription_options_as(); //check subscription options custom_field is enabled: $continue = false; // cf $obj_customfields = mgm_get_class('member_custom_fields'); // subo $arr_sub_options = $obj_customfields->get_field_by_name('subscription_options'); // check if (isset($arr_sub_options['id']) && !empty($obj_customfields->sort_orders) && in_array($arr_sub_options['id'], $obj_customfields->sort_orders)) { $continue = true; } // return if (!$continue) { return ''; } $system_obj = mgm_get_class('system'); // args $args = $this->get_config('args', array()); // selected_subscription $selected_subs = mgm_get_selected_subscription($args); // get active modules $a_payment_modules = $system_obj->get_active_modules('payment'); /* @todo deprecate load here since gateways are loaded for post purchase also // get modules for packs: $allpacks = mgm_get_class('subscription_packs')->get_packs(); // init $pack_modules = array(); // loop foreach ($allpacks as $allp) { // reset $include = mgm_select_subscription($allp,$selected_subs); // skip other when a package sent as selected if($selected_subs !== false){ if(empty($include)) continue; } //issue #1532 if(is_array($allp['modules'])){ $pack_modules = array_merge($pack_modules,$allp['modules']); } } // pack $pack_modules = array_unique($pack_modules); mgm_pr($pack_modules);*/ // payment modules $payment_modules = array(); // loop if (!empty($a_payment_modules)) { // loop foreach ($a_payment_modules as $payment_module) { // not trial if (in_array($payment_module, array('mgm_free', 'mgm_trial'))) { continue; } // included modules // if( ! in_array($payment_module, $pack_modules) ) continue; // store $payment_modules[] = $payment_module; } } // make unique $payment_modules = apply_filters('mgm_payment_gateways_as_custom_field', array_unique($payment_modules)); // check count $module_count = count($payment_modules); // one active $hide_div = $module_count === 1 ? 'style="display:none;"' : ''; // NOTE: uncomment the below line to enable module display even if only one exists // $hide_div = ""; // NOTE: do not change the id: mgm_payment_gateways_container $html = sprintf('<div id="mgm_payment_gateways_container" class="mgm_payment_wrapper" %s >', $hide_div); //loop through payment modules: if ($module_count == 0) { $html .= sprintf('<div>%s</div>', __('No active payment module', 'mgm')); } else { //print each module: foreach ($payment_modules as $payment_module) { //checked: if(selected/only one gateway exists) if (isset($_POST['mgm_payment_gateways'])) { $checked = $payment_module == $_POST['mgm_payment_gateways'] ? 'checked="true"' : ''; } else { $checked = !empty($value) && $value == $field['value'] || $module_count === 1 ? 'checked="true"' : ''; } // get obj $mod_obj = mgm_get_module($payment_module, 'payment'); // html $img_url = mgm_site_url($mod_obj->logo); // desc $description = mgm_stripslashes_deep($mod_obj->description); //module description $html .= sprintf('<div id="%s_container" class="mgm_payment_opt_wrapper" %s> <input type="radio" %s class="checkbox" name="mgm_payment_gateways" value="%s" alt="%s" /> <img class="mgm_payment_opt_customfield_image" src="%s" alt="%s" /> <div class="mgm_paymod_description">%s</div> </div>', $mod_obj->code, $hide_div, $checked, $mod_obj->code, $mod_obj->name, $img_url, $mod_obj->name, $description); } // scripts required for pack buttons: // $packs_obj = mgm_get_class('subscription_packs'); // packs // $packs = $packs_obj->get_packs('register'); // $lf = "\n"; //script to show/hide appicable module buttons $html .= '<script type="text/javascript">jQuery(document).ready(function() {' . PHP_EOL; // bind as needed if ($dispaly_as_selectbox) { $html .= 'jQuery("select[rel=\'mgm_subscription_options\']").bind("change", function(){ mgm_select_pack_modules("select"); }).change();' . PHP_EOL; } else { $html .= 'jQuery(":input[rel=\'mgm_subscription_options\']").bind("click", function(){ mgm_select_pack_modules("radio"); });' . PHP_EOL; $html .= 'mgm_select_pack_modules("' . ($dispaly_as_selectbox ? 'select' : 'radio') . '");' . PHP_EOL; // @todo consider SELECT } // end $html .= '});</script>' . PHP_EOL; } // end $html .= '</div>'; // return return $html; }
<?php /** * Objects merge/update * Add worldpay gateway_successpage and gateway_failedpage settings */ // read $worldpay = mgm_get_module('worldpay', 'payment'); if (isset($worldpay->setting['gateway_successpage'])) { $worldpay->setting['gateway_successpage'] = '<html> <head> <meta http-equiv="refresh" content="<WPDISPLAY ITEM=MC_redirectin>;url=<WPDISPLAY ITEM=MC_success>" /> <title>Thank you for your payment</title> </head> <WPDISPLAY FILE=header.html DEFAULT="<body bgcolor=#ffffff>"> <h1><WPDISPLAY ITEM=MC_sitename></h1> <WPDISPLAY ITEM=name>, thank you for your payment of <WPDISPLAY ITEM=amountString> for <WPDISPLAY ITEM=desc> <div>Click <a href="<WPDISPLAY ITEM=MC_success>"><strong>here</strong></a> to return to the site if you are not redirected within <WPDISPLAY ITEM=MC_redirectin> seconds</div> <WPDISPLAY ITEM=banner> <WPDISPLAY FILE=footer.html DEFAULT="</body>"> </html>'; $worldpay->save(); } // end file
/** * Cancel Recurring Subscription * This is not a private function * @param int/string $trans_ref * @param int $user_id * @param int/string $subscr_id * @param int $pack_id * @return boolean */ function cancel_recurring_subscription($trans_ref = null, $user_id = null, $subscr_id = null, $pack_id = null) { //if coming form process return after a subscription payment if (!empty($trans_ref)) { $transdata = $this->_get_transaction_passthrough($trans_ref); if ($transdata['payment_type'] != 'subscription_purchase') { return false; } $user_id = $transdata['user_id']; if (isset($transdata['is_another_membership_purchase']) && $transdata['is_another_membership_purchase'] == 'Y') { $member = mgm_get_member_another_purchase($user_id, $transdata['membership_type']); } else { $member = mgm_get_member($user_id); } if (isset($member->payment_info->module) && !empty($member->payment_info->module)) { if (isset($member->payment_info->subscr_id)) { $subscr_id = $member->payment_info->subscr_id; } else { //check pack is recurring: $pid = $pack_id ? $pack_id : $member->pack_id; if ($pid) { $s_packs = mgm_get_class('subscription_packs'); $sel_pack = $s_packs->get_pack($pid); if ($sel_pack['num_cycles'] != 1) { $subscr_id = 0; } } } //check for same module: if not call the same function of the applicale module. if (str_replace('mgm_', '', $member->payment_info->module) != str_replace('mgm_', '', $this->code)) { mgm_log('RECALLing ' . $member->payment_info->module . ': cancel_recurring_subscription FROM: ' . $this->code); return mgm_get_module($member->payment_info->module, 'payment')->cancel_recurring_subscription($trans_ref, null, null, $pack_id); } //skip if same pack is updated if (empty($member->pack_id) || is_numeric($pack_id) && $pack_id == $member->pack_id) { return false; } } else { return false; } } else { if ($this->setting['aquirer'] != 'sisow') { // skip sisow return false; //skip as trans reff will need to be passed always } } //only for subscription_purchase if ($this->setting['aquirer'] == 'sisow') { if (!isset($member)) { $member = mgm_get_member($user_id); } $txn_id = $member->payment_info->txn_id; //mgm_pr($member); // endpoint $endpoint = $this->_get_endpoint(); // set $endpoint = str_replace('[action]', 'CancelReservationRequest', $endpoint); // keys $compute_keys = array($txn_id, $this->setting['merchant_id'], $this->setting['secret_key']); $compute_sha1 = sha1(implode('', $compute_keys)); $post_data = array('trxid' => $txn_id, 'merchantid' => $this->setting['merchant_id'], 'sha1' => $compute_sha1); // headers $http_headers = array(); //array('Content-Type' => 'text/xml'); //mgm_pr($post_data); die; // create curl post $http_response = mgm_remote_post($endpoint, $post_data, array('headers' => $http_headers, 'timeout' => 30, 'sslverify' => false)); mgm_log($http_response, __FUNCTION__); // parse if ($xml = @simplexml_load_string($http_response)) { mgm_log($xml, __FUNCTION__); // redirect to issuer if (isset($xml->reservation->status)) { return (string) $xml->reservation->status == 'Cancelled' ? true : false; } else { return false; } } } //send email only if setting enabled if (!empty($subscr_id) || $subscr_id === 0) { $system_obj = mgm_get_class('system'); $dge = bool_from_yn($system_obj->get_setting('disable_gateway_emails')); //send email only if setting enabled if (!$dge) { // blog $blogname = get_option('blogname'); // user $user = get_userdata($user_id); // notify admin mgm_notify_admin_membership_cancellation_manual_removal_required($blogname, $user, $member); } return true; } return false; }
/** * the meta box for post/page purchase * */ function mgm_post_setup_meta_box_form($post) { // get object $post_obj = mgm_get_post($post->ID); $datepickerformat = mgm_get_datepicker_format(); // set default price if ($post_obj->purchase_cost == 0) { if (mgm_get_module('mgm_paypal', 'payment')->setting['purchase_price']) { $post_obj->purchase_cost = mgm_get_module('mgm_paypal', 'payment')->setting['purchase_price']; } else { $post_obj->purchase_cost = mgm_get_class('system')->setting['post_purchase_price']; } } // protect $protect_content = mgm_protect_content(); //issue#: 414(changed id submitpost => submitpost_member for the below div ) ?> <div class="submitbox" id="submitpost_member"> <div class="misc-pub-section"> <p id="howto"> <?php _e('Select which membership types will have access to read this post/page.', 'mgm'); ?> <?php _e('Note: The private parts of the post should be inside the following tags: <strong>[private]</strong> <em>your text</em> <strong>[/private]</strong>', 'mgm'); ?> </p> <p> <div class="mgm_post_setup_meta_box_div"> <input type="checkbox" name="check_all" value="mgm_post[access_membership_types][]" /> <span><?php _e('Select all', 'mgm'); ?> </span> </div> </p> <p> <?php echo mgm_make_checkbox_group('mgm_post[access_membership_types][]', mgm_get_class('membership_types')->get_membership_types(), $post_obj->access_membership_types, MGM_KEY_VALUE); ?> </p> <?php if ($protect_content == false) { ?> <div class="information mgm_width_230px"><?php echo sprintf(__('<a href="%s">Content Protection</a> is <b>%s</b>. Make sure its enabled to Protect Post/Page.', 'mgm'), 'admin.php?page=mgm/admin', $protect_content ? 'enabled' : 'disabled'); ?> </div> <?php } ?> </div> <div class="misc-pub-section"> <b><?php _e('Pay Per Post', 'mgm'); ?> :</b> <a href="#payperpost" class="mgm-toggle"><?php _e('Edit'); ?> </a> <div id="payperpostdiv" class="hide-if-js"> <div class="mgm_padding_5px"> <p class="postpurhase-heading"><?php _e('Purchasable Settings', 'mgm'); ?> :</p> <ul class="mgm_post_setup_meta_box_ul"> <li> <label><?php _e('If the user doesn\'t have access, is this post/page available to buy?', 'mgm'); ?> </label><br/> <input type="radio" class="radio" name="mgm_post[purchasable]" value='N' <?php mgm_check_if_match('N', $post_obj->purchasable); ?> /> <label><?php _e('No', 'mgm'); ?> </label> <input type="radio" class="radio" name="mgm_post[purchasable]" value='Y' <?php mgm_check_if_match('Y', $post_obj->purchasable); ?> /> <label><?php _e('Yes', 'mgm'); ?> </label> </li> <li> <label><?php _e('Cost of Post?', 'mgm'); ?> </label><br> <input type="text" name="mgm_post[purchase_cost]" class="mgm_width_55px" value="<?php echo $post_obj->purchase_cost; ?> "/> <?php echo mgm_get_setting('currency'); ?> </li> <li> <label><?php _e('The date that the ability to buy this page/post expires (Leave blank for indefinate).', 'mgm'); ?> </label><br /> <input type="text" name="mgm_post[purchase_expiry]" class="date_input mgm_width_100px" value="<?php echo intval($post_obj->purchase_expiry) > 0 ? date(MGM_DATE_FORMAT_INPUT, strtotime($post_obj->purchase_expiry)) : ''; ?> "/> <span class="mgm_font_size_8px">(<?php echo $datepickerformat; ?> )</span> </li> <li> <label><?php _e('The number of days that the buyer will have access for (0 for indefinate).', 'mgm'); ?> </label><br /> <input type="text" name="mgm_post[access_duration]" class="mgm_width_50px" value="<?php echo $post_obj->get_access_duration(); ?> "/> </li> <li> <label><?php _e('The number of times that the buyer will have access for, "PAY PER VIEW" (0 for unlimited views).', 'mgm'); ?> </label><br /> <input type="text" name="mgm_post[access_view_limit]" class="mgm_width_50px" value="<?php echo $post_obj->get_access_view_limit(); ?> "/> </li> </ul> <?php if ($addons = mgm_get_all_addon_combo()) { ?> <p class="postpurhase-heading"><?php _e('Addon Settings', 'mgm'); ?> :</p> <ul class="mgm_post_setup_meta_box_ul"> <li> <label><?php _e('Allow Addons?', 'mgm'); ?> </label> <br /> <select name="mgm_post[addons][]" class="mgm_width_50px"> <option value="">-</option> <?php echo mgm_make_combo_options($addons, $post_obj->get_addons(), MGM_KEY_VALUE); ?> </select> </li> </ul> <?php } ?> <p class="postpurhase-heading"><?php _e('Payment Settings', 'mgm'); ?> :</p> <p class="fontweightbold"><?php _e('Allow Modules', 'mgm'); ?> :</p> <?php if ($payment_modules = mgm_get_class('system')->get_active_modules('payment')) { $modue_i = 0; foreach ($payment_modules as $payment_module) { if (!in_array($payment_module, array('mgm_trial'))) { ?> <input type="checkbox" name="mgm_post[allowed_modules][<?php echo $modue_i; ?> ]" value="<?php echo $payment_module; ?> " <?php echo in_array($payment_module, $post_obj->get_allowed_modules()) ? 'checked' : ''; ?> /> <label><?php echo mgm_get_module($payment_module)->name; ?> </label><br/> <?php $modue_i++; } } } else { ?> <b class="mgm_color_red"><?php _e('No payment module is active.', 'mgm'); ?> </b> <?php } ?> <?php // init $payment_settings = ''; // product id mapping if ($payment_modules) { foreach ($payment_modules as $payment_module) { if ($module = mgm_is_valid_module($payment_module, 'payment', 'object')) { if ($module->has_product_map()) { $payment_settings .= $module->settings_post_purchase($post_obj); } } } } // print if (!empty($payment_settings)) { echo $payment_settings; } ?> <?php do_action('mgm_widget_payperpost_options', $post->ID); ?> </div> </div> </div> <div class="misc-pub-section misc-pub-section-last"> <b><?php _e('Post Delay (sequential posts)', 'mgm'); ?> :</b> <a href="#postdelay" class="mgm-toggle"><?php _e('Edit'); ?> </a> <div id="postdelaydiv" class="hide-if-js"> <div class="mgm_padding_5px"> <p id="howto"><?php _e('How long should the user have been a member to see this content?', 'mgm'); ?> </p> <div class="div_table mgm_width_100pr"> <?php foreach (mgm_get_class('membership_types')->membership_types as $type_code => $type_name) { $val = isset($post_obj->access_delay[$type_code]) ? (int) $post_obj->access_delay[$type_code] : 0; ?> <div class="row"> <div class="cell mgm_width_100px mgm_font_size_11px"><?php echo $type_name; ?> </div> <div class="cell mgm_font_size_11px"> <input type="text" name="mgm_post[access_delay][<?php echo $type_code; ?> ]" value="<?php echo $val; ?> " class="mgm_width_50px"/> Day(s) </div> </div> <?php } ?> </div> </div> </div> </div> </div> <script language="javascript"> jQuery(document).ready(function(){ jQuery('.mgm-toggle').bind('click', function(){ if(jQuery(this).html() == '<?php _e('Edit', 'mgm'); ?> '){ jQuery(jQuery(this).attr('href')+'div').slideDown(); jQuery(this).html('<?php _e('Close', 'mgm'); ?> ') }else{ jQuery(jQuery(this).attr('href')+'div').slideUp(); jQuery(this).html('<?php _e('Edit', 'mgm'); ?> ') } }); // check bind jQuery("#submitpost_member :checkbox[name='check_all']").bind('click',function(){ // check jQuery("#submitpost_member :checkbox[name='"+jQuery(this).val()+"']").attr('checked', (jQuery(this).attr('checked')=='checked') ); // label if(jQuery(this).attr('checked')){ jQuery(this).next().html('<?php _e('Deselect all', 'mgm'); ?> '); }else{ jQuery(this).next().html('<?php _e('Select all', 'mgm'); ?> '); } }); // bind module allow jQuery(":checkbox[name^='mgm_post[allowed_modules]']").bind('click',function() { var _m = jQuery(this).val().replace('mgm_', ''); if(jQuery(this).attr('checked')){ jQuery('#settings_postpurchase_package_' + _m).slideDown('slow'); }else{ jQuery('#settings_postpurchase_package_' + _m).slideUp('slow'); } }); // date try{ mgm_date_picker('.date_input', false, {yearRange:"<?php echo mgm_get_calendar_year_range(); ?> ", dateFormat: "<?php echo $datepickerformat; ?> "}); }catch(ex){} }); </script> <?php }
/** * get payment processed page html * * @param void * @return string * @since 1.5 */ function mgm_get_payment_processed_page_html() { // home url $home_url = trailingslashit(get_option('siteurl')); // current module $module = mgm_request_var('module', '', true); // check if (!mgm_is_valid_module($module) || empty($module)) { // redirect mgm_redirect($home_url); } // init $html = ''; // refresh wait time $refresh_wait_time = 5; //in seconds // redirect url $redirect_url = ''; // redirect $do_redirect = true; // refresh header for post redirecr if (isset($_GET['post_redirect'])) { // redirect url $redirect_url = strip_tags($_GET['post_redirect']); } elseif (isset($_GET['register_redirect'])) { // redirect url, if 1/true, redirect to profile, else its register & redirect url if ($_GET['register_redirect'] != 1) { $redirect_url = strip_tags($_GET['register_redirect']); } else { // auto login $system_obj = mgm_get_class('system'); //issue# 1392 $current_user_id = get_current_user_id(); // check if set if ($autologin_redirect_url = $system_obj->get_setting('autologin_redirect_url')) { $page_title = ''; $redirect_url = $autologin_redirect_url; //short code support if (!empty($current_user_id)) { $user = get_userdata($current_user_id); $redirect_url = str_replace('[username]', $user->user_login, $redirect_url); } } elseif (mgm_get_user_package_redirect_url($current_user_id) && $current_user_id) { $page_title = ''; $redirect_url = mgm_get_user_package_redirect_url($current_user_id); } else { $page_title = 'Profile'; $redirect_url = mgm_get_custom_url('profile'); } } // check not logged in, #948 paypal fails to redirect if (!is_user_logged_in()) { // user login if (isset($_GET['trans_ref'])) { // re construct redirect url $redirect_url = mgm_get_custom_url('login', false, array('trans_ref' => strip_tags($_GET['trans_ref']), 'auto_login' => true, 'redirect_to' => $redirect_url)); } } } // check and set if (!empty($redirect_url) && $do_redirect) { // alter $redirect_url = apply_filters('mgm_register_redirect', $redirect_url); // no headers if (!headers_sent()) { @header(sprintf('Refresh: %d;url=%s', $refresh_wait_time, $redirect_url)); } else { $html .= sprintf('<script language="javascript">window.setTimeout(function(){window.location.href="%s";}, %d)</script>', $redirect_url, (int) $refresh_wait_time * 5); } } // module object $module_object = mgm_get_module($module, 'payment'); // [domain]/subscribe/?method=payment_processed&module=mgm_paypal&status=success // [domain]/subscribe/?method=payment_processed&module=mgm_paypal&status=cancel // status and message $arr_shortcodes = array('transaction_amount' => ''); // check if (!isset($_GET['status']) || $_GET['status'] == 'success') { // mgm_replace_oldlinks_with_tag is a patch for replacing the old link $message = $module_object->setting['success_message'] ? mgm_replace_oldlinks_with_tag($module_object->setting['success_message'], 'payment_success_message') : $system_obj->get_template('payment_success_message', array(), true); // get price if (isset($_GET['trans_ref'])) { // tarns $_GET['trans_ref'] = mgm_decode_id(strip_tags($_GET['trans_ref'])); // get transaction data $trans = mgm_get_transaction($_GET['trans_ref']); // set amount if ($trans['module'] == 'manualpay') { $arr_shortcodes['transaction_amount'] = $trans['data']['cost'] . ' ' . $trans['data']['currency']; } // update googe analytics: $html .= apply_filters('mgm_payment_processed_page_analytics', $trans); // @todo, callback in template function // mgm_update_google_analytics($trans); deprecated, use hook } } else { if (!isset($_GET['status']) || $_GET['status'] == 'cancel') { // set message $message = __('You have cancelled the transaction.', 'mgm'); } else { // mgm_replace_oldlinks_with_tag is a patch for replacing the old link $message = $module_object->setting['failed_message'] ? mgm_replace_oldlinks_with_tag($module_object->setting['failed_message'], 'payment_failed_message') : $system_obj->get_template('payment_failed_message', array(), true); } } // parse short codes: // [transaction_amount] = amount paid foreach ($arr_shortcodes as $code => $value) { $message = str_replace('[' . $code . ']', $value, $message); } // html $html .= mgm_stripslashes_deep(mgm_get_message_template($message)); // get error if (isset($_GET['errors'])) { // get errors $errors = explode('|', strip_tags($_GET['errors'])); // html $html .= sprintf('<h3> %s </h3><div><ul>', __('Messages', 'mgm')); // loop foreach ($errors as $error) { $html .= sprintf('<li> %s </li>', $error); } // end $html .= '</ul></div>'; } // auto redirect to post purchased if (isset($_GET['post_redirect'])) { // message $m = sprintf(__('You will be automatically redirected to the post you purchased within %d seconds. Please <a href="%s"> click here </a> to go to the page. ', 'mgm'), $refresh_wait_time, strip_tags($_GET['post_redirect'])); // set $html .= sprintf('<b>%s</b>', $m); } elseif (isset($_GET['register_redirect'])) { // auto login redirect // message $m = sprintf(__('You will be automatically redirected to your %s page within %d seconds. Please <a href="%s"> click here </a> to go to the page. ', 'mgm'), $_GET['register_redirect'] == 1 ? __($page_title, 'mgm') : __('Post', 'mgm'), $refresh_wait_time, $redirect_url); // set $html .= sprintf('<b>%s</b>', $m); } // return return apply_filters('mgm_payment_processed_page_html', $html); }
/** * Cancel Recurring Subscription * This is not a private function * @param int/string $trans_ref * @param int $user_id * @param int/string $subscr_id * @param int $pack_id * @return boolean */ function cancel_recurring_subscription($trans_ref = null, $user_id = null, $subscr_id = null, $pack_id = null) { //if coming form process return after a subscription payment if (!empty($trans_ref)) { $transdata = $this->_get_transaction_passthrough($trans_ref); if ($transdata['payment_type'] != 'subscription_purchase') { return false; } $user_id = $transdata['user_id']; if (isset($transdata['is_another_membership_purchase']) && $transdata['is_another_membership_purchase'] == 'Y') { $member = mgm_get_member_another_purchase($user_id, $transdata['membership_type']); } else { $member = mgm_get_member($user_id); } if (isset($member->payment_info->module) && !empty($member->payment_info->module)) { if (isset($member->payment_info->subscr_id)) { $subscr_id = $member->payment_info->subscr_id; } else { //check pack is recurring: $pid = $pack_id ? $pack_id : $member->pack_id; if ($pid) { $s_packs = mgm_get_class('subscription_packs'); $sel_pack = $s_packs->get_pack($pid); if ($sel_pack['num_cycles'] != 1) { $subscr_id = 0; } } } //check for same module: if not call the same function of the applicale module. if (str_replace('mgm_', '', $member->payment_info->module) != str_replace('mgm_', '', $this->code)) { mgm_log('RECALLing ' . $member->payment_info->module . ': cancel_recurring_subscription FROM: ' . $this->code); return mgm_get_module($member->payment_info->module, 'payment')->cancel_recurring_subscription($trans_ref, null, null, $pack_id); } //skip if same pack is updated if (empty($member->pack_id) || is_numeric($pack_id) && $pack_id == $member->pack_id) { return false; } } else { return false; } } // when a subscription found if ($subscr_id) { // @todo add api call // query data $query_data = array(); // add internal vars $secure = array('clientAccnum' => $this->setting['client_acccnum'], 'clientSubacc' => $this->setting['client_subacc'], 'username' => $this->setting['datalink_username'], 'password' => $this->setting['datalink_password']); // merge $query_data = array_merge($query_data, $secure); // overwrite post data array with secure params // method $query_data['action'] = 'cancelSubscription'; //check if (isset($member)) { $query_data['subscriptionId'] = $member->payment_info->subscr_id; } else { $query_data['subscriptionId'] = $subscr_id; } // xml response $query_data['returnXML'] = 1; // post string $query_string = _http_build_query($query_data, null, '&'); // endpoint $endpoint = $this->_get_endpoint('datalink_sms'); // url $url = $endpoint . '?' . $query_string; // log mgm_log($url, $this->module . '_' . __FUNCTION__); // remote get $http_response = mgm_remote_get($url, null, null, false); // log mgm_log($http_response, $this->module . '_' . __FUNCTION__); // xml if ($xml = @simplexml_load_string($http_response)) { // log mgm_log($xml, $this->module . '_' . __FUNCTION__); // return return (int) $xml == 1; // success } // end api call } elseif (is_null($subscr_id) || $subscr_id === 0) { $system_obj = mgm_get_class('system'); $dge = bool_from_yn($system_obj->get_setting('disable_gateway_emails')); // check if (!$dge) { // blog $blogname = get_option('blogname'); // user $user = get_userdata($user_id); // notify admin mgm_notify_admin_membership_cancellation_manual_removal_required($blogname, $user, $member); } // return return true; } // return return false; }
/** * Cancel Recurring Subscription * This is not a private function * @param int/string $trans_ref * @param int $user_id * @param int/string $subscr_id * @return boolean */ function cancel_recurring_subscription($trans_ref = null, $user_id = null, $subscr_id = null, $pack_id = null) { //if coming form process return after a subscription payment if (!empty($trans_ref)) { $transdata = $this->_get_transaction_passthrough($trans_ref); if ($transdata['payment_type'] != 'subscription_purchase') { return false; } $user_id = $transdata['user_id']; if (isset($transdata['is_another_membership_purchase']) && $transdata['is_another_membership_purchase'] == 'Y') { $member = mgm_get_member_another_purchase($user_id, $transdata['membership_type']); } else { $member = mgm_get_member($user_id); } if (isset($member->payment_info->module) && !empty($member->payment_info->module)) { if (isset($member->payment_info->subscr_id)) { $subscr_id = $member->payment_info->subscr_id; } else { //check pack is recurring: $pid = $pack_id ? $pack_id : $member->pack_id; if ($pid) { $s_packs = mgm_get_class('subscription_packs'); $sel_pack = $s_packs->get_pack($pid); if ($sel_pack['num_cycles'] != 1) { $subscr_id = 0; } // 0 stands for a lost subscription id } } //check for same module: if not call the same function of the applicale module. if (str_replace('mgm_', '', $member->payment_info->module) != str_replace('mgm_', '', $this->code)) { // mgm_log('RECALLing '. $member->payment_info->module .': cancel_recurring_subscription FROM: ' . $this->code); return mgm_get_module($member->payment_info->module, 'payment')->cancel_recurring_subscription($trans_ref, null, null, $pack_id); } //skip if same pack is updated if (empty($member->pack_id) || is_numeric($pack_id) && $pack_id == $member->pack_id) { return false; } } else { return false; } } //ony for subscription_purchase if ($subscr_id) { // end point $endpoint = $this->_get_endpoint('unsubscribe'); // base // add query $url = add_query_arg(array('SUBSCRIPTION_ID' => urlencode($subscr_id), 'MERCHANT_ID' => urlencode($this->setting['merchant_id']), 'ZombaioGWPass' => urlencode($this->setting['gw_pass']), 'ReasonCode' => urlencode(11)), $endpoint); // create curl post //$buffer = $this->_curl_post($url); // headers $http_headers = array(); // fetch $http_response = mgm_remote_post($url, $post_data, array('headers' => $http_headers, 'timeout' => 30, 'sslverify' => false)); // verify if ($http_response == 1) { return true; } else { // message return $this->_get_cancel_error($http_response); } } elseif ($subscr_id === 0) { //send email to admin if subscription Id is absent $system_obj = mgm_get_class('system'); $dge = bool_from_yn($system_obj->get_setting('disable_gateway_emails')); //send email only if setting enabled if (!$dge) { $user = get_userdata($user_id); //send notification email to admin: $message = __('The User: '******'mgm') . $user->user_email . ' (' . $user_id . ') ' . __('has upgraded/cancelled subscription.', 'mgm'); $message .= "<br/>" . __('Please unsubscribe the user subscription from Gateway Merchant panel.', 'mgm'); if (!empty($member->transaction_id)) { $message .= "<br/>" . __('MGM Transaction Id:', 'mgm') . $member->transaction_id; } //admin email: if (!empty($system_obj->setting['admin_email'])) { @mgm_mail($system_obj->setting['admin_email'], sprintf(__('[%s] User Subscription Cancellation', 'mgm'), get_option('blogname')), $message); } } return true; } return false; }
/** * Confirm notify URL. * * related to issue#: 528 * As PAYPALPRO doesn't use overridden notifyurl, and posts IPN to default IPN settings URL on merchant panel * Confirm module field in transactions table/mgm_member object * */ function _confirm_notify() { $mod_code = ''; //check possible params for transaction id [rp_invoice_id, invoice, custom] if (isset($_POST['rp_invoice_id']) && is_numeric($_POST['rp_invoice_id'])) { $transaction_id = $_POST['rp_invoice_id']; } elseif (isset($_POST['invoice']) && is_numeric($_POST['invoice'])) { $transaction_id = $_POST['invoice']; } elseif (isset($_POST['custom']) && is_numeric($_POST['custom'])) { $transaction_id = $_POST['custom']; } elseif (isset($_POST['custom']) && !is_numeric($_POST['custom']) && preg_match('/^subscription_/', $_POST['custom'])) { //for backward compatibility: //transaction cannot be found for old users: $transdata = $this->_get_transaction_passthrough($_POST['custom']); $member = mgm_get_member($transdata['user_id']); if (isset($member->payment_info->module) && !empty($member->payment_info->module)) { $mod_code = preg_match('/mgm_/', $member->payment_info->module) ? $member->payment_info->module : 'mgm_' . $transdata['module']; } } //if a transaction id is found if (isset($transaction_id)) { $transdata = mgm_get_transaction($transaction_id); if (!empty($transdata['module'])) { $mod_code = preg_match('/mgm_/', $transdata['module']) ? $transdata['module'] : 'mgm_' . $transdata['module']; } } //if module code is found and not belongs to current module, then invode process_notify() function of the applicable module. if (!empty($mod_code) && $mod_code != $this->code) { // recall process_notifyof the module // keep the log untill paypal is resolved. // mgm_log('FROM PAYMENT: recalling ' . $mod_code .'->process_notify() FROM: '. $this->code ); mgm_get_module($mod_code, 'payment')->process_notify(); // return return false; } return true; }
<?php /** * Objects merge/update * Add eWay webservice username and password to settings */ // read $eway = mgm_get_module('eway', 'payment'); if (!isset($eway->setting['username'])) { $eway->setting['username'] = ''; $eway->setting['password'] = ''; $eway->save(); } // end file
function _update_modules() { // get modules $modules = mgm_get_modules('payment'); // loop foreach ($modules as $module) { // instance $module_object = mgm_get_module('mgm_' . $module, 'payment'); // update message $module_object->_setup_callback_messages(array(), true); // update from global template // update option $module_object->save(); } }
/** * get post purchase buttons * final step for post purchase * * @param void * @return $html */ function mgm_get_post_purchase_buttons() { // get current user data - issue #1421 $user = wp_get_current_user(); // pack $pack = NULL; // addon options if ($addon_option_ids = mgm_post_var('addon_options')) { $addon_options = mgm_get_addon_options_only($addon_option_ids); // mgm_pr($addon_options); } // post purchase if (isset($_POST['post_id'])) { //issue #1250 if (isset($_POST['mgm_postpurchase_field']['coupon']) && !empty($_POST['mgm_postpurchase_field']['coupon'])) { //issue #1250 - Coupon validation if (!empty($_POST['form_action'])) { // check if its a valid coupon if (!($coupon = mgm_get_coupon_data($_POST['mgm_postpurchase_field']['coupon']))) { //redirect back to the form $q_arg = array('error_field' => 'Coupon', 'error_type' => 'invalid', 'error_field_value' => $_POST['mgm_postpurchase_field']['coupon']); $redirect = add_query_arg($q_arg, $_POST['form_action']); mgm_redirect($redirect); exit; } } } // post id $post_id = $_POST['post_id']; // gete mgm data $post_obj = mgm_get_post($post_id); $cost = mgm_convert_to_currency($post_obj->purchase_cost); $product = $post_obj->product; $allowed_modules = $post_obj->allowed_modules; // post data $post = get_post($post_id); $title = $post->post_title; // item name -issue #1380 $item_name = apply_filters('mgm_post_purchase_itemname', sprintf(__('Purchase Post - %s', 'mgm'), $title)); // set pack $pack = array('duration' => 1, 'item_name' => $item_name, 'buypost' => 1, 'cost' => $cost, 'title' => $title, 'product' => $product, 'post_id' => $post_id, 'allowed_modules' => $allowed_modules); } else { if (isset($_POST['postpack_id'])) { // post pack purchase //issue #1250 if (isset($_POST['mgm_postpurchase_field']['coupon']) && !empty($_POST['mgm_postpurchase_field']['coupon'])) { //issue #1250 - Coupon validation if (!empty($_POST['form_action'])) { // check if its a valid coupon if (!($coupon = mgm_get_coupon_data($_POST['mgm_postpurchase_field']['coupon']))) { //redirect back to the form $q_arg = array('error_field' => 'Coupon', 'error_type' => 'invalid', 'error_field_value' => $_POST['mgm_postpurchase_field']['coupon']); $redirect = add_query_arg($q_arg, $_POST['form_action']); mgm_redirect($redirect); exit; } } } // post pack purchase $postpack_id = $_POST['postpack_id']; // pcak id $postpack_post_id = $_POST['postpack_post_id']; // post id where pack is listed, redirect here // get pack $postpack = mgm_get_postpack($postpack_id); $cost = mgm_convert_to_currency($postpack->cost); $product = json_decode($postpack->product, true); $modules = json_decode($postpack->modules, true); //mgm_pr($postpack); // item name -issue #1380 $item_name = apply_filters('mgm_postpack_purchase_itemname', sprintf(__('Purchase Post Pack - %s', 'mgm'), $postpack->name)); // post id $post_id = mgm_get_postpack_posts_csv($postpack_id); // set pack $pack = array('duration' => 1, 'item_name' => $item_name, 'buypost' => 1, 'cost' => $cost, 'title' => $postpack->name, 'product' => $product, 'post_id' => $post_id, 'postpack_id' => $postpack_id, 'postpack_post_id' => $postpack_post_id, 'allowed_modules' => $modules); } } // check if (!$pack) { return __('Error in Payment! No data available '); exit; } // guest token -issue #1421 if (isset($_POST['guest_purchase']) && $_POST['guest_purchase'] == TRUE && $user->ID <= 0) { $pack['guest_token'] = sanitize_title_for_query(mgm_create_token()); } // addon options if (isset($addon_options) && !empty($addon_options)) { $pack['addon_options'] = $addon_options; } // get coupon $post_purchase_coupon = mgm_save_partial_fields(array('on_postpurchase' => true), 'mgm_postpurchase_field', $pack['cost'], false, 'postpurchase'); // alter mgm_get_post_purchase_coupon_pack($post_purchase_coupon, $pack); // Eg: $_POST['mgm_payment_gateways'] = mgm_paypal $cf_payment_gateways = isset($_POST['mgm_payment_gateways']) && !empty($_POST['mgm_payment_gateways']) ? $_POST['mgm_payment_gateways'] : null; // bypass step2 if payment gateway is submitted: issue #: 469 if (!is_null($cf_payment_gateways)) { // get pack // mgm_get_upgrade_coupon_pack($member, $selected_pack); // cost if ((double) $pack['cost'] > 0) { //get an object of the payment gateway: $mod_obj = mgm_get_module($cf_payment_gateways, 'payment'); // tran options $tran_options = array('user_id' => $user->ID); // is register & purchase if (isset($_POST['post_id'])) { $tran_options['post_id'] = (int) $_POST['post_id']; } // postpack id if (isset($_POST['postpack_id'])) { $tran_options['postpack_id'] = (int) $_POST['postpack_id']; } // is register & purchase postpack if (isset($_POST['postpack_post_id']) && isset($_POST['postpack_id'])) { $tran_options['postpack_post_id'] = (int) $_POST['postpack_post_id']; $tran_options['postpack_id'] = (int) $_POST['postpack_id']; } // create transaction $tran_id = mgm_add_transaction($pack, $tran_options); // bypass directly to process return if manual payment: if ($cf_payment_gateways == 'mgm_manualpay') { // set $_POST['custom'] = $tran_id; // direct call to module return function: $mod_obj->process_return(); // exit exit; } // encode id: $tran_id = mgm_encode_id($tran_id); $redirect = $mod_obj->_get_endpoint('html_redirect', true); $redirect = add_query_arg(array('tran_id' => $tran_id), $redirect); // redirect mgm_redirect($redirect); // this goes to subscribe, mgm_functions.php/mgm_get_subscription_buttons // exit exit; } } // get payment modules $a_payment_modules = mgm_get_class('system')->get_active_modules('payment'); // init $payment_modules = array(); // when active if ($a_payment_modules) { // loop foreach ($a_payment_modules as $payment_module) { // not trial if (in_array($payment_module, array('mgm_free', 'mgm_trial'))) { continue; } // store $payment_modules[] = $payment_module; } } // init $button = ''; // transaction $tran_id = NULL; $button_printed = 0; // loop modules foreach ($payment_modules as $module) { // object $mod_obj = mgm_get_module($module, 'payment'); // check buypost support if (in_array('buypost', $mod_obj->supported_buttons)) { // create transaction if (!$tran_id) { $tran_id = mgm_add_transaction($pack); } // button code if (isset($pack['allowed_modules'])) { // Issue #1562: If no payment module is selected, display all supported modules if (!empty($pack['allowed_modules']) && FALSE === in_array($module, $pack['allowed_modules'])) { continue; } } $button_code = $mod_obj->get_button_buypost(array('pack' => $pack, 'tran_id' => $tran_id), true); $button_printed++; // get button $button .= "<div class='mgm_custom_filed_table'>" . $button_code . "</div>"; } } // none active if ($button_printed == 0) { $button .= sprintf('<p class="mgm-no-module"> %s </p>', __('No Payment module active for this Content Purchase.', 'mgm')); } // if Cost is zero, then process using free module.: issue#: 883 if ($tran_id && $pack['cost'] == 0 && in_array('mgm_free', $a_payment_modules) && mgm_get_module('mgm_free')->is_enabled()) { // module $module = 'mgm_free'; // payments url $payments_url = mgm_get_custom_url('transactions'); // query_args $query_args = array('method' => 'payment_return', 'module' => $module, 'custom' => $tran_id); // redirector if (isset($_REQUEST['redirector'])) { // set $query_args['redirector'] = $_REQUEST['redirector']; } // redirect to module to mark the payment as complete $redirect = add_query_arg($query_args, $payments_url); // redirect mgm_redirect($redirect); } // html $return = '<div class="post_purchase_select_gateway">' . __('Please Select a Payment Gateway.', 'mgm') . '</div>' . $button; // return return $return; }
function activate() { global $wpdb; // get auth $auth = mgm_get_class('auth'); // verify key if ($auth->verify()) { // migration once / it will take care require_once 'migration/mgm_migrate.php'; // check and set each schedules foreach (mgm_get_defined_schedules() as $schedule_name => $event_name) { // set up daily cron event, once if (!wp_next_scheduled($event_name)) { // add wp_schedule_event(time(), $schedule_name, $event_name); // the name of event/schedule hook } } // create pages run always now, only when new pages added it will execute mgm_create_custom_pages(); // run others once if (!get_option('mgm_version') || version_compare(get_option('mgm_upgrade_id'), '1.8', '<')) { // add version/upgrade compare, transaction added on 1.8 and pages later // create pages // mgm_create_custom_pages(); // enable active modules $payment_modules = mgm_get_class('system')->get_active_modules('payment'); // active modules if ($payment_modules) { // loop foreach ($payment_modules as $module) { // install modules mgm_get_module($module, 'payment')->enable(); // enable only } } // update update_option('mgm_version', $auth->get_product_info('product_version')); // version update_option('mgm_build', $auth->get_product_info('product_build')); // build } } }
/** * update transactions missing data */ function mgm_update_transaction_data() { // db global $wpdb; // // sql $sql = "SELECT id,user_id,module,data,transaction_dt FROM `" . TBL_MGM_TRANSACTION . "` \r\r\n\t WHERE 1 AND (`user_id` IS NULL OR `user_id` = 0) AND module IS NOT NULL LIMIT 0, 50"; // check missing user_id if ($transactions = $wpdb->get_results($sql)) { // log // mgm_log($transactions, __FUNCTION__); // loop foreach ($transactions as $transaction) { // pack $pack = json_decode($transaction->data, true); // check if (isset($pack['user_id']) && (int) $pack['user_id'] > 0) { // id $user_id = $pack['user_id']; // update $wpdb->update(TBL_MGM_TRANSACTION, array('user_id' => $user_id), array('id' => $transaction->id)); // log mgm_log($wpdb->last_query, __FUNCTION__); } } } // authorizenet module $authorizenet = mgm_get_module('authorizenet', 'payment'); // if active if ($authorizenet->is_enabled()) { // fetch module transactions // mgm_log('Enabled', __FUNCTION__); // 1699,1700,1711,1712,1714,1716,1718,1721,1725,1734,1735,1724,1722 mgm_fetch_authorizenet_missing_txn_id($authorizenet); } }
/** * Cancel Recurring Subscription * Cancellation includes 2 webservice calls * 1. delete Rebill Event on eWay * 2. delete Rebill Customer on eWay * This is not a private function * @param int/string $trans_ref * @param int $user_id * @param int/string $rebill_id * @param int $pack_id * @return boolean */ function cancel_recurring_subscription($trans_ref = null, $user_id = null, $rebill = null, $pack_id = null) { //if coming form process return after a subscription payment if (!empty($trans_ref)) { $transdata = $this->_get_transaction_passthrough($trans_ref); if ($transdata['payment_type'] != 'subscription_purchase') { return false; } $user_id = $transdata['user_id']; if (isset($transdata['is_another_membership_purchase']) && $transdata['is_another_membership_purchase'] == 'Y') { $member = mgm_get_member_another_purchase($user_id, $transdata['membership_type']); } else { $member = mgm_get_member($user_id); } if (isset($member->payment_info->module) && !empty($member->payment_info->module)) { if (isset($member->payment_info->subscr_id)) { $rebill['rebill_id'] = $member->payment_info->subscr_id; $rebill['rebill_customer_id'] = $member->payment_info->rebill_customerid; } else { //check pack is recurring: $pid = $pack_id ? $pack_id : $member->pack_id; if ($pid) { $s_packs = mgm_get_class('subscription_packs'); $sel_pack = $s_packs->get_pack($pid); if ($sel_pack['num_cycles'] != 1) { $rebill['rebill_id'] = 0; } // 0 stands for a lost subscription id } } //check for same module: if not call the same function of the applicale module. if (str_replace('mgm_', '', $member->payment_info->module) != str_replace('mgm_', '', $this->code)) { // log mgm_log('RECALLing ' . $member->payment_info->module . ': cancel_recurring_subscription FROM: ' . $this->module, $this->module . '_cancel'); // return return mgm_get_module($member->payment_info->module, 'payment')->cancel_recurring_subscription($trans_ref, null, null, $pack_id); } //skip if same pack is updated if (empty($member->pack_id) || is_numeric($pack_id) && $pack_id == $member->pack_id) { return false; } } else { return false; } } //if valid rebill data is found and settings are set if (!empty($rebill['rebill_id']) && !empty($rebill['rebill_customer_id']) && !empty($this->setting['customer_id']) && !empty($this->setting['username']) && !empty($this->setting['password'])) { $gateway_method = 'webservice'; $secure = array('CustomerID' => $this->setting['customer_id'], 'Username' => $this->setting['username'], 'Password' => $this->setting['password']); //data to post //Delete Rebill Event $post_data = array('webservice_action' => 'DeleteRebillEvent', 'RebillCustomerID' => $rebill['rebill_customer_id'], 'RebillID' => $rebill['rebill_id']); $post_data = array_merge($post_data, $secure); // filter post data and create soap xml $post_string = $this->_filter_postdata($gateway_method, $post_data); // endpoint $endpoint = $this->_get_endpoint($this->status . '_' . $gateway_method); // test_webservice / live_webservice // headers $http_headers = $this->_get_http_headers($gateway_method, $post_data['webservice_action']); // log mgm_log('Request Headers [' . $post_data['webservice_action'] . ']' . mgm_pr($http_headers, true), __FUNCTION__); // log mgm_log('Request [' . $post_data['webservice_action'] . ']' . $post_string, __FUNCTION__); // create curl post $http_response = mgm_remote_post($endpoint, $post_string, array('headers' => $http_headers, 'timeout' => 30, 'sslverify' => false)); // log mgm_log('Response [' . $post_data['webservice_action'] . ']' . $http_response, __FUNCTION__); /*$http_header = array('User-Agent: NuSOAP/0.9.5 (1.123)', 'Content-Type: text/xml; charset=ISO-8859-1', sprintf('SOAPAction: "http://www.eway.com.au/gateway/rebill/manageRebill/%s"', $post_data['webservice_action']));*/ // post soap data // $buffer = $this->_curl_post($endpoint, $post_string, $http_header); // parse response $this->_process_response($gateway_method, $http_response, $post_data['webservice_action']); // log mgm_log('Response Parsed [' . $post_data['webservice_action'] . ']' . mgm_pr($this->response, true), __FUNCTION__); //if rebill event is deleted, delete rebill customer if (isset($this->response['response_status']) && $this->response['response_status'] == 1) { //delete rebill customer: $post_data['webservice_action'] = 'DeleteRebillCustomer'; // filter post data and create soap xml $post_string = $this->_filter_postdata($gateway_method, $post_data); // soap_action $soap_action = sprintf('http://www.eway.com.au/gateway/rebill/manageRebill/%s', $post_data['webservice_action']); // http_headers $http_headers = array_merge($http_headers, array('SOAPAction' => $soap_action)); // log mgm_log('Request Headers [' . $post_data['webservice_action'] . ']' . mgm_pr($http_headers, true), __FUNCTION__); // log mgm_log('Request [' . $post_data['webservice_action'] . ']' . $post_string, __FUNCTION__); // create curl post $http_response = mgm_remote_post($endpoint, $post_string, array('headers' => $http_headers, 'timeout' => 30, 'sslverify' => false)); // log mgm_log('Response [' . $post_data['webservice_action'] . ']' . $http_response, __FUNCTION__); /*$http_header = array('User-Agent: NuSOAP/0.9.5 (1.123)', 'Content-Type: text/xml; charset=ISO-8859-1', sprintf('SOAPAction: "http://www.eway.com.au/gateway/rebill/manageRebill/%s"', $post_data['webservice_action']));*/ // post soap data // $buffer = $this->_curl_post($endpoint, $post_string, $http_header); // parse response $this->_process_response($gateway_method, $http_response, $post_data['webservice_action']); // log mgm_log('Response Parsed [' . $post_data['webservice_action'] . ']' . mgm_pr($this->response, true), __FUNCTION__); // check if (isset($this->response['response_status']) && $this->response['response_status'] == 1) { //done return true; } } } elseif ($rebill['rebill_id'] === 0) { $system_obj = mgm_get_class('system'); $dge = bool_from_yn($system_obj->get_setting('disable_gateway_emails')); //send email only if setting enabled if (!$dge) { $user = get_userdata($user_id); //send notification email to admin: $message = __('The User: '******'mgm') . $user->user_email . ' (' . $user_id . ') ' . __('has upgraded/cancelled subscription.', 'mgm'); $message .= "<br/>" . __('Please unsubscribe the user from Gateway Merchant panel.', 'mgm'); if (!empty($rebill['rebill_customer_id'])) { $message .= "<br/><br/>" . __('Customer Rebill Id: ', 'mgm') . $rebill['rebill_customer_id']; } if (!empty($rebill['rebill_id'])) { $message .= "<br/><br/>" . __('Rebill Id: ', 'mgm') . $rebill['rebill_id']; } if (isset($member->transaction_id)) { $message .= "<br/>" . __('MGM Transaction Id:', 'mgm') . $member->transaction_id; } //admin email: if (!empty($system_obj->setting['admin_email'])) { @mgm_mail($system_obj->setting['admin_email'], sprintf(__('[%s] User Subscription Cancellation', 'mgm'), get_option('blogname')), $message); } } //treat as done return true; } return false; }
/** * Cancel Recurring Subscription * * @param int/string $trans_ref * @param int $user_id * @param int/string $subscr_id * @return boolean/string message */ function cancel_recurring_subscription($trans_ref = null, $user_id = null, $sale_id = null, $pack_id = null) { // if coming form process return after a subscription payment if (!empty($trans_ref)) { // transaction data $transdata = $this->_get_transaction_passthrough($trans_ref); // validate if ($transdata['payment_type'] != 'subscription_purchase') { return false; } // user $user_id = $transdata['user_id']; // multiple purchase if (isset($transdata['is_another_membership_purchase']) && $transdata['is_another_membership_purchase'] == 'Y') { $member = mgm_get_member_another_purchase($user_id, $transdata['membership_type']); } else { $member = mgm_get_member($user_id); } // subscription exists if (isset($member->payment_info->module) && !empty($member->payment_info->module)) { // sale id if (isset($member->payment_info->txn_id)) { $sale_id = $member->payment_info->txn_id; } else { //check pack is recurring: $pid = $pack_id ? $pack_id : $member->pack_id; if ($pid) { $s_packs = mgm_get_class('subscription_packs'); $sel_pack = $s_packs->get_pack($pid); if ($sel_pack['num_cycles'] != 1) { $sale_id = 0; } //not found } } // module info // check for same module: if not call the same function of the applicale module. if (str_replace('mgm_', '', $member->payment_info->module) != str_replace('mgm_', '', $this->code)) { // recur return mgm_get_module($member->payment_info->module, 'payment')->cancel_recurring_subscription($trans_ref, null, null, $pack_id); } //skip if same pack is updated if (empty($member->pack_id) || is_numeric($pack_id) && $pack_id == $member->pack_id) { return false; } } else { // error return false; } } // only for subscription_purchase if ($sale_id) { // sale id, returned order_number on approval url post back // saledetail_url $saledetail_url = add_query_arg(array('sale_id' => $sale_id), $this->_get_endpoint('saledetail')); // auth string $auth = $this->setting['apiusername'] . ':' . $this->setting['apipassword']; // post data $post_data = array(); // headers $http_headers = array('Accept' => 'application/json', 'Authorization' => 'Basic ' . base64_encode($auth)); // fetch $http_response = mgm_remote_post($saledetail_url, $post_data, array('headers' => $http_headers, 'timeout' => 30, 'sslverify' => false)); // decode $response = json_decode($http_response); // ind $lineitem_id = ''; // validate if ((string) $response->response_code == 'OK') { $lineitem_id = (string) $response->sale->invoices[0]->lineitems[0]->billing->lineitem_id; } // set post $post_data = array('vendor_id' => $this->setting['sid'], 'lineitem_id' => $lineitem_id); // unsubscribe_url $unsubscribe_url = $this->_get_endpoint('unsubscribe'); // fetch $http_response = mgm_remote_post($unsubscribe_url, $post_data, array('headers' => $http_headers, 'timeout' => 30, 'sslverify' => false)); // decode $response = json_decode($http_response); // return status if ((string) $response->response_code == 'OK') { return true; } else { return $response->errors[0]->message; } } elseif ($sale_id === 0) { //send email to admin if subscription Id is absent $system_obj = mgm_get_class('system'); $dge = bool_from_yn($system_obj->get_setting('disable_gateway_emails')); //send email only if setting enabled if (!$dge) { // blog $blogname = get_option('blogname'); // user $user = get_userdata($user_id); // notify admin mgm_notify_admin_membership_cancellation_manual_removal_required($blogname, $user, $member); } return true; } // default return false; }
/** * get response confirmation users mail to campaign admin * * @deprecated */ function daily_getresponse_confirmed_users() { // send mgm_get_module('getresponse', 'autoresponder')->send_confirmation(); }
/** * Cancel Recurring Subscription * * @param int/string $trans_ref * @param int $user_id * @param int/string $subscr_id * @return boolean */ function cancel_recurring_subscription($trans_ref = null, $user_id = null, $subscr_id = null, $pack_id = null) { //if coming form process return after a subscription payment if (!empty($trans_ref)) { $transdata = $this->_get_transaction_passthrough($trans_ref); if ($transdata['payment_type'] != 'subscription_purchase') { return false; } $user_id = $transdata['user_id']; if (isset($transdata['is_another_membership_purchase']) && $transdata['is_another_membership_purchase'] == 'Y') { $member = mgm_get_member_another_purchase($user_id, $transdata['membership_type']); } else { $member = mgm_get_member($user_id); } if (isset($member->payment_info->module) && !empty($member->payment_info->module)) { $subscr_id = null; if (!empty($member->payment_info->subscr_id)) { $subscr_id = $member->payment_info->subscr_id; } elseif (!empty($member->pack_id)) { //check the pack is recurring $s_packs = mgm_get_class('subscription_packs'); $sel_pack = $s_packs->get_pack($member->pack_id); if ($sel_pack['num_cycles'] != 1) { $subscr_id = 0; } // 0 stands for a lost subscription id } //check for same module: if not call the same function of the applicale module. if (str_replace('mgm_', '', $member->payment_info->module) != str_replace('mgm_', '', $this->code)) { // mgm_log('RECALLing '. $member->payment_info->module .': cancel_recurring_subscription FROM: ' . $this->code); return mgm_get_module($member->payment_info->module, 'payment')->cancel_recurring_subscription($trans_ref, null, null, $pack_id); } //skip if same pack is updated if (empty($member->pack_id) || is_numeric($pack_id) && $pack_id == $member->pack_id) { return false; } } else { return false; } } //ony for subscription_purchase if ($subscr_id) { $user = get_userdata($user_id); $format = mgm_get_date_format('date_format'); // compose post body $post_data = array('USER' => $this->setting['username'], 'PWD' => $this->setting['password'], 'SIGNATURE' => $this->setting['signature'], 'VERSION' => '64.0', 'METHOD' => 'ManageRecurringPaymentsProfileStatus', 'PROFILEID' => $subscr_id, 'ACTION' => 'Cancel', 'NOTE' => sprintf('Cancellation selected by member on UPGRADE: "%s", ID: %d on: %s', $user->user_email, $user->ID, date($format))); // end point url $end_point = $this->_get_endpoint(); //issue #1508 $url_parsed = parse_url($end_point); // domain/host $domain = $url_parsed['host']; // headers $http_headers = array('POST /cgi-bin/webscr HTTP/1.1\\r\\n', 'Content-Type: application/x-www-form-urlencoded\\r\\n', 'Host: ' . $domain . '\\r\\n', 'Connection: close\\r\\n\\r\\n'); // post $http_response = mgm_remote_post($end_point, $post_data, array('headers' => $http_headers, 'timeout' => 30, 'sslverify' => false)); // log mgm_log($http_response, __FUNCTION__); // fields // $fields = mgm_http_build_query($post_data); // post // $response = $this->_curl_post($endpoint, $fields, '', false); // sleep sleep(1); // parse $this->response = array(); // parse to array parse_str($http_response, $this->response); // log mgm_log($this->response, __FUNCTION__); // cancel return isset($this->response['ACK']) && $this->response['ACK'] == 'Success' ? true : false; } elseif ($subscr_id === 0) { //send email to admin if subscription Id is absent $system_obj = mgm_get_class('system'); $dge = bool_from_yn($system_obj->get_setting('disable_gateway_emails')); //send email only if setting enabled if (!$dge) { // blog $blogname = get_option('blogname'); // user $user = get_userdata($user_id); // notify admin mgm_notify_admin_membership_cancellation_manual_removal_required($blogname, $user, $member); } return true; } return false; }
<?php /** * Patch for updating PAYPAL locale value(issue#: 538) */ $active_modules = mgm_get_class('system')->get_active_modules('payment'); //check modules are enabled: if (count($active_modules) > 0 && (in_array('mgm_paypal', $active_modules) || in_array('mgm_paypalpro', $active_modules))) { $obj_paypalstd = mgm_get_module('paypal', 'payment'); $obj_paypalpro = mgm_get_module('paypalpro', 'payment'); $arr_locale = mgm_get_locales(); $i = 0; foreach ($arr_locale as $code => $locale) { //paypal if (isset($obj_paypalstd->setting['locale']) && $i == $obj_paypalstd->setting['locale']) { $obj_paypalstd->setting['locale'] = $code; } //paypalpro if (isset($obj_paypalpro->setting['locale']) && $i == $obj_paypalpro->setting['locale']) { $obj_paypalpro->setting['locale'] = $code; } $i++; } $obj_paypalstd->save(); $obj_paypalpro->save(); }
/** * Cancel Recurring Subscription * This is not a private function * @param int/string $trans_ref * @param int $user_id * @param int/string $subscr_id * @param int $pack_id * @return boolean */ function cancel_recurring_subscription($trans_ref = null, $user_id = null, $subscr_id = null, $pack_id = null) { //if coming form process return after a subscription payment if (!empty($trans_ref)) { $transdata = $this->_get_transaction_passthrough($trans_ref); if ($transdata['payment_type'] != 'subscription_purchase') { return false; } $user_id = $transdata['user_id']; if (isset($transdata['is_another_membership_purchase']) && $transdata['is_another_membership_purchase'] == 'Y') { $member = mgm_get_member_another_purchase($user_id, $transdata['membership_type']); } else { $member = mgm_get_member($user_id); } if (isset($member->payment_info->module)) { if (isset($member->payment_info->subscr_id)) { $subscr_id = $member->payment_info->subscr_id; } else { //check pack is recurring: $pid = $pack_id ? $pack_id : $member->pack_id; if ($pid) { $s_packs = mgm_get_class('subscription_packs'); $sel_pack = $s_packs->get_pack($pid); if ($sel_pack['num_cycles'] != 1) { $subscr_id = 0; } } } //check for same module: if not call the same function of the applicale module. if (str_replace('mgm_', '', $member->payment_info->module) != str_replace('mgm_', '', $this->code)) { mgm_log('RECALLing ' . $member->payment_info->module . ': cancel_recurring_subscription FROM: ' . $this->code); return mgm_get_module($member->payment_info->module, 'payment')->cancel_recurring_subscription($trans_ref, null, null, $pack_id); } //skip if same pack is updated if (empty($member->pack_id) || is_numeric($pack_id) && $pack_id == $member->pack_id) { return false; } } else { return false; } } //send email only if setting enabled if (!empty($subscr_id) || $subscr_id === 0) { $system_obj = mgm_get_class('system'); $dge = bool_from_yn($system_obj->get_setting('disable_gateway_emails')); //send email only if setting enabled if (!$dge) { // blog $blogname = get_option('blogname'); // user $user = get_userdata($user_id); // notify admin mgm_notify_admin_membership_cancellation_manual_removal_required($blogname, $user, $member); } return true; } return false; }
function mgm_replace_payment_message_tags($content) { // system $system_obj = mgm_get_class('system'); // current module $module = mgm_request_var('module', '', true); // object $module_object = NULL; // check if ($module) { // module object $module_object = mgm_get_module($module, 'payment'); } // double check if (is_object($module_object)) { // status and message if (!isset($_GET['status']) || $_GET['status'] == 'success') { $payment_status_title = $module_object->setting['success_title'] ? $module_object->setting['success_title'] : $system_obj->get_template('payment_success_title', array(), true); $payment_status_message = $module_object->setting['success_message'] ? $module_object->setting['success_message'] : $system_obj->get_template('payment_success_message', array(), true); } else { if (!isset($_GET['status']) || $_GET['status'] == 'cancel') { $payment_status_title = __('Transaction cancelled', 'mgm'); $payment_status_message = __('You have cancelled the transaction.', 'mgm'); } else { $payment_status_title = $module_object->setting['failed_title'] ? $module_object->setting['failed_title'] : $system_obj->get_template('payment_failed_title', array(), true); $payment_status_message = $module_object->setting['failed_message'] ? $module_object->setting['failed_message'] : $system_obj->get_template('payment_failed_message', array(), true); } } // set errors if (isset($_GET['errors'])) { $errors = explode('|', strip_tags($_GET['errors'])); $payment_status_message .= '<p><h3>' . __('Messages', 'mgm') . '</h3>'; $payment_status_message .= '<div><ul>'; foreach ($errors as $error) { $payment_status_message .= '<li>' . $error . '</li>'; } $payment_status_message .= '</ul> </div></p>'; } // redirect_to post if (isset($_GET['post_redirect'])) { $payment_status_message .= __('<b>You will be redirected to the Post Purchased, please click <a href="' . strip_tags($_GET['post_redirect']) . '"> here </a> if you are not redirected.</b>', 'mgm'); $payment_status_message .= "<script language=\"Javascript\">var t = setTimeout ( \"window.location='" . strip_tags($_GET['post_redirect']) . "'\", 5000 ); </script>"; } // loop tags foreach (array('payment_status_title', 'payment_status_message') as $tag) { // set $content = str_replace('[[' . $tag . ']]', mgm_stripslashes_deep(${$tag}), $content); } } else { // loop tags and clean tags foreach (array('payment_status_title', 'payment_status_message') as $tag) { // set $content = str_replace('[[' . $tag . ']]', '', $content); } } // return return $content; }
?> ", dateFormat: "<?php echo mgm_get_datepicker_format(); ?> "}); } break; case 'payment_module': <?php // init $payment_modules = array(); // module tracking fields if ($data['payment_modules']) { foreach ($data['payment_modules'] as $payment_module) { // get modu;e $module = mgm_get_module($payment_module); // check virtual //if( !$module->is_virtual_payment() ): // set data $payment_modules[$module->code] = $module->name; //endif; } } ?> jQuery('#fld_wrapper_two').html(''); var s=document.createElement('select'); s.name='search_field_value'; <?php foreach ($payment_modules as $payment_module_code => $payment_module_name) { ?>
if ($data['payment_modules']) { foreach ($data['payment_modules'] as $payment_module) { if (!in_array($payment_module, array('mgm_free'))) { ?> <input type="checkbox" name="packs[<?php echo $data['pack_ctr'] - 1; ?> ][modules][]" value="<?php echo $payment_module; ?> " <?php echo in_array($payment_module, (array) $data['pack']['modules']) ? 'checked' : ''; ?> /> <?php echo mgm_get_module($payment_module)->name; ?> <?php } } } ?> </div> </div> <?php } // end type free/trial check ?>
<?php /** * Objects merge/update * update getResponse autoresponder endpoint */ // read $getresponse = mgm_get_module('getresponse', 'autoresponder'); if (!empty($getresponse->end_points['live'])) { $getresponse->end_points['live'] = 'http://api2.getresponse.com'; $getresponse->save(); } // end file
<?php /** * Patch for updating AlertPay Payment gateway label changes * Alertpay has been Renamed to Payza */ $alertpay = mgm_get_module('alertpay', 'payment'); // name $alertpay->name = 'Payza'; // logo $alertpay->logo = MGM_MODULE_BASE_URL . 'payment/alertpay/assets/payza.png'; // description $alertpay->description = __('A comprehensive all-in-one solution for your payment needs. Payza is an account-based payment processor allowing just about ' . 'anyone with an email address to securely send and receive money with their credit card or bank account. .', 'mgm'); // end points $alertpay->end_points = array('test' => 'https://sandbox.payza.com/sandbox/payprocess.aspx', 'live' => 'https://secure.payza.com/checkout', 'unsubscribe' => 'https://api.payza.com/svc/api.svc/CancelSubscription'); // cancel subscription // save changes $alertpay->save();
/** * Cancel Recurring Subscription * This is not a private function * @param int/string $trans_ref * @param int $user_id * @param int/string $subscr_id * @param int $pack_id * @return boolean */ function cancel_recurring_subscription($trans_ref = null, $user_id = null, $subscr_id = null, $pack_id = null) { //if coming form process return after a subscription payment if (!empty($trans_ref)) { $transdata = $this->_get_transaction_passthrough($trans_ref); if ($transdata['payment_type'] != 'subscription_purchase') { return false; } $user_id = $transdata['user_id']; if (isset($transdata['is_another_membership_purchase']) && $transdata['is_another_membership_purchase'] == 'Y') { $member = mgm_get_member_another_purchase($user_id, $transdata['membership_type']); } else { $member = mgm_get_member($user_id); } if (isset($member->payment_info->module) && !empty($member->payment_info->module)) { if (isset($member->payment_info->subscr_id)) { $subscr_id = $member->payment_info->subscr_id; } else { //check pack is recurring: $pid = $pack_id ? $pack_id : $member->pack_id; if ($pid) { $s_packs = mgm_get_class('subscription_packs'); $sel_pack = $s_packs->get_pack($pid); if ($sel_pack['num_cycles'] != 1) { $subscr_id = 0; } // 0 stands for a lost subscription id } } //check for same module: if not call the same function of the applicale module. if (str_replace('mgm_', '', $member->payment_info->module) != str_replace('mgm_', '', $this->code)) { mgm_log('RECALLing ' . $member->payment_info->module . ': cancel_recurring_subscription FROM: ' . $this->code); return mgm_get_module($member->payment_info->module, 'payment')->cancel_recurring_subscription($trans_ref, null, null, $pack_id); } //skip if same pack is updated if (empty($member->pack_id) || is_numeric($pack_id) && $pack_id == $member->pack_id) { return false; } } else { return false; } } $system_obj = mgm_get_class('system'); $dge = bool_from_yn($system_obj->get_setting('disable_gateway_emails')); //send email only if setting enabled if ((!empty($subscr_id) || $subscr_id === 0) && !$dge) { $user = get_userdata($user_id); //send notification email to admin: $message = __('The User: '******'mgm') . $user->user_email . ' (' . $user_id . ') ' . __('has upgraded/cancelled subscription.', 'mgm'); $message .= "<br/>" . __('Please unsubscribe the user from Gateway Merchant panel.', 'mgm'); if ($subscr_id) { $message .= "<br/><br/>" . __('Pay Id: ', 'mgm') . $subscr_id; } if (isset($member->transaction_id)) { $message .= "<br/>" . __('MGM Transaction Id:', 'mgm') . $member->transaction_id; } //admin email: if (!empty($system_obj->setting['admin_email'])) { @mgm_mail($system_obj->setting['admin_email'], sprintf(__('[%s] User Subscription Cancellation', 'mgm'), get_option('blogname')), $message); } } return true; }
function mgm_get_cached_object($class_name, $type, $id = false) { // on type switch ($type) { case 'payment': case 'autoresponder': return mgm_get_module($class_name, $type, true); break; case 'member': return mgm_get_member($id, true); // cached from db break; case 'post': return mgm_get_post($id, true); // cached from db break; case 'class': default: return mgm_get_option($class_name); break; } // error return false; }
/** * Cancel Recurring Subscription * This is not a private function * @param int/string $trans_ref * @param int $user_id * @param int/string $subscr_id * @return boolean */ function cancel_recurring_subscription($trans_ref = null, $user_id = null, $subscr_id = null, $pack_id = null) { //if coming form process return after a subscription payment if (!empty($trans_ref)) { $transdata = $this->_get_transaction_passthrough($trans_ref); if ($transdata['payment_type'] != 'subscription_purchase') { return false; } $user_id = $transdata['user_id']; if (isset($transdata['is_another_membership_purchase']) && $transdata['is_another_membership_purchase'] == 'Y') { $member = mgm_get_member_another_purchase($user_id, $transdata['membership_type']); } else { $member = mgm_get_member($user_id); } if (isset($member->payment_info->module) && !empty($member->payment_info->module)) { if (isset($member->payment_info->subscr_id)) { $subscr_id = $member->payment_info->subscr_id; } else { //check pack is recurring: $pid = $pack_id ? $pack_id : $member->pack_id; if ($pid) { $s_packs = mgm_get_class('subscription_packs'); $sel_pack = $s_packs->get_pack($pid); if ($sel_pack['num_cycles'] != 1) { $subscr_id = 0; } } } //check for same module: if not call the same function of the applicale module. if (str_replace('mgm_', '', $member->payment_info->module) != str_replace('mgm_', '', $this->code)) { // log // mgm_log('RECALLing '. $member->payment_info->module .': cancel_recurring_subscription FROM: ' . $this->code); // return return mgm_get_module($member->payment_info->module, 'payment')->cancel_recurring_subscription($trans_ref, null, null, $pack_id); } //skip if same pack is updated if (empty($member->pack_id) || is_numeric($pack_id) && $pack_id == $member->pack_id) { return false; } } else { return false; } } //only for subscription_purchase if ($subscr_id) { // set xml content $post_data = '<ARBCancelSubscriptionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"> <merchantAuthentication> <name>' . $this->setting['loginid'] . '</name> <transactionKey>' . $this->setting['tran_key'] . '</transactionKey> </merchantAuthentication> <refId>' . $user_id . '</refId> <subscriptionId>' . $subscr_id . '</subscriptionId> </ARBCancelSubscriptionRequest>'; // end point $endpoint = $this->_get_endpoint($this->status . '_arb'); // test_arb, live_aim etc. // headers $http_headers = array('Content-Type' => 'text/xml'); // create curl post $http_response = mgm_remote_post($endpoint, $post_data, array('headers' => $http_headers, 'timeout' => 30, 'sslverify' => false)); // parse response and store into a different array: // do not use $this->response here as this will overwrite previous theprevious values in one scenario $arb_response = $this->_process_response('arb', $http_response, false); // check if (isset($arb_response['response_status']) && $arb_response['response_status'] == 1) { return true; } } elseif (is_null($subscr_id) || $subscr_id === 0) { //send email to admin if subscription Id is absent $system_obj = mgm_get_class('system'); $dge = bool_from_yn($system_obj->get_setting('disable_gateway_emails')); //send email only if setting enabled if (!$dge) { // blog $blogname = get_option('blogname'); // user $user = get_userdata($user_id); // notify admin mgm_notify_admin_membership_cancellation_manual_removal_required($blogname, $user, $member); } // return return true; } // return return false; }
/** * Cancel Recurring Subscription * This is not a private function * @param int/string $trans_ref * @param int $user_id * @param int/string $subscr_id * @return boolean */ function cancel_recurring_subscription($trans_ref = null, $user_id = null, $subscr_id = null, $pack_id = null) { global $wpdb; //if coming form process return after a subscription payment if (!empty($trans_ref)) { $transdata = $this->_get_transaction_passthrough($trans_ref); if ($transdata['payment_type'] != 'subscription_purchase') { return false; } $user_id = $transdata['user_id']; if (isset($transdata['is_another_membership_purchase']) && $transdata['is_another_membership_purchase'] == 'Y') { $member = mgm_get_member_another_purchase($user_id, $transdata['membership_type']); } else { $member = mgm_get_member($user_id); } if (isset($member->payment_info->module) && !empty($member->payment_info->module)) { if (isset($member->payment_info->subscr_id)) { $subscr_id = $member->payment_info->subscr_id; } else { //check pack is recurring: $pid = $pack_id ? $pack_id : $member->pack_id; if ($pid) { $s_packs = mgm_get_class('subscription_packs'); $sel_pack = $s_packs->get_pack($pid); if ($sel_pack['num_cycles'] != 1) { $subscr_id = 0; } } } //check for same module: if not call the same function of the applicale module. if (str_replace('mgm_', '', $member->payment_info->module) != str_replace('mgm_', '', $this->code)) { // log // mgm_log('RECALLing '. $member->payment_info->module .': cancel_recurring_subscription FROM: ' . $this->code); // return return mgm_get_module($member->payment_info->module, 'payment')->cancel_recurring_subscription($trans_ref, null, null, $pack_id); } //skip if same pack is updated if (empty($member->pack_id) || is_numeric($pack_id) && $pack_id == $member->pack_id) { return false; } } else { return false; } } //only for subscription_purchase if ($pack_id && $user_id) { $userInfo = get_userdata($user_id); $client_cache = $wpdb->get_results($wpdb->prepare('SELECT paymill_sub_id FROM ' . $wpdb->prefix . 'paymill_subscriptions WHERE mgm_user_id="%s" AND mgm_offer_id="%s"', array($user_id, $pack_id)), ARRAY_A); if (isset($client_cache[0]['paymill_sub_id']) && strlen($client_cache[0]['paymill_sub_id']) > 0) { $this->subscriptions->remove($client_cache[0]['paymill_sub_id']); $query = $wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'paymill_subscriptions WHERE mgm_user_id="%s" AND mgm_offer_id="%s"', array($user_id, $pack_id)); $wpdb->query($query); return true; } else { return false; } } return false; }