예제 #1
0
    function process_html_redirect()
    {
        // read tran id
        if (!($tran_id = $this->_read_transaction_id())) {
            return __('Transaction Id invalid', 'mgm');
        }
        // get trans
        if (!($tran = mgm_get_transaction($tran_id))) {
            return __('Transaction invalid', 'mgm');
        }
        // update pack/transaction: this is to confirm the module code if it is different
        mgm_update_transaction(array('module' => $this->module), $tran_id);
        // Check user id is set if subscription_purchase. issue #1049
        if ($tran['payment_type'] == 'subscription_purchase' && (!isset($tran['data']['user_id']) || isset($tran['data']['user_id']) && (int) $tran['data']['user_id'] < 1)) {
            return __('Transaction invalid . User id field is empty', 'mgm');
        }
        // generate
        $button_code = $this->_get_button_code($tran['data'], $tran_id);
        // extra code
        $additional_code = do_action('mgm_additional_code');
        // the html
        $html = '<form action="' . $this->_get_endpoint() . '" method="post" class="mgm_form" name="' . $this->code . '_redirect_form" id="' . $this->code . '_redirect_form">
					' . $button_code . '					
					' . $additional_code . '						
					<img src="' . MGM_ASSETS_URL . 'images/ajax/ajax-loader.gif"/><br>
					<b>' . sprintf(__('Please wait, you are being redirected to %s...', 'mgm'), $this->name) . '</b>							
			  </form>				
			  <script language="javascript">document.' . $this->code . '_redirect_form.submit();</script>';
        // return
        return $html;
    }
    function process_html_redirect()
    {
        // read tran id
        if (!($tran_id = $this->_read_transaction_id())) {
            return __('Transaction Id invalid', 'mgm');
        }
        // get trans
        if (!($tran = mgm_get_transaction($tran_id))) {
            return __('Transaction invalid', 'mgm');
        }
        // Check user id is set if subscription_purchase. issue #1049
        if ($tran['payment_type'] == 'subscription_purchase' && (!isset($tran['data']['user_id']) || isset($tran['data']['user_id']) && (int) $tran['data']['user_id'] < 1)) {
            return __('Transaction invalid . User id field is empty', 'mgm');
        }
        // get user
        $user_id = $tran['data']['user_id'];
        $user = get_userdata($user_id);
        // log
        // mgm_pr($tran);
        // update pack/transaction: this is to confirm the module code if it is different
        mgm_update_transaction(array('module' => $this->module), $tran_id);
        // cc field
        $cc_fields = $this->_get_ccfields($user, $tran);
        // validate card: This will validate card and reload the form with errors
        // if validated process_credit_card() method will be called internally
        $html = $this->validate_cc_fields_process(__FUNCTION__);
        // the html
        $html .= '<form action="' . $this->_get_endpoint('html_redirect') . '" method="post" class="mgm_form" name="' . $this->code . '_form" id="' . $this->code . '_form">
					<input type="hidden" name="tran_id" value="' . $tran_id . '">
					<input type="hidden" name="submit_from" value="' . __FUNCTION__ . '">
					' . $cc_fields . '
			   </form>';
        // return
        return $html;
    }
/**
 * 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);
}
예제 #4
0
    function process_html_redirect()
    {
        // read tran id
        if (!($tran_id = $this->_read_transaction_id())) {
            return __('Transaction Id invalid', 'mgm');
        }
        // get trans
        if (!($tran = mgm_get_transaction($tran_id))) {
            return __('Transaction invalid', 'mgm');
        }
        // Check user id is set if subscription_purchase. issue #1049
        if ($tran['payment_type'] == 'subscription_purchase' && (!isset($tran['data']['user_id']) || isset($tran['data']['user_id']) && (int) $tran['data']['user_id'] < 1)) {
            return __('Transaction invalid . User id field is empty', 'mgm');
        }
        // get user
        $user_id = $tran['data']['user_id'];
        $user = get_userdata($user_id);
        // update pack/transaction: this is to confirm the module code if it is different
        mgm_update_transaction(array('module' => $this->module), $tran_id);
        // endpoint
        $endpoint = $this->_get_endpoint();
        // sisow
        if ('sisow' == $this->setting['aquirer']) {
            // set action
            $endpoint = str_replace('[action]', 'TransactionRequest', $endpoint);
            // get post data
            $post_data = $this->_get_button_data($tran['data'], $tran_id);
            // headers
            $http_headers = array();
            //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 to xml
            if ($xml = @simplexml_load_string($http_response)) {
                // redirect to issuer
                if (isset($xml->transaction->issuerurl)) {
                    wp_redirect(urldecode($xml->transaction->issuerurl));
                } else {
                    // capture error
                    if (isset($xml->error->errormessage)) {
                        $html = (string) $xml->error->errormessage;
                    } else {
                        $html = __('Unknown error occured, please try again!', 'mgm');
                    }
                    // return
                    return $html;
                }
            }
            // exit
            exit;
        }
        // generate
        $button_code = $this->_get_button_code($tran['data'], $tran_id);
        // extra code
        $additional_code = do_action('mgm_additional_code');
        // the html
        $html = '<form action="' . $endpoint . '" method="post" class="mgm_form" name="' . $this->code . '_redirect_form" id="' . $this->code . '_redirect_form">
					' . $button_code . '					
					' . $additional_code . '											
					<img src="' . MGM_ASSETS_URL . 'images/ajax/ajax-loader.gif"/><br>
					<b>' . sprintf(__('Please wait, you are being redirected to %s...', 'mgm'), $this->name) . '</b>
			   </form>
			   <script language="javascript">document.' . $this->code . '_redirect_form.submit();</script>';
        // return
        return $html;
    }
/**
 * Send Email Notification to User on Membership Purchase
 *
 * @uses mgm_notify_user()
 * @param string $blogname
 * @param object $user
 * @param object $member
 * @param array $custom
 * @param array $subs_pack
 * @param object $s_packs
 * @param object $system_obj
 * @return bool $send
 */
function mgm_notify_user_membership_purchase($blogname, $user, $member, $custom, $subs_pack, $s_packs, $system_obj)
{
    // local var
    extract($custom);
    // on status
    switch ($member->status) {
        case MGM_STATUS_ACTIVE:
            //Sending notification email to user - issue #1468
            if (isset($notify_user) && isset($is_registration) && bool_from_yn($is_registration)) {
                // get pass
                $user_pass = mgm_decrypt_password($member->user_password, $user->ID);
                // action
                // send notification only once - issue #1601
                if ($system_obj->setting['enable_new_user_email_notifiction_after_user_active'] == 'Y' && $notify_user) {
                    //check - issue #1794
                    if (isset($member->transaction_id) && $member->transaction_id > 0) {
                        $trans = mgm_get_transaction($member->transaction_id);
                        $trans['data']['notify_user'] = false;
                        mgm_update_transaction(array('data' => json_encode($trans['data'])), $member->transaction_id);
                    }
                    //notify
                    do_action('mgm_register_user_notification', $user->ID, $user_pass);
                }
            }
            //sending upgrade notifaction email to admin
            if (isset($subscription_option) && $subscription_option == 'upgrade') {
                do_action('mgm_user_upgrade_notification', $user_id);
            }
            // init
            $subscription = '';
            // add trial
            if (isset($subs_pack['trial_on']) && (int) $subs_pack['trial_on'] == 1) {
                // trial
                $subscription = sprintf('%1$s %2$s for the first %3$s %4$s,<br> then ', $member->trial_cost, $member->currency, $member->trial_duration * $member->trial_num_cycles, $s_packs->get_pack_duration($subs_pack, true));
            }
            // on type
            if ($member->payment_type == 'subscription') {
                $payment_type = 'recurring subscription';
                $subscription .= sprintf('%1$s %2$s for each %3$s %4$s, %5$s', $member->amount, $member->currency, $member->duration, $s_packs->get_pack_duration($subs_pack), (int) $member->active_num_cycles > 0 ? sprintf('for %d installments', (int) $member->active_num_cycles) : 'until cancelled');
            } else {
                $payment_type = 'one-time payment';
                $subscription .= sprintf('%1$s %2$s for %3$s %4$s', $member->amount, $member->currency, $member->duration, $s_packs->get_pack_duration($subs_pack));
            }
            // subject
            $subject = $system_obj->get_template('payment_success_email_template_subject', array('blogname' => $blogname), true);
            // data
            $data = array('blogname' => $blogname, 'name' => $user->display_name, 'email' => $user->user_email, 'payment_type' => $payment_type, 'subscription' => $subscription, 'admin_email' => $system_obj->get_setting('admin_email'));
            // message
            $message = $system_obj->get_template('payment_success_subscription_email_template_body', $data, true);
            break;
        case MGM_STATUS_NULL:
            // subject
            $subject = $system_obj->get_template('payment_failed_email_template_subject', array('blogname' => $blogname), true);
            // data
            $data = array('blogname' => $blogname, 'name' => $user->display_name, 'email' => $user->user_email, 'payment_type' => 'subscription payment', 'reason' => $member->status_str, 'admin_email' => $system_obj->get_setting('admin_email'));
            // message
            $message = $system_obj->get_template('payment_failed_email_template_body', $data, true);
            break;
        case MGM_STATUS_PENDING:
            // subject
            $subject = $system_obj->get_template('payment_pending_email_template_subject', array('blogname' => $blogname), true);
            // data
            $data = array('blogname' => $blogname, 'name' => $user->display_name, 'email' => $user->user_email, 'reason' => $member->status_str, 'admin_email' => $system_obj->get_setting('admin_email'));
            // body
            $message = $system_obj->get_template('payment_pending_email_template_body', $data, true);
            break;
        case MGM_STATUS_ERROR:
            // subject
            $subject = $system_obj->get_template('payment_error_email_template_subject', array('blogname' => $blogname), true);
            // data
            $data = array('blogname' => $blogname, 'name' => $user->display_name, 'email' => $user->user_email, 'reason' => $member->status_str, 'admin_email' => $system_obj->get_setting('admin_email'));
            // body
            $message = $system_obj->get_template('payment_error_email_template_body', $data, true);
            break;
    }
    // replace tags
    $subject = mgm_replace_email_tags($subject, $user->ID);
    $message = mgm_replace_email_tags($message, $user->ID);
    // return
    return @mgm_notify_user($user->user_email, $subject, $message);
}
 /**
  * Create  a request and redirect to PAYPAL
  *
  * @return unknown
  */
 function process_html_redirect()
 {
     // read tran id
     if (!($tran_id = $this->_read_transaction_id())) {
         return __('Transaction Id invalid', 'mgm');
     }
     // get trans
     if (!($tran = mgm_get_transaction($tran_id))) {
         return __('Transaction invalid', 'mgm');
     }
     // update pack/transaction
     mgm_update_transaction(array('module' => $this->module), $tran_id);
     // Check user id is set if subscription_purchase. issue #1049
     //issue #1080 - corrected $tran['data']['user_id'] to $tran['user_id']
     if ($tran['payment_type'] == 'subscription_purchase' && (!isset($tran['data']['user_id']) || isset($tran['data']['user_id']) && (int) $tran['data']['user_id'] < 1)) {
         return __('Transaction invalid . User id field is empty', 'mgm');
     }
     // generate
     $post_data = $this->_get_button_code($tran['data'], $tran_id);
     // log
     mgm_log($post_data, __FUNCTION__);
     // end point
     $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__);
     // reset
     $this->response = array();
     // parse to array
     parse_str($http_response, $this->response);
     // log
     mgm_log($this->response, __FUNCTION__);
     // match
     if (isset($this->response['ACK']) && strtoupper($this->response['ACK']) == 'SUCCESS') {
         // redirect to paypal site for authorization:
         $authorize_url = str_replace('[TOKEN_STRING]', $this->response['TOKEN'], $this->_get_endpoint($this->status . '_authorize'));
         // redirect
         mgm_redirect($authorize_url);
     } else {
         // check response
         if (!empty($this->response)) {
             $errors = sprintf('[code - %s]: %s - %s', $this->response['L_ERRORCODE0'], $this->response['L_SHORTMESSAGE0'], $this->response['L_LONGMESSAGE0']);
         } else {
             $errors = __('An error occured while processing the transaction.', 'mgm');
         }
         // redirect
         mgm_redirect(add_query_arg(array('status' => 'error', 'errors' => urlencode($errors)), $this->_get_thankyou_url()));
     }
     // return
     return __('Transaction could not be processed', 'mgm');
 }
예제 #7
0
    function process_html_redirect()
    {
        // read tran id
        if (!($tran_id = $this->_read_transaction_id())) {
            return __('Transaction Id invalid', 'mgm');
        }
        // get trans
        if (!($tran = mgm_get_transaction($tran_id))) {
            return __('Transaction invalid', 'mgm');
        }
        // update pack/transaction: this is to confirm the module code if it is different
        mgm_update_transaction(array('module' => $this->module), $tran_id);
        // Check user id is set if subscription_purchase. issue #1049
        if ($tran['payment_type'] == 'subscription_purchase' && (!isset($tran['data']['user_id']) || isset($tran['data']['user_id']) && (int) $tran['data']['user_id'] < 1)) {
            return __('Transaction invalid . User id field is empty', 'mgm');
        }
        // generate
        $button_code = $this->_get_button_code($tran['data'], $tran_id);
        // extra code
        $additional_code = do_action('mgm_additional_code');
        // the html
        $html = '<form action="' . $this->_get_endpoint() . '" method="post" class="mgm_form" name="' . $this->code . '_redirect_form" id="' . $this->code . '_redirect_form">
					' . $button_code . '					
					' . $additional_code . '						
					<img src="' . MGM_ASSETS_URL . 'images/ajax/ajax-loader.gif"/><br>
					<b>' . sprintf(__('Please wait, you are being redirected to %s...', 'mgm'), $this->name) . '</b>
					<input type="image" name="submit" width="0" height="0" src="https://p.simg.uol.com.br/out/pagseguro/i/botoes/pagamentos/120x53-pagar.gif" alt = "<?php _e("Pay with PagSeguro","mgm"); ?>" >
					<!--mandatory, needed for merchant gateway, KEEP AS IT IS and no line break!-->												
			  </form>				
			  <script language="javascript">document.' . $this->code . '_redirect_form.submit();</script>';
        // return
        return $html;
    }
예제 #8
0
 /**
  * Update payment notification email sent count  
  *
  * @param int $tran_id
  */
 function update_paymentemail_sent($tran_id)
 {
     if (!is_numeric($tran_id)) {
         return;
     }
     $trans = mgm_get_transaction($tran_id);
     if (!isset($trans['data']['payment_email'])) {
         $trans['data']['payment_email'] = 0;
     }
     $trans['data']['payment_email'] = (int) $trans['data']['payment_email'] + 1;
     // update
     mgm_update_transaction(array('data' => json_encode($trans['data']), 'module' => $this->module), $tran_id);
 }
예제 #9
0
    function get_button_subscribe($options = array())
    {
        // perm link
        $include_permalink = isset($options['widget']) ? false : true;
        // get trans id
        $tran_id = (int) $options['tran_id'];
        // get trans
        if (!($tran = mgm_get_transaction($tran_id))) {
            return __('Transaction invalid', 'mgm');
        }
        // generate
        $button_code = $this->_get_button_code($tran['data'], $tran_id);
        // extra code
        $additional_code = do_action('mgm_additional_code');
        // get html
        //modified the form to bypass process_html_redirect(issue#:514)
        //$html='<form action="'. $this->_get_endpoint('html_redirect',$include_permalink) .'" method="post" class="mgm_form" name="' . $this->code . '_form" id="' . $this->code . '_form">
        $html = '<form action="' . $this->_get_endpoint('return') . '" method="post" class="mgm_form" name="' . $this->code . '_form" id="' . $this->code . '_form">
					' . $button_code . '					
					' . $additional_code . '						
					<input class="mgm_paymod_logo" type="image" src="' . mgm_site_url($this->logo) . '" border="0" name="submit" alt="' . $this->name . '">	
					<div class="mgm_paymod_description">' . mgm_stripslashes_deep($this->description) . '</div>				
				</form>';
        // return
        return $html;
    }
예제 #10
0
    function process_html_redirect()
    {
        // read tran id
        if (!($tran_id = $this->_read_transaction_id())) {
            return __('Transaction Id invalid', 'mgm');
        }
        // get trans
        if (!($tran = mgm_get_transaction($tran_id))) {
            return __('Transaction invalid', 'mgm');
        }
        // Check user id is set if subscription_purchase. issue #1049
        if ($tran['payment_type'] == 'subscription_purchase' && (!isset($tran['data']['user_id']) || isset($tran['data']['user_id']) && (int) $tran['data']['user_id'] < 1)) {
            return __('Transaction invalid . User id field is empty', 'mgm');
        }
        // get user
        $user_id = $tran['data']['user_id'];
        $user = get_userdata($user_id);
        // log
        // mgm_pr($tran);
        // update pack/transaction: this is to confirm the module code if it is different
        mgm_update_transaction(array('module' => $this->module), $tran_id);
        // cc field
        // $cc_fields = $this->_get_ccfields($user, $tran);
        // validate card: This will validate card and reload the form with errors
        // if validated process_credit_card() method will be called internally
        $html = $this->validate_cc_fields_process(__FUNCTION__);
        // the html
        /*
        		$html .='<form action="'. $this->_get_endpoint('html_redirect') .'" method="post" class="mgm_form" name="' . $this->code . '_form" id="' . $this->code . '_form">
        
        					<input type="hidden" name="tran_id" value="'.$tran_id.'">
        
        					<input type="hidden" name="submit_from" value="'.__FUNCTION__.'">
        
        					'. $cc_fields .'
        
        			   </form>';
        */
        // html / icons
        ob_start();
        if (!$GLOBALS['paymill_active']) {
            paymill_load_frontend_scripts();
            // load frontend scripts
            // settings
            $GLOBALS['paymill_active'] = true;
            $country = 'DE';
            $cart_total = $tran['data']['cost'] * 100;
            $currency = $tran['data']['currency'];
            $cc_logo = plugins_url('', __FILE__) . '/../img/cc_logos_v.png';
            // form ids
            echo '<script>
			paymill_form_checkout_id = ".checkout";
			paymill_form_checkout_submit_id = "#place_order";
			paymill_shop_name = "magicmembers";
			paymill_pcidss3 = ' . (empty($GLOBALS['paymill_settings']->paymill_general_settings['pci_dss_3']) || $GLOBALS['paymill_settings']->paymill_general_settings['pci_dss_3'] != '1' ? 1 : 0) . ';
			paymill_pcidss3_lang = "' . substr(apply_filters('plugin_locale', get_locale(), $domain), 0, 2) . '";
			</script>';
            echo '<div id="payment" class="paymill_pay_button paymill_magicmembers"><form action="' . $this->_get_endpoint('return') . '" name="' . $this->code . '_form" method="post" id="' . $this->code . '_form" class="checkout">';
            require PAYMILL_DIR . 'lib/tpl/checkout_form.php';
            echo '
			<input type="submit" id="place_order" value="' . __('Pay now', 'paymill') . '"/>
			<input type="hidden" name="tran_id" value="' . $tran_id . '">
			<input type="hidden" name="submit_from" value="' . __FUNCTION__ . '">
			';
            echo '</form></div>';
        } else {
            echo '<div class="paymill_notification paymill_notification_once_only"><strong>Error:</strong> Paymill can be loaded once only on the same page.</div>';
        }
        $html = ob_get_clean();
        // return
        return $html;
    }
예제 #11
0
/** 
 * rebill notify on rebill status change
 * 
 * @param array $options saved in usermeta
 * @param int user_id
 * @return void	
 * @since 2.7
 */
function mgm_notify_on_rebill_status_change($user_id, $new_status, $old_status, $context)
{
    // system
    $system_obj = mgm_get_class('system');
    $dge = bool_from_yn($system_obj->get_setting('disable_gateway_emails'));
    $dpne = bool_from_yn($system_obj->get_setting('disable_payment_notify_emails'));
    // get member
    $member = mgm_get_member($user_id);
    // log
    // mgm_log($member, __FUNCTION__);
    // notify
    $notify = false;
    // @todo check by last_pay_date
    // check
    if (!($last_email_notify_date = get_user_option('_mgm_last_email_notify_date', $user_id))) {
        // check
        $notify = true;
        // log
        // mgm_log('Block1: ' . $last_email_notify_date . ' - ' . $member->last_pay_date . ' ' . $notify, __FUNCTION__);
    } else {
        // check
        if (!empty($member->last_pay_date) && $last_email_notify_date != $member->last_pay_date) {
            $notify = true;
        }
        // log
        // mgm_log('Block2: ' . $last_email_notify_date . ' - ' . $member->last_pay_date . ' ' . $notify, __FUNCTION__);
    }
    // notify user
    if ($notify) {
        // packs
        $s_packs = mgm_get_class('subscription_packs');
        // get user
        $user = get_userdata($user_id);
        // blog
        $blogname = get_option('blogname');
        // notify user
        if (!$dpne) {
            // get pack
            if ($member->pack_id) {
                $subs_pack = $s_packs->get_pack($member->pack_id);
            } else {
                $subs_pack = $s_packs->validate_pack($member->amount, $member->duration, $member->duration_type, $member->membership_type);
            }
            // custom
            $custom = mgm_get_transaction($member->transaction_id);
            // notify
            if (mgm_notify_user_membership_purchase($blogname, $user, $member, $custom, $subs_pack, $s_packs, $system_obj)) {
                // tracking
                update_user_option($user_id, '_mgm_last_email_notify_date', $member->last_pay_date, true);
                // log
                // mgm_log('mgm_last_email_notify_date updated: ' . $member->last_pay_date, __FUNCTION__);
                // update as email sent
                /*				
                				if( $module = mgm_is_valid_module($member->payment_info->module) ){
                					$module->update_paymentemail_sent( $member->transaction_id );	
                				}*/
                // check
                if ($module = $member->payment_info->module) {
                    // if a valid module
                    if ($obj_module = mgm_is_valid_module($module, 'payment', 'object')) {
                        $obj_module->update_paymentemail_sent($member->transaction_id);
                    }
                }
            }
        }
        // notify admin
        if (!$dge) {
            // pack duration
            $pack_duration = $s_packs->get_pack_duration($subs_pack);
            // notify admin,
            mgm_notify_admin_membership_purchase($blogname, $user, $member, $pack_duration);
        }
    }
}
 /**
  * create recurring profile
  */
 function _create_paypal_profile()
 {
     // double check
     if ($_POST['RESULT'] != 0) {
         return;
     }
     // @todo
     // void the auth
     // $this->_void_auth();
     // tran
     $tran = mgm_get_transaction($_POST['M_CUSTOM']);
     // pack
     $pack = $tran['data'];
     // log
     // mgm_log($pack, $this->module . __FUNCTION__);
     // one time billing cycle
     if (isset($pack['num_cycles']) && (int) $pack['num_cycles'] == 1) {
         // log
         mgm_log('Exit Flag for One time billing', $this->module . __FUNCTION__);
         // exit
         return;
     }
     // log
     mgm_log('Process flag to Create Profile', $this->module . __FUNCTION__);
     // user data
     $user_id = $pack['user_id'];
     $user = get_userdata($user_id);
     // item
     $item = $this->get_pack_item($pack);
     // periods
     $pay_periods = array('d' => 'DAYS', 'w' => 'WEEK', 'm' => 'MONT', 'y' => 'YEAR');
     // day not supported by Paypal
     $pay_terms = array('d' => 365, 'w' => 52, 'm' => 12, 'y' => 1);
     // secured
     $secured = array('PARTNER' => $this->setting['partner'], 'VENDOR' => $this->setting['vendor'], 'USER' => $this->setting['username'], 'PWD' => $this->setting['password'], 'MAXFAILPAYMENTS' => (int) $this->setting['max_failed_payments']);
     // greater than 0, set term to ongoing
     if ((int) $pack['num_cycles'] > 1) {
         $term = $pay_terms[$pack['duration_type']] * ($pack['num_cycles'] - 1);
         // reduce 1 since auth captures first payment right away
     } else {
         $term = 0;
     }
     // exprs
     $duration_exprs = mgm_get_class('subscription_packs')->get_duration_exprs();
     //array('d'=>'DAY','w' => 'WEEK', 'm'=>'MONTH', 'y'=>'YEAR' );
     // start date should be next billing cycle date, //date('mdY', strtotime('+1 DAY')),//MMDDYYYY
     $start_date = date('mdY', strtotime('+' . 1 * (int) $pack['duration'] . ' ' . $duration_exprs[$pack['duration_type']]));
     // method
     switch ($_POST['METHOD']) {
         case 'CC':
             // Credit Card DCC
             // comment
             $comment = sprintf('%s By %s', $item['name'], $user->user_email);
             # code...
             $data = array('TRXTYPE' => 'R', 'TENDER' => 'C', 'ACTION' => 'A', 'PROFILENAME' => $item['name'], 'ORIGID' => $_POST['PNREF'], 'START' => $start_date, 'PAYPERIOD' => $pay_periods[$pack['duration_type']], 'TERM' => $term, 'AMT' => $pack['cost'], 'EMAIL' => $user->user_email, 'DESC' => $item['name'], 'COMMENT1' => $this->_remove_special_chars($comment));
             break;
         case 'P':
             // PayPal, EC
         // PayPal, EC
         default:
             // comment
             $comment = sprintf('%s By %s', $item['name'], $user->user_email);
             # code...
             $data = array('TRXTYPE' => 'R', 'TENDER' => 'P', 'ACTION' => 'A', 'PROFILENAME' => $item['name'], 'BAID' => isset($_POST['BAID']) && !empty($_POST['BAID']) ? $_POST['BAID'] : $_POST['PNREF'], 'START' => $start_date, 'PAYPERIOD' => $pay_periods[$pack['duration_type']], 'TERM' => $term, 'AMT' => $pack['cost'], 'EMAIL' => $user->user_email, 'DESC' => $item['name'], 'COMMENT1' => $this->_remove_special_chars($comment));
             // check, notify admin
             if (!isset($_POST['BAID']) || empty($_POST['BAID'])) {
                 // subject
                 $subject = 'BAID missing in PayPal Payflow Profile Creation';
                 // message
                 $message = sprintf('BAID missing in PayPal Payflow Profile Creation, Please contact PayPal, POST DATA: %s', print_r($_POST, true));
                 // send
                 mgm_notify_admin(null, $subject, $message);
                 // log
                 mgm_log($message, $this->module . __FUNCTION__);
             }
             break;
     }
     // additional fields
     $this->_set_address_fields($user, $data);
     // merge
     $data = array_merge($secured, $data);
     // log
     mgm_log($data, $this->module . __FUNCTION__);
     // data
     $data_post = _http_build_query($data, null, '&', '', false);
     // do not encode
     // link
     $post_url = $this->_get_endpoint();
     //issue #1508
     $url_parsed = parse_url($post_url);
     // 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($post_url, $data_post, array('headers' => $http_headers, 'timeout' => 30, 'sslverify' => false));
     // parse
     $response = array();
     // parse
     parse_str($http_response, $response);
     // log
     mgm_log($response, $this->module . __FUNCTION__);
     // profile id
     if ($response['RESULT'] == 0) {
         // set in post
         $_POST['PROFILEID'] = $response['PROFILEID'];
         // set in option
         mgm_add_transaction_option(array('transaction_id' => $_POST['M_CUSTOM'], 'option_name' => strtolower($this->module . '_PROFILEID'), 'option_value' => isset($_POST['PROFILEID']) ? $_POST['PROFILEID'] : ''));
     }
 }
/**
 * Check autoresponder_notified flag for member objet, thereby ensure that AR subscription will be done only once 
 * @param unknown_type $member
 * @param unknown_type $trans_id
 */
function mgm_subscribe_to_autoresponder(&$member, $trans_id = null)
{
    // if an active user and ready to be subscribed to AR
    if (isset($member->subscribed) && bool_from_yn($member->subscribed) && $member->status == MGM_STATUS_ACTIVE) {
        // for backward compatibility
        // To skip skip previous transactions/IPN posts
        if (!is_null($trans_id)) {
            // mgm_log($trans_id .' :checking trans date', __FUNCTION__);
            $transaction = mgm_get_transaction($trans_id);
            // check transaction date+1 day to skip old transaction IPN posts
            if (strtotime('+1 day', strtotime($transaction['transaction_dt'])) < strtotime('now')) {
                return false;
            }
        }
        // check acknowledge flag. If not marked as Y, allow to subscribe
        if (isset($member->autoresponder_notified) && !bool_from_yn($member->autoresponder_notified)) {
            // set flag as notified
            $member->autoresponder_notified = 'Y';
            // return
            return true;
            //issue #1276
        } else {
            if ($member->autoresponder_notified == 'Y') {
                return true;
            }
        }
    }
    // return
    return false;
}