function show_checkout($option, $subscription, $item_id, $proc) { global $Itemid, $JLMS_CONFIG, $my; $params = new JLMSParameters($proc->params); if (!$params->get('inst_id')) { $redirect_task = 'subscription'; if ($subscription->payment_type == 2) { $redirect_task = 'show_cart'; } JLMSredirect(sefRelToAbs("index.php?option=" . $option . "&Itemid=" . $Itemid . "&task={$redirect_task}"), "This payment method is not available at the moment.<br /> Ask site administrator to check payment method settings."); } setcookie('joomlalms_cart_contents', '', time() - 3600, '/'); // generating sites string; $prod_descr = $params->get('prod_descr'); ?> <html> <body onLoad="document.forms.ms_checkout_form.submit();"> <form action="https://select.worldpay.com/wcc/purchase" method="post" name="ms_checkout_form" id="ms_checkout_form"> <input type="hidden" name="instId" value="<?php echo $params->get('inst_id'); ?> " /> <input type="hidden" name="cartId" value="<?php echo $item_id; ?> " /> <input type="hidden" name="amount" value="<?php echo number_format($subscription->price + $subscription->tax_amount, 2, '.', ''); ?> " /> <input type="hidden" name="currency" value="<?php echo $JLMS_CONFIG->get('jlms_cur_code'); ?> " /> <input type="hidden" name="desc" value="<?php echo $subscription->name; ?> " /> <input type="hidden" name="testMode" value="<?php echo $params->get('test_mode'); ?> " /> <input type="hidden" name="MC_order" value="<?php echo $item_id; ?> " /> <input type="hidden" name="MC_tax" value="<?php echo $subscription->tax_amount; ?> " /> <input type="hidden" name="MC_user" value="<?php echo $my->id; ?> " /> </form> </body> </html> <?php die; }
function show_checkout($option, $subscription, $item_id, $proc) { global $Itemid, $JLMS_CONFIG, $JLMS_DB; $params = new JLMSParameters($proc->params); if (!$params->get('server_url') || !$params->get('business_email')) { $redirect_task = 'subscription'; if ($subscription->payment_type == 2) { $redirect_task = 'show_cart'; } JLMSredirect(sefRelToAbs("index.php?option=" . $option . "&Itemid=" . $Itemid . "&task={$redirect_task}"), "This payment method is not available at the moment.<br /> Ask site administrator to check payment method settings."); } //setcookie('joomlalms_cart_contents', '', time()-3600, '/'); JLMSCookie::setcookie('joomlalms_cart_contents', '$current_cart_cookie', time() - 3600, '/'); global $JLMS_DB; $subscr_ids = implode(',', $subscription->subscriptions); if (!$subscription->sub_name && count($subscription->subscriptions) && (strpos($params->get('item_name'), '[sub]') !== false || strpos($params->get('item_name'), '[SUB]') !== false)) { $query = "SELECT id, sub_name FROM #__lms_subscriptions WHERE id IN ({$subscr_ids})"; $JLMS_DB->SetQuery($query); $subs_names_list_db = $JLMS_DB->LoadObjectList(); //create item name from list of all subscriptions separated by comma, ordered as in cart $subs_names_list = array(); foreach ($subscription->subscriptions as $cart_sub_id) { foreach ($subs_names_list_db as $subname_item) { if ($subname_item->id == $cart_sub_id) { $subs_names_list[] = $subname_item->sub_name; break; } } } $subscription->sub_name = implode(', ', $subs_names_list); } if ($subscription->payment_type) { $query = "SELECT course_id FROM #__lms_subscriptions_courses WHERE sub_id IN (" . $subscr_ids . ")"; $JLMS_DB->SetQuery($query); $courses = $JLMS_DB->LoadResultArray(); } else { $courses = array(); } $where = ''; $whereacc = ''; $where .= " AND ps.subscr_id IN (" . $subscr_ids . ")"; $query = "SELECT p.id, p.name, p.description, p.published, p.p1, p.t1, p.p2, p.t2, p.p3, p.t3, s.a1, s.a2, s.a3, p.sra, p.src, p.srt, p.params" . "\n FROM #__lms_plans_subscriptions ps, #__lms_plans p, #__lms_subscriptions s" . "\n WHERE s.id=ps.subscr_id AND ps.plan_id=p.id AND s.account_type=6" . $where; $JLMS_DB->setQuery($query); $plan = $JLMS_DB->loadObject(); if (is_object($plan)) { $plan->tax = $subscription->tax; $plan->tax_type = $subscription->tax_type; JLMS_RECURRENT_PAY::initPricesObjects($plan); } //check if there is subscription with account_type==4 $whereacc .= " AND s.id IN (" . $subscr_ids . ")"; $query = "SELECT s.id, s.access_days" . "\n FROM #__lms_subscriptions s" . "\n WHERE s.account_type=4" . $whereacc; $JLMS_DB->setQuery($query); $subscriptionAccesses = $JLMS_DB->loadObjectList(); $adddays = 0; if ($subscriptionAccesses) { foreach ($subscriptionAccesses as $subscr) { $adddays += $subscr->access_days; } } //get user_id $query = "SELECT user_id FROM #__lms_payments WHERE id=" . $item_id; $JLMS_DB->setQuery($query); $uid = $JLMS_DB->loadResult(); ?> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> </head> <body onLoad="document.forms.jlms_checkout_form.submit();"> <?php $print_item_name = $params->get('item_name'); if (strpos($print_item_name, '[sub]') !== false || strpos($print_item_name, '[SUB]') !== false) { //compare and repalce both uppercase and lowercase strings (stri_repalce not used for PHP4 compat) $print_item_name = str_replace('[sub]', $subscription->sub_name, $print_item_name); $print_item_name = str_replace('[SUB]', $subscription->sub_name, $print_item_name); } if (!$print_item_name) { $print_item_name = $subscription->sub_name; } if (!is_object($plan)) { ?> <form action="<?php echo $params->get('server_url'); ?> " method="post" name="jlms_checkout_form" id="jlms_checkout_form" /> <input type="hidden" name="cmd" value="_xclick" /> <input type="hidden" name="business" value="<?php echo $params->get('business_email'); ?> " /> <input type="hidden" name="on0" value="Tax amount" /> <input type="hidden" name="os0" value="<?php echo $subscription->tax_amount; ?> " /> <input type="hidden" name="item_number" value="<?php echo $item_id; ?> " /> <input type="hidden" name="item_name" value="<?php echo $print_item_name; ?> " /> <input type="hidden" name="no_shipping" value="1" /> <?php if (count($courses) == 1 && $subscription->payment_type == 0) { ?> <input type="hidden" name="return" value="<?php echo JURI::root(); ?> index.php?option=<?php echo $option; ?> &Itemid=<?php echo $Itemid; ?> &task=details_course&id=<?php echo $courses[0]; ?> " /> <?php } else { ?> <input type="hidden" name="return" value="<?php echo JURI::root(); ?> index.php?option=<?php echo $option; ?> &Itemid=<?php echo $Itemid; ?> " /> <?php /* <input type="hidden" name="return" value="<?php echo $JLMS_CONFIG->get('live_site');?>/index.php?option=com_joomla_lms&task=callback&trs_id=<?php echo $item_id?>&proc=<?php echo $proc->id;?>" /> */ } ?> <input type="hidden" name="rm" value="2" /> <input type="hidden" name="cancel_return" value="<?php if ($params->get('cancel_url') == '') { echo sefRelToAbs("index.php?option=com_joomla_lms&Itemid=" . $Itemid); } else { echo $params->get('cancel_url'); } ?> "> <input type="hidden" name="notify_url" value="<?php echo JURI::root(); ?> index.php?option=com_joomla_lms&task=callback&trs_id=<?php echo $item_id; ?> &proc=<?php echo $proc->id; ?> " /> <input type="hidden" name="amount" value="<?php echo number_format($subscription->price + $subscription->tax_amount, 2, '.', ''); ?> " /> <input type="hidden" name="currency_code" value="<?php echo $JLMS_CONFIG->get('jlms_cur_code'); ?> " /> <input type="hidden" name="receiver_email" value="<?php echo $params->get('business_email'); ?> " /> <input type="hidden" name="charset" value="utf-8" /> </form> <?php } else { if ($subscription->recurrent_obj) { $plan = $subscription->recurrent_obj; } ?> <form action="<?php echo $params->get('server_url'); ?> " method="post" name="jlms_checkout_form" id="jlms_checkout_form"> <input type="hidden" name="cmd" value="_xclick-subscriptions" /> <input type="hidden" name="business" value="<?php echo $params->get('business_email'); ?> " /> <input type="hidden" name="item_name" value="<?php echo $print_item_name; ?> " /> <input type="hidden" name="item_number" value="<?php echo $item_id; ?> " /> <input type="hidden" name="no_shipping" value="1" /> <input type="hidden" name="rm" value="2" /> <input type="hidden" name="no_note" value="1" /> <input type="hidden" name="currency_code" value="<?php echo $JLMS_CONFIG->get('jlms_cur_code'); ?> " /> <?php if (count($courses) == 1 && $subscription->payment_type == 0) { ?> <input type="hidden" name="return" value="<?php echo JURI::root(); ?> index.php?option=<?php echo $option; ?> &Itemid=<?php echo $Itemid; ?> &task=details_course&id=<?php echo $courses[0]; ?> " /> <?php } else { ?> <input type="hidden" name="return" value="<?php echo JURI::root(); ?> index.php?option=<?php echo $option; ?> &Itemid=<?php echo $Itemid; ?> " /> <?php /* <input type="hidden" name="return" value="<?php echo $JLMS_CONFIG->get('live_site');?>/index.php?option=com_joomla_lms&task=callback&trs_id=<?php echo $item_id?>&proc=<?php echo $proc->id;?>" /> */ ?> <?php } ?> <input type="hidden" name="cancel_return" value="<?php if ($params->get('cancel_url') == '') { echo sefRelToAbs("index.php?option=com_joomla_lms&Itemid=" . $Itemid); } else { echo $params->get('cancel_url'); } ?> " /> <input type="hidden" name="notify_url" value="<?php echo JURI::root(); ?> index.php?option=com_joomla_lms&task=callback&trs_id=<?php echo $item_id; ?> &proc=<?php echo $proc->id; ?> &subscr=1" /> <?php //if is basic then no other parameters should be considered if ($plan->price1->showPrice() || $plan->price1->isPeriodTrial()) { ?> <input type="hidden" name="a1" value="<?php echo $plan->price1->get('a'); ?> "/> <input type="hidden" name="p1" value="<?php echo $plan->price1->get('p'); ?> "/> <input type="hidden" name="t1" value="<?php echo $plan->t1; ?> "/> <?php } if ($plan->price2->showPrice()) { ?> <input type="hidden" name="a2" value="<?php echo $plan->price2->get('a'); ?> "/> <input type="hidden" name="p2" value="<?php echo $plan->price2->get('p'); ?> "/> <input type="hidden" name="t2" value="<?php echo $plan->t2; ?> "/> <?php } ?> <input type="hidden" name="a3" value="<?php echo $plan->price3->get('a'); ?> "/> <input type="hidden" name="p3" value="<?php echo $plan->price3->get('p'); ?> "/> <input type="hidden" name="t3" value="<?php echo $plan->t3; ?> "/> <?php if ($plan->src && $plan->price3->get('srt') != 1) { ?> <input type="hidden" name="srt" value="<?php echo $plan->price3->get('srt'); ?> "/> <input type="hidden" name="src" value="<?php echo $plan->src; ?> "/> <input type="hidden" name="sra" value="<?php echo $plan->sra; ?> "> <?php } ?> <input type="hidden" name="charset" value="utf-8" /> </form> <?php } ?> <?php /*<br /><br /><br /><br /><br /><br /> <center> <img class="JLMS_png" src="<?php echo $JLMS_CONFIG->get('live_site') . '/' . $JLMS_CONFIG->get('lms_path_to_images', 'components/com_joomla_lms/lms_images');?>/loading.gif" width="32" height="32" border="0" alt="..." title="..." /> </center> */ ?> </body> </html> <?php die; }
function show_checkout($option, $subscription, $item_id, $proc) { global $Itemid, $my, $JLMS_CONFIG; $params = new JLMSParameters($proc->params); if (!$params->get('x_login')) { $redirect_task = 'subscription'; if ($subscription->payment_type == 2) { $redirect_task = 'show_cart'; } JLMSredirect(sefRelToAbs("index.php?option=" . $option . "&Itemid=" . $Itemid . "&task={$redirect_task}"), "This payment method is not available at the moment.<br /> Ask site administrator to check payment method settings."); } setcookie('joomlalms_cart_contents', '', time() - 3600, '/'); // generating sites string; $item_name = $params->get('item_name'); ?> <html> <body onLoad="document.forms.ms_checkout_form.submit();"> <form action="https://www2.2checkout.com/2co/buyer/purchase" method="post" name="ms_checkout_form" id="ms_checkout_form"> <input type="hidden" name="x_login" value="<?php echo $params->get('x_login'); ?> " /> <input type="hidden" name="x_amount" value="<?php echo number_format($subscription->price + $subscription->tax_amount, 2, '.', ''); ?> " /> <input type="hidden" name="x_invoice_num" value="<?php echo $item_id; ?> " /> <input type="hidden" name="x_receipt_link_url" value="<?php echo sefRelToAbs('index.php?option=com_joomla_lms&task=callback&proc=' . $proc->id); ?> "/> <input type="hidden" name="x_email" value="<?php echo $my->email; ?> " /> <?php if ($params->get('demo')) { ?> <input type="hidden" name="demo" value="Y" /> <?php } ?> <input type="hidden" name="x_email_merchant" value="<?php echo $params->get('x_email_merchant'); ?> " /> <input type="hidden" name="fixed" value="Y"/> <input type="hidden" name="lang" value="<?php echo $params->get('lang'); ?> " /> <input type="hidden" name="return_url" value="<?php if ($params->get('return_url') == '') { echo sefRelToAbs($JLMS_CONFIG->get('live_site') . "/index.php?option=" . $option . "&Itemid=" . $Itemid); } else { echo $params->get('return_url'); } ?> " /> <input type="hidden" name="pay_method" value="<?php echo $params->get('pay_method'); ?> " /> <input type="hidden" name="custom" value="<?php echo $item_id; ?> " /> <input type="hidden" name="userid" value="<?php echo $my->id; ?> " /> <input type="hidden" name="tax_amount" value="<?php echo $subscription->tax_amount; ?> " /> </form> </body> </html> <?php die; }