if (add_option($order['option_order_id'], $order)) { $cp_user_orders = get_user_orders($current_user->ID); if (isset($cp_user_orders) && $cp_user_orders) { $cp_user_recent_order = $cp_user_orders[0]; } } else { $order_already_exists = true; } include_once TEMPLATEPATH . '/includes/forms/step3-membership.php'; } else { // create a unique ID for this new ad order // uniqid requires a param for php 4.3 or earlier. added for 3.0.1 if (empty($cp_user_recent_order)) { $order_id = uniqid(rand(10, 1000), false); } else { $order_id = get_order_id($cp_user_recent_order); } include_once TEMPLATEPATH . '/includes/forms/step1-membership.php'; } ?> <?php } else { ?> <h2 class="dotted"><?php _e('Membership Not Enabled', 'appthemes'); ?> </h2> <div class="info">
function cp_handle_ipn_response($_POST) { global $wpdb; //step functions required to process orders include_once "wp-load.php"; include_once TEMPLATEPATH . '/includes/forms/step-functions.php'; // make sure the ad unique trans id (stored in invoice var) is included if (!empty($_POST['txn_type']) && !empty($_POST['invoice'])) { // process the ad based on the paypal response switch (strtolower($_POST['payment_status'])) { // payment was made so we can approve the ad case 'completed': $pid = trim($_POST['invoice']); //attempt to process membership order first $orders = get_user_orders('', $pid); if (!empty($orders)) { $order_id = get_order_id($orders); $storedOrder = get_option($orders); $user_id = get_order_userid($orders); $the_user = get_userdata($user_id); if (get_option('cp_paypal_ipn_debug') == 'true' && !empty($orders)) { wp_mail(get_option('admin_email'), 'PayPal IPN Attempting to Activate Memebership', print_r($orders, true) . PHP_EOL . print_r($order, true) . PHP_EOL . print_r($_REQUEST, true)); } $order_processed = appthemes_process_membership_order($the_user, $storedOrder); } if ($order_processed) { //admin email confirmation //TODO - move into wordpress options panel and allow customization wp_mail(get_option('admin_email'), 'PayPal IPN Activated Memebership', __('A membership order has been completed. Check to make sure this is a valid order by comparing this messages Paypal Transaction ID to the respective ID in the Paypal payment receipt email.', 'appthemes') . PHP_EOL . __('Order ID: ', 'appthemes') . print_r($orders, true) . PHP_EOL . __('User ID: ', 'appthemes') . print_r($user_id, true) . PHP_EOL . __('User Login: '******'appthemes') . print_r($the_user->user_login, true) . PHP_EOL . __('Pack Name: ', 'appthemes') . print_r(stripslashes($storedOrder['pack_name']), true) . PHP_EOL . __('Total Cost: ', 'appthemes') . print_r($storedOrder['total_cost'], true) . PHP_EOL . __('Paypal Transaction ID: ', 'appthemes') . print_r($_POST['txn_id'], true) . PHP_EOL); break; } $sql = $wpdb->prepare("SELECT p.ID, p.post_status\r\n FROM {$wpdb->posts} p, {$wpdb->postmeta} m\r\n WHERE p.ID = m.post_id\r\n AND p.post_status <> 'publish'\r\n AND m.meta_key = 'cp_sys_ad_conf_id'\r\n AND m.meta_value = %s\r\n ", $pid); $newadid = $wpdb->get_row($sql); // if the ad is found, then publish it if ($newadid) { $the_ad = array(); $the_ad['ID'] = $newadid->ID; $the_ad['post_status'] = 'publish'; $ad_id = wp_update_post($the_ad); // now we need to update the ad expiration date so they get the full length of time // sometimes they didn't pay for the ad right away or they are renewing // first get the ad duration and first see if ad packs are being used // if so, get the length of time in days otherwise use the default // prune period defined on the CP settings page $ad_length = get_post_meta($ad_id, 'cp_sys_ad_duration', true); if (isset($ad_length)) { $ad_length = $ad_length; } else { $ad_length = get_option('cp_prun_period'); } // set the ad listing expiration date $ad_expire_date = date_i18n('m/d/Y H:i:s', strtotime('+' . $ad_length . ' days')); // don't localize the word 'days' //now update the expiration date on the ad update_post_meta($ad_id, 'cp_sys_expire_date', $ad_expire_date); } break; case 'pending': // send an email if payment is pending wp_mail(get_option('admin_email'), 'PayPal IPN - payment pending', "" . print_r($_POST, true)); break; // payment failed so don't approve the ad // payment failed so don't approve the ad case 'denied': case 'expired': case 'failed': case 'voided': // send an email if payment didn't work wp_mail(get_option('admin_email'), 'PayPal IPN - payment failed', "" . print_r($_POST, true)); break; } // regardless of what happens, log the transaction if (file_exists(TEMPLATEPATH . '/includes/gateways/process.php')) { include_once TEMPLATEPATH . '/includes/gateways/process.php'; } } }
function cp_handle_ipn_response() { global $wpdb; //step functions required to process orders include_once "wp-load.php"; include_once TEMPLATEPATH . '/includes/forms/step-functions.php'; // make sure the ad unique trans id (stored in invoice var) is included if (!empty($_POST['txn_id']) && !empty($_REQUEST['invoice'])) { $request_data = stripslashes_deep($_REQUEST); // process the ad based on the paypal response switch (strtolower($_POST['payment_status'])) { // payment was made so we can approve the ad case 'completed': $pid = trim($_REQUEST['invoice']); //attempt to process membership order first $orders = get_user_orders('', $pid); if (!empty($orders)) { $order_id = get_order_id($orders); $storedOrder = get_option($orders); $user_id = get_order_userid($orders); $the_user = get_userdata($user_id); if (get_option('cp_paypal_ipn_debug') == 'true' && !empty($orders)) { wp_mail(get_option('admin_email'), __('PayPal IPN Attempting to Activate Membership', APP_TD), print_r($orders, true) . PHP_EOL . print_r($order, true) . PHP_EOL . print_r($request_data, true)); } $order_processed = appthemes_process_membership_order($the_user, $storedOrder); } if ($order_processed) { //send email to user cp_owner_activated_membership_email($the_user, $order_processed); //admin email confirmation //TODO - move into wordpress options panel and allow customization wp_mail(get_option('admin_email'), __('PayPal IPN Activated Membership', APP_TD), __('A membership order has been completed. Check to make sure this is a valid order by comparing this messages Paypal Transaction ID to the respective ID in the Paypal payment receipt email.', APP_TD) . PHP_EOL . __('Order ID: ', APP_TD) . print_r($orders, true) . PHP_EOL . __('User ID: ', APP_TD) . print_r($user_id, true) . PHP_EOL . __('User Login: '******'Pack Name: ', APP_TD) . print_r(stripslashes($storedOrder['pack_name']), true) . PHP_EOL . __('Total Cost: ', APP_TD) . print_r($storedOrder['total_cost'], true) . PHP_EOL . __('Paypal Transaction ID: ', APP_TD) . print_r($_POST['txn_id'], true) . PHP_EOL); break; } $sql = $wpdb->prepare("SELECT p.ID, p.post_status\n\t\t\t\t\tFROM {$wpdb->posts} p, {$wpdb->postmeta} m\n\t\t\t\t\tWHERE p.ID = m.post_id\n\t\t\t\t\tAND p.post_status <> 'publish'\n\t\t\t\t\tAND m.meta_key = 'cp_sys_ad_conf_id'\n\t\t\t\t\tAND m.meta_value = %s\n\t\t\t\t\t", $pid); $newadid = $wpdb->get_row($sql); // if the ad is found, then publish it if ($newadid) { $the_ad = array(); $the_ad['ID'] = $newadid->ID; $the_ad['post_status'] = 'publish'; $ad_id = wp_update_post($the_ad); // now we need to update the ad expiration date so they get the full length of time // sometimes they didn't pay for the ad right away or they are renewing // first get the ad duration and first see if ad packs are being used // if so, get the length of time in days otherwise use the default // prune period defined on the CP settings page $ad_length = get_post_meta($ad_id, 'cp_sys_ad_duration', true); if (isset($ad_length)) { $ad_length = $ad_length; } else { $ad_length = get_option('cp_prun_period'); } // set the ad listing expiration date $ad_expire_date = date_i18n('m/d/Y H:i:s', strtotime('+' . $ad_length . ' days')); // don't localize the word 'days' //now update the expiration date on the ad update_post_meta($ad_id, 'cp_sys_expire_date', $ad_expire_date); } break; case 'pending': // send an email if payment is pending $mailto = get_option('admin_email'); $subject = __('PayPal IPN - payment pending', APP_TD); $headers = 'From: ' . __('ClassiPress Admin', APP_TD) . ' <' . get_option('admin_email') . '>' . "\r\n"; $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $message = __('Dear Admin,', APP_TD) . "\r\n\r\n"; $message .= sprintf(__('The following payment is pending on your %s website.', APP_TD), $blogname) . "\r\n\r\n"; $message .= __('Payment Details', APP_TD) . "\r\n"; $message .= __('-----------------', APP_TD) . "\r\n"; $message .= __('Payer PayPal address: ', APP_TD) . $_POST['payer_email'] . "\r\n"; $message .= __('Transaction ID: ', APP_TD) . $_POST['txn_id'] . "\r\n"; $message .= __('Payer first name: ', APP_TD) . $_POST['first_name'] . "\r\n"; $message .= __('Payer last name: ', APP_TD) . $_POST['last_name'] . "\r\n"; $message .= __('Payment type: ', APP_TD) . $_POST['payment_type'] . "\r\n"; $message .= __('Amount: ', APP_TD) . html_entity_decode(cp_display_price($_POST['mc_gross'], $_POST['mc_currency'], false), ENT_QUOTES, 'UTF-8') . "\r\n\r\n"; $message .= __('Full Details', APP_TD) . "\r\n"; $message .= __('-----------------', APP_TD) . "\r\n"; $message .= print_r($request_data, true) . "\r\n"; wp_mail($mailto, $subject, $message, $headers); break; // payment failed so don't approve the ad // payment failed so don't approve the ad case 'denied': case 'expired': case 'failed': case 'voided': // send an email if payment didn't work $mailto = get_option('admin_email'); $subject = __('PayPal IPN - payment failed', APP_TD); $headers = 'From: ' . __('ClassiPress Admin', APP_TD) . ' <' . get_option('admin_email') . '>' . "\r\n"; $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $message = __('Dear Admin,', APP_TD) . "\r\n\r\n"; $message .= sprintf(__('The following payment has failed on your %s website.', APP_TD), $blogname) . "\r\n\r\n"; $message .= __('Payment Details', APP_TD) . "\r\n"; $message .= __('-----------------', APP_TD) . "\r\n"; $message .= __('Payer PayPal address: ', APP_TD) . $_POST['payer_email'] . "\r\n"; $message .= __('Transaction ID: ', APP_TD) . $_POST['txn_id'] . "\r\n"; $message .= __('Payer first name: ', APP_TD) . $_POST['first_name'] . "\r\n"; $message .= __('Payer last name: ', APP_TD) . $_POST['last_name'] . "\r\n"; $message .= __('Payment type: ', APP_TD) . $_POST['payment_type'] . "\r\n"; $message .= __('Amount: ', APP_TD) . html_entity_decode(cp_display_price($_POST['mc_gross'], $_POST['mc_currency'], false), ENT_QUOTES, 'UTF-8') . "\r\n\r\n"; $message .= __('Full Details', APP_TD) . "\r\n"; $message .= __('-----------------', APP_TD) . "\r\n"; $message .= print_r($request_data, true) . "\r\n"; wp_mail($mailto, $subject, $message, $headers); break; case 'refunded': case 'reversed': case 'chargeback': // send an email if payment was refunded $mailto = get_option('admin_email'); $subject = __('PayPal IPN - payment refunded/reversed', APP_TD); $headers = 'From: ' . __('ClassiPress Admin', APP_TD) . ' <' . get_option('admin_email') . '>' . "\r\n"; $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $message = __('Dear Admin,', APP_TD) . "\r\n\r\n"; $message .= sprintf(__('The following payment has been marked as refunded on your %s website.', APP_TD), $blogname) . "\r\n\r\n"; $message .= __('Payment Details', APP_TD) . "\r\n"; $message .= __('-----------------', APP_TD) . "\r\n"; $message .= __('Payer PayPal address: ', APP_TD) . $_POST['payer_email'] . "\r\n"; $message .= __('Transaction ID: ', APP_TD) . $_POST['txn_id'] . "\r\n"; $message .= __('Payer first name: ', APP_TD) . $_POST['first_name'] . "\r\n"; $message .= __('Payer last name: ', APP_TD) . $_POST['last_name'] . "\r\n"; $message .= __('Payment type: ', APP_TD) . $_POST['payment_type'] . "\r\n"; $message .= __('Reason code: ', APP_TD) . $_POST['reason_code'] . "\r\n"; $message .= __('Amount: ', APP_TD) . html_entity_decode(cp_display_price($_POST['mc_gross'], $_POST['mc_currency'], false), ENT_QUOTES, 'UTF-8') . "\r\n\r\n"; $message .= __('Full Details', APP_TD) . "\r\n"; $message .= __('-----------------', APP_TD) . "\r\n"; $message .= print_r($request_data, true) . "\r\n"; wp_mail($mailto, $subject, $message, $headers); break; } // regardless of what happens, log the transaction if (file_exists(TEMPLATEPATH . '/includes/gateways/process.php')) { include_once TEMPLATEPATH . '/includes/gateways/process.php'; } } }
function cp_transactions() { global $wpdb, $wp_version; include_once TEMPLATEPATH . '/includes/forms/step-functions.php'; if (isset($_GET['p'])) { $page = (int) $_GET['p']; } else { $page = 1; } $per_page = 10; $start = $per_page * $page - $per_page; // check to prevent php "notice: undefined index" msg when php strict warnings is on if (isset($_GET['action'])) { $theswitch = $_GET['action']; } else { $theswitch = ''; } switch ($theswitch) { // mark transaction as paid case 'setPaid': $wpdb->update($wpdb->cp_order_info, array('payment_status' => 'Completed'), array('id' => $_GET['id'])); ?> <p style="text-align:center;padding-top:50px;font-size:22px;"><?php _e('Updating transaction entry.....', APP_TD); ?> <br /><br /><img src="<?php bloginfo('template_directory'); ?> /images/loader.gif" alt="" /></p> <meta http-equiv="refresh" content="0; URL=?page=transactions"> <?php break; // mark transaction as unpaid // mark transaction as unpaid case 'unsetPaid': $wpdb->update($wpdb->cp_order_info, array('payment_status' => 'Pending'), array('id' => $_GET['id'])); ?> <p style="text-align:center;padding-top:50px;font-size:22px;"><?php _e('Updating transaction entry.....', APP_TD); ?> <br /><br /><img src="<?php bloginfo('template_directory'); ?> /images/loader.gif" alt="" /></p> <meta http-equiv="refresh" content="0; URL=?page=transactions"> <?php break; // delete transaction entry // delete transaction entry case 'delete': if (version_compare($wp_version, '3.4', '>=')) { $wpdb->delete($wpdb->cp_order_info, array('id' => $_GET['id'])); } else { $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->cp_order_info} WHERE id = %d", $_GET['id'])); } ?> <p style="text-align:center;padding-top:50px;font-size:22px;"><?php _e('Deleting transaction entry.....', APP_TD); ?> <br /><br /><img src="<?php bloginfo('template_directory'); ?> /images/loader.gif" alt="" /></p> <meta http-equiv="refresh" content="0; URL=?page=transactions"> <?php break; // activate membership, update transaction entry // activate membership, update transaction entry case 'activateMembership': $orders = get_user_orders('', $_GET['oid']); if (!empty($orders)) { $order_id = get_order_id($orders); $storedOrder = get_option($orders); $user_id = get_order_userid($orders); $the_user = get_userdata($user_id); //activate membership $order_processed = appthemes_process_membership_order($the_user, $storedOrder); //send email to user if ($order_processed) { cp_owner_activated_membership_email($the_user, $order_processed); } //update transaction entry $wpdb->update($wpdb->cp_order_info, array('payment_status' => 'Completed'), array('custom' => $_GET['oid'])); } ?> <p style="text-align:center;padding-top:50px;font-size:22px;"><?php _e('Activating membership plan.....', APP_TD); ?> <br /><br /><img src="<?php bloginfo('template_directory'); ?> /images/loader.gif" alt="" /></p> <meta http-equiv="refresh" content="0; URL=?page=transactions"> <?php break; // show the table of all transactions // show the table of all transactions default: ?> <div class="wrap"> <div class="icon32" id="icon-themes"><br /></div> <h2><?php _e('Order Transactions', APP_TD); ?> </h2> <?php cp_admin_info_box(); ?> <table id="tblspacer" class="widefat fixed"> <thead> <tr> <th scope="col" style="width:35px;"> </th> <th scope="col"><?php _e('Payer Name', APP_TD); ?> </th> <th scope="col" style="text-align: center;"><?php _e('Payer Status', APP_TD); ?> </th> <th scope="col"><?php _e('Ad Title', APP_TD); ?> </th> <th scope="col"><?php _e('Item Description', APP_TD); ?> </th> <th scope="col" style="width:125px;"><?php _e('Transaction ID', APP_TD); ?> </th> <th scope="col"><?php _e('Payment Type', APP_TD); ?> </th> <th scope="col"><?php _e('Payment Status', APP_TD); ?> </th> <th scope="col"><?php _e('Total Amount', APP_TD); ?> </th> <th scope="col" style="width:150px;"><?php _e('Date Paid', APP_TD); ?> </th> <th scope="col" style="text-align:center;width:100px;"><?php _e('Actions', APP_TD); ?> </th> </tr> </thead> <?php // must be higher than personal edition so let's query the db $sql = "SELECT SQL_CALC_FOUND_ROWS o.*, p.post_title " . "FROM {$wpdb->cp_order_info} o, {$wpdb->posts} p " . "WHERE o.ad_id = p.id " . "ORDER BY o.id DESC LIMIT {$start},{$per_page}"; $results = $wpdb->get_results($sql); $total_pages = $wpdb->get_var("SELECT FOUND_ROWS()"); $total_pages = ceil($total_pages / $per_page); if ($results) { $rowclass = ''; $i = 1; ?> <tbody id="list"> <?php foreach ($results as $result) { $rowclass = 'even' == $rowclass ? 'alt' : 'even'; if ($result->user_id > 0) { $user = get_user_by('id', $result->user_id); $user_link = $user ? '( <a href="user-edit.php?user_id=' . $user->ID . '" title="' . __('Edit user', APP_TD) . '">' . $user->user_login . '</a> )<br />' : ''; } else { $user_link = ''; } ?> <tr class="<?php echo $rowclass; ?> "> <td style="padding-left:10px;"><?php echo $i; ?> .</td> <td><strong><?php echo $result->first_name; ?> <?php echo $result->last_name; ?> </strong><br /><?php echo $user_link; ?> <a href="mailto:<?php echo $result->payer_email; ?> "><?php echo $result->payer_email; ?> </a></td> <td style="text-align: center;"> <?php if ($result->payer_status == 'verified') { ?> <img src="<?php bloginfo('template_directory'); ?> /images/paypal_verified.gif" alt="" title="" /><br /><?php } ?> <?php echo cp_get_status_i18n($result->payer_status); ?> </td> <td><a href="post.php?action=edit&post=<?php echo $result->ad_id; ?> "><?php echo $result->post_title; ?> </a></td> <td><?php echo $result->item_name; ?> </td> <td><?php echo $result->txn_id; ?> </td> <td><?php echo ucfirst($result->payment_type); ?> </td> <td><?php echo cp_get_status_i18n($result->payment_status); ?> </td> <td><?php cp_display_price($result->mc_gross, $result->mc_currency); ?> </td> <td><?php echo mysql2date(get_option('date_format') . ' ' . get_option('time_format'), $result->payment_date); ?> </td> <td style="text-align:center"> <?php echo '<a onclick="return confirmBeforeDelete();" href="?page=transactions&action=delete&id=' . $result->id . '" title="' . __('Delete', APP_TD) . '"><img src="' . get_bloginfo('template_directory') . '/images/cross.png" alt="' . __('Delete', APP_TD) . '" /></a> '; if (strtolower($result->payment_status) == 'completed') { echo '<br /><a href="?page=transactions&action=unsetPaid&id=' . $result->id . '" title="' . __('Mark as Unpaid', APP_TD) . '">' . __('Unmark Paid', APP_TD) . '</a>'; } else { echo '<br /><a href="?page=transactions&action=setPaid&id=' . $result->id . '" title="' . __('Mark as Paid', APP_TD) . '">' . __('Mark Paid', APP_TD) . '</a>'; } ?> </td> </tr> <?php $i++; } // end for each ?> </tbody> <?php } else { ?> <tr> <td> </td><td colspan="10"><?php _e('No transactions found.', APP_TD); ?> </td> </tr> <?php } // end $results ?> </table> <!-- this is ok --> <div class="tablenav"> <div class="tablenav-pages alignright"> <?php if ($total_pages > 1) { echo paginate_links(array('base' => 'admin.php?page=transactions%_%', 'format' => '&p=%#%', 'prev_text' => __('« Previous', APP_TD), 'next_text' => __('Next »', APP_TD), 'total' => $total_pages, 'current' => $page, 'end_size' => 1, 'mid_size' => 5)); } ?> </div> </div> <div class="clear"></div> <div class="icon32" id="icon-themes"><br /></div> <h2><?php _e('Membership Orders', APP_TD); ?> </h2> <table id="tblspacer" class="widefat fixed"> <thead> <tr> <th scope="col" style="width:35px;"> </th> <th scope="col"><?php _e('Payer Name', APP_TD); ?> </th> <th scope="col" style="text-align: center;"><?php _e('Payer Status', APP_TD); ?> </th> <th scope="col"><?php _e('Item Description', APP_TD); ?> </th> <th scope="col" style="width:125px;"><?php _e('Transaction ID', APP_TD); ?> </th> <th scope="col"><?php _e('Payment Type', APP_TD); ?> </th> <th scope="col"><?php _e('Payment Status', APP_TD); ?> </th> <th scope="col"><?php _e('Total Amount', APP_TD); ?> </th> <th scope="col" style="width:150px;"><?php _e('Date Paid', APP_TD); ?> </th> <th scope="col" style="text-align:center;width:100px;"><?php _e('Actions', APP_TD); ?> </th> </tr> </thead> <?php // seperate table for membership orders $sql = "SELECT SQL_CALC_FOUND_ROWS * " . "FROM {$wpdb->cp_order_info} " . "WHERE ad_id = 0 " . "ORDER BY id DESC LIMIT {$start},{$per_page}"; $results = $wpdb->get_results($sql); $total_pages = $wpdb->get_var("SELECT FOUND_ROWS()"); $total_pages = ceil($total_pages / $per_page); if ($results) { $rowclass = ''; $i = 1; ?> <tbody id="list"> <?php foreach ($results as $result) { $rowclass = 'even' == $rowclass ? 'alt' : 'even'; if ($result->user_id > 0) { $user = get_user_by('id', $result->user_id); $user_link = $user ? '( <a href="user-edit.php?user_id=' . $user->ID . '" title="' . __('Edit user', APP_TD) . '">' . $user->user_login . '</a> )<br />' : ''; } else { $user_link = ''; } ?> <tr class="<?php echo $rowclass; ?> "> <td style="padding-left:10px;"><?php echo $i; ?> .</td> <?php $payer = get_user_by('email', $result->payer_email); ?> <?php //TODO - LOOKUP CUSTOMER BY PAYPAL EMAIL CUSTOM PROFILE FIELD ?> <td><strong><?php echo $result->first_name; ?> <?php echo $result->last_name; ?> </strong><br /><?php echo $user_link; ?> <a href="<?php if (isset($payer->ID) && $payer) { echo get_bloginfo('url') . '/wp-admin/user-edit.php?user_id=' . $payer->ID; } else { echo 'mailto:' . $result->payer_email; } ?> "><?php echo $result->payer_email; ?> </a></td> <td style="text-align: center;"> <?php if ($result->payer_status == 'verified') { ?> <img src="<?php bloginfo('template_directory'); ?> /images/paypal_verified.gif" alt="" title="" /><br /><?php } ?> <?php echo cp_get_status_i18n($result->payer_status); ?> </td> <td><?php echo $result->item_name; ?> </td> <td><?php echo $result->txn_id; ?> </td> <td><?php echo ucfirst($result->payment_type); ?> </td> <td><?php echo cp_get_status_i18n($result->payment_status); ?> </td> <td><?php cp_display_price($result->mc_gross, $result->mc_currency); ?> </td> <td><?php echo mysql2date(get_option('date_format') . ' ' . get_option('time_format'), $result->payment_date); ?> </td> <td style="text-align:center"> <?php echo '<a onclick="return confirmBeforeDelete();" href="?page=transactions&action=delete&id=' . $result->id . '" title="' . __('Delete', APP_TD) . '"><img src="' . get_bloginfo('template_directory') . '/images/cross.png" alt="' . __('Delete', APP_TD) . '" /></a> '; if (strtolower($result->payment_status) == 'completed') { echo '<br /><a href="?page=transactions&action=unsetPaid&id=' . $result->id . '" title="' . __('Mark as Unpaid', APP_TD) . '">' . __('Unmark Paid', APP_TD) . '</a>'; } else { echo '<br /><a href="?page=transactions&action=setPaid&id=' . $result->id . '" title="' . __('Mark as Paid', APP_TD) . '">' . __('Mark Paid', APP_TD) . '</a>'; if (!empty($result->custom)) { $orders = get_user_orders('', $result->custom); } else { $orders = ''; } if (!empty($orders)) { echo '<br /><a href="?page=transactions&action=activateMembership&oid=' . $result->custom . '" title="' . __('Activate membership', APP_TD) . '">' . __('Activate membership', APP_TD) . '</a>'; } } ?> </td> </tr> <?php $i++; } // end for each ?> </tbody> <?php } else { ?> <tr> <td> </td><td colspan="9"><?php _e('No transactions found.', APP_TD); ?> </td> </tr> <?php } // end $results ?> </table> <!-- this is ok --> <div class="tablenav"> <div class="tablenav-pages alignright"> <?php if ($total_pages > 1) { echo paginate_links(array('base' => 'admin.php?page=transactions%_%', 'format' => '&p=%#%', 'prev_text' => __('« Previous', APP_TD), 'next_text' => __('Next »', APP_TD), 'total' => $total_pages, 'current' => $page, 'end_size' => 1, 'mid_size' => 5)); } ?> </div> </div> <div class="clear"></div> </div><!-- end wrap --> <?php } // endswitch ?> <script type="text/javascript"> /* <![CDATA[ */ function confirmBeforeDelete() { return confirm("<?php _e('WARNING: Are you sure you want to delete this transaction entry?? (This cannot be undone)', APP_TD); ?> "); } /* ]]> */ </script> <?php }
echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?> </td> </tr> <tr> <td colspan="3"><?php echo tep_draw_separator(); ?> </td> </tr> <tr> <td colspan="2" align="right"><?php if ($nextid = get_order_id($oID, 'prev')) { echo '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID', 'action')) . 'oID=' . $nextid . '&action=edit') . '">' . tep_image(DIR_WS_ICONS . 'prev.gif', IMAGE_PREV_ORDER) . '</a> '; } if ($previd = get_order_id($oID)) { echo '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID', 'action')) . 'oID=' . $previd . '&action=edit') . '">' . tep_image(DIR_WS_ICONS . 'next.gif', IMAGE_NEXT_ORDER) . '</a> '; } echo '<a href="' . tep_href_link(FILENAME_ORDERS_EDIT, 'oID=' . $_GET['oID']) . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS_INVOICE, 'oID=' . $_GET['oID']) . '" TARGET="_blank">' . tep_image_button('button_invoice.gif', IMAGE_ORDERS_INVOICE) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS_PACKINGSLIP, 'oID=' . $_GET['oID']) . '" TARGET="_blank">' . tep_image_button('button_packingslip.gif', IMAGE_ORDERS_PACKINGSLIP) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS, 'pdf_check=invoice&oID=' . $_GET['oID']) . '" target="_blank">' . tep_image_button('button_invoice_pdf.gif', IMAGE_ORDERS_INVOICE) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS, 'pdf_check=packingslip&oID=' . $_GET['oID']) . '" target="_blank">' . tep_image_button('button_packingslip_pdf.gif', IMAGE_ORDERS_PACKINGSLIP) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('action'))) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a> '; ?> </td> <!-- *** BEGIN GOOGLE CHECKOUT *** --> <?php if (defined('MODULE_PAYMENT_GOOGLECHECKOUT_STATUS') && MODULE_PAYMENT_GOOGLECHECKOUT_STATUS == 'True') { require_once DIR_FS_CATALOG . 'googlecheckout/inserts/admin/orders3.php'; } ?> <!-- *** END GOOGLE CHECKOUT *** --> </tr> <?php } else {
function cp_bank_owner_new_membership_email($oid) { $orders = get_user_orders('', $oid); if (!empty($orders)) { $order_id = get_order_id($orders); $storedOrder = get_option($orders); $user_id = get_order_userid($orders); $the_user = get_userdata($user_id); $membership_order_id = stripslashes($order_id); $membership_pack_id = stripslashes($storedOrder['pack_id']); $membership_pack_name = stripslashes($storedOrder['pack_name']); $membership_user_email = stripslashes($the_user->user_email); $membership_user_login = stripslashes($the_user->user_login); $membership_total_cost = stripslashes($storedOrder['total_cost']); $siteurl = trailingslashit(get_option('home')); // The blogname option is escaped with esc_html on the way into the database in sanitize_option // we want to reverse this for the plain text arena of emails. $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $mailto = $membership_user_email; $subject = sprintf(__('Your Membership Purchase on %s', 'appthemes'), $blogname); $headers = 'From: ' . sprintf(__('%s Admin', 'appthemes'), $blogname) . ' <' . get_option('admin_email') . '>' . "\r\n"; $message = sprintf(__('Hi %s,', 'appthemes'), $membership_user_login) . "\r\n\r\n"; $message .= __('Thank you for your membership order! Your membership has been submitted and will not be valid on our site until you pay for it.', 'appthemes') . "\r\n\r\n"; $message .= __('Please include the following details when sending the bank transfer. Once your transfer has been verified, we will then activate your membership.') . "\r\n\r\n"; $message .= __('Details for Payment', 'appthemes') . "\r\n"; $message .= __('-----------------') . "\r\n"; $message .= __('Transaction ID: ', 'appthemes') . $membership_pack_name . "\r\n"; $message .= __('Reference #: ', 'appthemes') . $oid . "\r\n"; $message .= __('Total Amount: ', 'appthemes') . $membership_total_cost . " (" . get_option('cp_curr_pay_type') . ")\r\n"; $message .= __('-----------------') . "\r\n\r\n"; $message .= __('Bank Transfer Instructions', 'appthemes') . "\r\n"; $message .= __('-----------------') . "\r\n"; $message .= strip_tags(appthemes_br2nl(stripslashes(get_option('cp_bank_instructions')))) . "\r\n"; $message .= __('-----------------') . "\r\n\r\n"; $message .= __('For questions or problems, please contact us directly at', 'appthemes') . " " . get_option('admin_email') . "\r\n\r\n\r\n\r\n"; $message .= __('Regards,', 'appthemes') . "\r\n\r\n"; $message .= sprintf(__('Your %s Team', 'appthemes'), $blogname) . "\r\n"; $message .= $siteurl . "\r\n\r\n\r\n\r\n"; // ok let's send the email wp_mail($mailto, $subject, $message, $headers); } }
function cp_dashboard_paypal_button($the_id) { global $wpdb, $current_user; $current_user = wp_get_current_user(); $pack = get_pack($the_id); // figure out the number of days this ad was listed for if (get_post_meta($the_id, 'cp_sys_ad_duration', true)) { $prun_period = get_post_meta($the_id, 'cp_sys_ad_duration', true); } else { $prun_period = get_option('cp_prun_period'); } //setup variables depending on the purchase type if (isset($pack->pack_name) && stristr($pack->pack_status, 'membership')) { //get any existing orders $cp_user_orders = get_user_orders($current_user->ID); if (isset($cp_user_orders) && $cp_user_orders) { $cp_user_recent_order = $cp_user_orders[0]; } else { $oid = uniqid(rand(10, 1000), false); $order = array(); $order['user_id'] = $current_user->ID; $order['order_id'] = $oid; $order['option_order_id'] = 'cp_order_' . $current_user->ID . '_' . $oid; $order['pack_type'] = 'membership'; $order['total_cost'] = $pack->pack_membership_price; $order = array_merge($order, (array) $pack); if (add_option($order['option_order_id'], $order)) { $cp_user_orders = get_user_orders($current_user->ID); if (isset($cp_user_orders) && $cp_user_orders) { $cp_user_recent_order = $cp_user_orders[0]; } } } $item_name = sprintf(__('Membership on %s for %s days', 'appthemes'), get_bloginfo('name'), $pack->pack_duration); $item_number = stripslashes($pack->pack_name); $custom = get_order_id($cp_user_recent_order); $amount = $pack->pack_membership_price; $notify_url = get_bloginfo('url') . '/index.php?invoice=' . $custom; $return = CP_MEMBERSHIP_PURCHASE_CONFIRM_URL . '?oid=' . $custom; $cbt = __('Click here to complete your purchase on', 'appthemes') . ' ' . get_bloginfo('name'); } else { //by default we assume its an ad posting $item_name = sprintf(__('Classified ad listing on %s for %s days', 'appthemes'), get_bloginfo('name'), $prun_period); $item_number = get_post_meta($the_id, 'cp_sys_ad_conf_id', true); $custom = get_post_meta($the_id, 'cp_sys_ad_conf_id', true); $amount = get_post_meta($the_id, 'cp_sys_total_ad_cost', true); $notify_url = get_bloginfo('url') . '/index.php?invoice=' . get_post_meta($the_id, 'cp_sys_ad_conf_id', true) . '&aid=' . $the_id; $return = CP_ADD_NEW_CONFIRM_URL . '?pid=' . get_post_meta($the_id, 'cp_sys_ad_conf_id', true) . '&aid=' . $the_id; $cbt = __('Click here to publish your ad on', 'appthemes') . ' ' . get_bloginfo('name'); } ?> <form name="paymentform" action="<?php if (get_option('cp_paypal_sandbox') == 'true') { echo 'https://www.sandbox.paypal.com/cgi-bin/webscr'; } else { echo 'https://www.paypal.com/cgi-bin/webscr'; } ?> " method="post"> <input type="hidden" name="cmd" value="_xclick" /> <input type="hidden" name="charset" value="utf-8" /> <input type="hidden" name="business" value="<?php echo get_option('cp_paypal_email'); ?> " /> <input type="hidden" name="item_name" value="<?php echo esc_attr($item_name); ?> " /> <input type="hidden" name="item_number" value="<?php echo esc_attr($item_number); ?> " /> <input type="hidden" name="amount" value="<?php echo esc_attr($amount); ?> " /> <input type="hidden" name="no_shipping" value="1" /> <input type="hidden" name="no_note" value="1" /> <input type="hidden" name="custom" value="<?php echo esc_attr($custom); ?> " /> <input type="hidden" name="cancel_return" value="<?php echo home_url(); ?> " /> <input type="hidden" name="return" value="<?php echo esc_attr($return); ?> " /> <input type="hidden" name="rm" value="2" /> <input type="hidden" name="cbt" value="<?php echo esc_attr($cbt); ?> " /> <input type="hidden" name="currency_code" value="<?php echo esc_attr(get_option('cp_curr_pay_type')); ?> " /> <?php if (get_option('cp_enable_paypal_ipn') == 'yes') { ?> <input type="hidden" name="notify_url" value="<?php echo esc_attr($notify_url); ?> " /> <?php if (get_option('cp_paypal_sandbox') == 'true') { ?> <input type="hidden" name="test_ipn" value="1" /> <?php } ?> <?php } ?> <?php if (get_option('cp_paypal_logo_url')) { ?> <input type="hidden" name="cpp_header_image" value="<?php echo esc_attr(get_option('cp_paypal_logo_url')); ?> " /> <?php } ?> <input type="image" src="<?php bloginfo('template_directory'); ?> /images/paypal.png" name="submit" /> </form> <?php }
/** * Processes membership activation on order activation. * * @param object $order */ function cp_payments_handle_membership_activated($order) { // include all the functions needed for this action require_once get_template_directory() . '/includes/forms/step-functions.php'; foreach ($order->get_items(CP_ITEM_MEMBERSHIP) as $item) { $user = get_user_by('id', $order->get_author()); $membership_orders = get_user_orders($user->ID, false); if (empty($membership_orders)) { continue; } $order_id = get_order_id($membership_orders[0]); $stored_order = get_option($membership_orders[0]); $order_processed = appthemes_process_membership_order($user, $stored_order); if ($order_processed) { cp_owner_activated_membership_email($user, $order_processed); } } }
// Copyright (c) Romanof // Если файл загружен не из движка - завершаем программу if (!defined('SYS_LOADER')) { die; } global $engineconf, $rficb, $pmmod_conf; $engineconf = engine_conf(); if (!file_exists(PM_MODULES_DIR . "/rficb/pmmod_conf.php")) { die('Платежный модуль не настроен. Описание настройки этого модуля в файле ' . PM_MODULES_DIR . "/rficb/README.TXT"); } require_once PM_MODULES_DIR . "/rficb/pmmod_conf.php"; require_once PM_MODULES_DIR . "/rficb/rficb.php"; $rficb = new rficb(); $rficb->loadlng(); switch ($_GET['act']) { case 'result': echo $rficb->payment_result(); break; case 'fail': echo $rficb->payment_fail(); break; case 'success': echo $rficb->payment_success(); break; default: $order_id = get_order_id(); if ($order_id) { echo $rficb->payment_form($order_id); } }
</style> </head> <body> <form name="order_display" action="sales_order_management.php" method="post"> <table id="order_title"> <tr> <td colspan="3"> <label for="oid">報價單號:</label> <select name="select_oid" class="select_oid" onchange="this.form.submit()"> <?php if (isset($oid)) { echo "<option>查詢報價單</option>"; } else { echo "<option selected>查詢報價單</option>"; } $oid_array = get_order_id(); for ($i = 0; $i < count($oid_array); $i++) { if ($oid_array[$i] == $oid) { echo "<option selected>{$oid_array[$i]}</option>"; } else { echo "<option>{$oid_array[$i]}</option>"; } } ?> </select> </td> </tr> </table> <?php if (isset($data) && !empty($data)) { ?>
function cp_transactions() { global $wpdb; // check to prevent php "notice: undefined index" msg when php strict warnings is on if (isset($_GET['action'])) { $theswitch = $_GET['action']; } else { $theswitch = ''; } switch ($theswitch) { // mark transaction as paid case 'setPaid': $update = "UPDATE " . $wpdb->prefix . "cp_order_info SET payment_status = 'Completed' WHERE id = '" . $_GET['id'] . "'"; $wpdb->query($update); ?> <p style="text-align:center;padding-top:50px;font-size:22px;"><?php _e('Updating transaction entry.....', 'appthemes'); ?> <br /><br /><img src="<?php echo bloginfo('template_directory'); ?> /images/loader.gif" alt="" /></p> <meta http-equiv="refresh" content="0; URL=?page=transactions"> <?php break; // mark transaction as unpaid // mark transaction as unpaid case 'unsetPaid': $update = "UPDATE " . $wpdb->prefix . "cp_order_info SET payment_status = 'Pending' WHERE id = '" . $_GET['id'] . "'"; $wpdb->query($update); ?> <p style="text-align:center;padding-top:50px;font-size:22px;"><?php _e('Updating transaction entry.....', 'appthemes'); ?> <br /><br /><img src="<?php echo bloginfo('template_directory'); ?> /images/loader.gif" alt="" /></p> <meta http-equiv="refresh" content="0; URL=?page=transactions"> <?php break; // delete transaction entry // delete transaction entry case 'delete': $delete = "DELETE FROM " . $wpdb->prefix . "cp_order_info WHERE id = '" . $_GET['id'] . "'"; $wpdb->query($delete); ?> <p style="text-align:center;padding-top:50px;font-size:22px;"><?php _e('Deleting transaction entry.....', 'appthemes'); ?> <br /><br /><img src="<?php echo bloginfo('template_directory'); ?> /images/loader.gif" alt="" /></p> <meta http-equiv="refresh" content="0; URL=?page=transactions"> <?php break; // activate membership, update transaction entry // activate membership, update transaction entry case 'activateMembership': include_once TEMPLATEPATH . '/includes/forms/step-functions.php'; $orders = get_user_orders('', $_GET['oid']); if (!empty($orders)) { $order_id = get_order_id($orders); $storedOrder = get_option($orders); $user_id = get_order_userid($orders); $the_user = get_userdata($user_id); //activate membership $order_processed = appthemes_process_membership_order($the_user, $storedOrder); //send email to user if ($order_processed) { cp_owner_activated_membership_email($the_user, $order_processed); } //update transaction entry $update = "UPDATE " . $wpdb->prefix . "cp_order_info SET payment_status = 'Completed' WHERE custom = '" . $_GET['oid'] . "'"; $wpdb->query($update); } ?> <p style="text-align:center;padding-top:50px;font-size:22px;"><?php _e('Activating membership plan.....', 'appthemes'); ?> <br /><br /><img src="<?php echo bloginfo('template_directory'); ?> /images/loader.gif" alt="" /></p> <meta http-equiv="refresh" content="0; URL=?page=transactions"> <?php break; // show the table of all transactions // show the table of all transactions default: ?> <div class="wrap"> <div class="icon32" id="icon-themes"><br /></div> <h2><?php _e('Order Transactions', 'appthemes'); ?> </h2> <?php cp_admin_info_box(); ?> <table id="tblspacer" class="widefat fixed"> <thead> <tr> <th scope="col" style="width:35px;"> </th> <th scope="col"><?php _e('Payer Name', 'appthemes'); ?> </th> <th scope="col" style="text-align: center;"><?php _e('Payer Status', 'appthemes'); ?> </th> <th scope="col"><?php _e('Ad Title', 'appthemes'); ?> </th> <th scope="col"><?php _e('Item Description', 'appthemes'); ?> </th> <th scope="col" style="width:125px;"><?php _e('Transaction ID', 'appthemes'); ?> </th> <th scope="col"><?php _e('Payment Type', 'appthemes'); ?> </th> <th scope="col"><?php _e('Payment Status', 'appthemes'); ?> </th> <th scope="col"><?php _e('Total Amount', 'appthemes'); ?> </th> <th scope="col" style="width:150px;"><?php _e('Date Paid', 'appthemes'); ?> </th> <th scope="col" style="text-align:center;width:100px;"><?php _e('Actions', 'appthemes'); ?> </th> </tr> </thead> <?php // must be higher than personal edition so let's query the db $sql = "SELECT o.*, p.post_title " . "FROM " . $wpdb->prefix . "cp_order_info o, {$wpdb->posts} p " . "WHERE o.ad_id = p.id " . "ORDER BY o.id desc"; $results = $wpdb->get_results($sql); if ($results) { $rowclass = ''; $i = 1; ?> <tbody id="list"> <?php foreach ($results as $result) { $rowclass = 'even' == $rowclass ? 'alt' : 'even'; ?> <tr class="<?php echo $rowclass; ?> "> <td style="padding-left:10px;"><?php echo $i; ?> .</td> <td><strong><?php echo $result->first_name; ?> <?php echo $result->last_name; ?> </strong><br /><a href="mailto:<?php echo $result->payer_email; ?> "><?php echo $result->payer_email; ?> </a></td> <td style="text-align: center;"> <?php if ($result->payer_status == 'verified') { ?> <img src="<?php bloginfo('template_directory'); ?> /images/paypal_verified.gif" alt="" title="" /><br /><?php } ?> <?php echo ucfirst($result->payer_status); ?> </td> <td><a href="post.php?action=edit&post=<?php echo $result->ad_id; ?> "><?php echo $result->post_title; ?> </a></td> <td><?php echo $result->item_name; ?> </td> <td><?php echo $result->txn_id; ?> </td> <td><?php echo ucfirst($result->payment_type); ?> </td> <td><?php echo ucfirst($result->payment_status); ?> </td> <td><?php echo $result->mc_gross; ?> <?php echo $result->mc_currency; ?> </td> <td><?php echo mysql2date(get_option('date_format') . ' ' . get_option('time_format'), $result->payment_date); ?> </td> <td style="text-align:center"> <?php echo '<a onclick="return confirmBeforeDelete();" href="?page=transactions&action=delete&id=' . $result->id . '" title="' . __('Delete', 'appthemes') . '"><img src="' . get_bloginfo('template_directory') . '/images/cross.png" alt="' . __('Delete', 'appthemes') . '" /></a> '; if (strtolower($result->payment_status) == 'completed') { echo '<br /><a href="?page=transactions&action=unsetPaid&id=' . $result->id . '" title="' . __('Mark as Unpaid', 'appthemes') . '">' . __('Unmark Paid', 'appthemes') . '</a>'; } else { echo '<br /><a href="?page=transactions&action=setPaid&id=' . $result->id . '" title="' . __('Mark as Paid', 'appthemes') . '">' . __('Mark Paid', 'appthemes') . '</a>'; } ?> </td> </tr> <?php $i++; } // end for each ?> </tbody> <?php } else { ?> <tr> <td> </td><td colspan="10"><?php _e('No transactions found.', 'appthemes'); ?> </td> </tr> <?php } // end $results ?> </table> <!-- this is ok --> <div class="icon32" id="icon-themes"><br /></div> <h2><?php _e('Membership Orders', 'appthemes'); ?> </h2> <table id="tblspacer" class="widefat fixed"> <thead> <tr> <th scope="col" style="width:35px;"> </th> <th scope="col"><?php _e('Payer Name', 'appthemes'); ?> </th> <th scope="col" style="text-align: center;"><?php _e('Payer Status', 'appthemes'); ?> </th> <th scope="col"><?php _e('Item Description', 'appthemes'); ?> </th> <th scope="col" style="width:125px;"><?php _e('Transaction ID', 'appthemes'); ?> </th> <th scope="col"><?php _e('Payment Type', 'appthemes'); ?> </th> <th scope="col"><?php _e('Payment Status', 'appthemes'); ?> </th> <th scope="col"><?php _e('Total Amount', 'appthemes'); ?> </th> <th scope="col" style="width:150px;"><?php _e('Date Paid', 'appthemes'); ?> </th> <th scope="col" style="text-align:center;width:100px;"><?php _e('Actions', 'appthemes'); ?> </th> </tr> </thead> <?php // seperate table for membership orders $sql = "SELECT * " . "FROM " . $wpdb->prefix . "cp_order_info " . "WHERE ad_id = 0 " . "ORDER BY id desc"; $results = $wpdb->get_results($sql); if ($results) { $rowclass = ''; $i = 1; ?> <tbody id="list"> <?php foreach ($results as $result) { $rowclass = 'even' == $rowclass ? 'alt' : 'even'; ?> <tr class="<?php echo $rowclass; ?> "> <td style="padding-left:10px;"><?php echo $i; ?> .</td> <?php $payer = get_user_by('email', $result->payer_email); ?> <?php //TODO - LOOKUP CUSTOMER BY PAYPAL EMAIL CUSTOM PROFILE FIELD ?> <td><strong><?php echo $result->first_name; ?> <?php echo $result->last_name; ?> </strong><br /><a href="<?php if (isset($payer->ID) && $payer) { echo get_bloginfo('url') . '/wp-admin/user-edit.php?user_id=' . $payer->ID; } else { echo 'mailto:' . $result->payer_email; } ?> "><?php echo $result->payer_email; ?> </a></td> <td style="text-align: center;"> <?php if ($result->payer_status == 'verified') { ?> <img src="<?php bloginfo('template_directory'); ?> /images/paypal_verified.gif" alt="" title="" /><br /><?php } ?> <?php echo ucfirst($result->payer_status); ?> </td> <td><?php echo $result->item_name; ?> </td> <td><?php echo $result->txn_id; ?> </td> <td><?php echo ucfirst($result->payment_type); ?> </td> <td><?php echo ucfirst($result->payment_status); ?> </td> <td><?php echo $result->mc_gross; ?> <?php echo $result->mc_currency; ?> </td> <td><?php echo mysql2date(get_option('date_format') . ' ' . get_option('time_format'), $result->payment_date); ?> </td> <td style="text-align:center"> <?php echo '<a onclick="return confirmBeforeDelete();" href="?page=transactions&action=delete&id=' . $result->id . '" title="' . __('Delete', 'appthemes') . '"><img src="' . get_bloginfo('template_directory') . '/images/cross.png" alt="' . __('Delete', 'appthemes') . '" /></a> '; if (strtolower($result->payment_status) == 'completed') { echo '<br /><a href="?page=transactions&action=unsetPaid&id=' . $result->id . '" title="' . __('Mark as Unpaid', 'appthemes') . '">' . __('Unmark Paid', 'appthemes') . '</a>'; } else { echo '<br /><a href="?page=transactions&action=setPaid&id=' . $result->id . '" title="' . __('Mark as Paid', 'appthemes') . '">' . __('Mark Paid', 'appthemes') . '</a>'; } ?> </td> </tr> <?php $i++; } // end for each ?> </tbody> <?php } else { ?> <tr> <td> </td><td colspan="9"><?php _e('No transactions found.', 'appthemes'); ?> </td> </tr> <?php } // end $results ?> </table> <!-- this is ok --> </div><!-- end wrap --> <?php } // endswitch ?> <script type="text/javascript"> /* <![CDATA[ */ function confirmBeforeDelete() { return confirm("<?php _e('WARNING: Are you sure you want to delete this transaction entry?? (This cannot be undone)', 'appthemes'); ?> "); } /* ]]> */ </script> <?php }
function comSession() { $_SESSION["cache"] = 0; $_SESSION["_new"] = newIdRnd(); $_SESSION["app_path"] = "{$_SERVER['DOCUMENT_ROOT']}"; $_SESSION["root_path"] = "{$_SERVER['DOCUMENT_ROOT']}"; $_SESSION["HTTP_HOST"] = $_SERVER['HTTP_HOST']; $domain = explode(".", str_replace("www.", "", strtolower($_SERVER["HTTP_HOST"]))); if (count($domain) == 3 and $_SESSION["projects"] == "on") { if ($domain[0] != "www") { $_SESSION["project"] = $domain[0]; $_SESSION["app_path"] .= "/projects/" . $domain[0]; if (!is_dir($_SESSION["app_path"])) { //if (!is_dir($_SESSION["app_path"])) {mkdir($_SESSION["app_path"]);} } } } else { $_SESSION["project"] = ""; } $_SESSION["prj_path"] = str_replace($_SESSION["root_path"], "", $_SESSION["app_path"]); if (!isset($_SESSION["User"])) { $_SESSION["User"] = "******"; } include_once "{$_SESSION["engine_path"]}/functions.php"; if (!isset($_SESSION["order_id"])) { $_SESSION["order_id"] = get_order_id(); } if (!is_file($_SESSION["app_path"] . "/contents/dict/user_role")) { copy("{$_SESSION["engine_path"]}/uploads/__contents/dict/user_role", $_SESSION["app_path"] . "/contents/dict/user_role"); } }
<?php header('Content-type: application/json;charset=UTF-8'); include_once './func/common.php'; include_once './func/SDKConfig.php'; include_once './func/secureUtil.php'; include_once './func/encryptParams.php'; include_once './func/httpClient.php'; include_once './custom_func.php'; if (!isset($_POST['card_info'])) { die(json_encode(array('status' => 400, 'message' => 'Invalid input: card_info is required.'))); } $decrypted_post_data = decrypt_post_data($_POST['card_info']); try { $card_info = json_decode($decrypted_post_data, True); } catch (Exception $e) { die(json_encode(array('status' => 400, 'message' => 'Error parsing post data.'))); } $params = array('version' => '5.0.0', 'encoding' => 'GBK', 'certId' => getSignCertId(), 'signMethod' => '01', 'txnType' => '01', 'txnSubType' => '01', 'bizType' => '000301', 'channelType' => '07', 'backUrl' => $SDK_BACK_NOTIFY_URL, 'accessType' => '0', 'merId' => $SDK_MER_ID, 'orderId' => get_order_id(), 'txnTime' => get_order_time(), 'accType' => $card_info['acc_type'], 'accNo' => $card_info['acc_no'], 'txnAmt' => get_payment_amount(), 'currencyCode' => '156', 'customerInfo' => customerInfo($card_info['acc_no'], $card_info['certif_tp'], $card_info['certif_id'], iconv("UTF-8", "gb2312", $card_info['customer_name']), $card_info['phone_no'], $card_info['sms_code'], $card_info['pin'], $card_info['cvn2'], $card_info['expired']), 'reqReserved' => gen_callback_reserved_string(), 'encryptCertId' => getEncryptCertId(), 'payCardType' => $card_info['card_type']); // 检查字段是否需要加密 encrypt_params($params); // 签名 sign($params); // 发送信息到后台 $result = sendHttpRequest($params, $SDK_BACK_TRANS_URL); $result_array = coverStringToArray($result); if ($result_array['respCode'] != '00') { die(json_encode(array('status' => -1, 'message' => 'Error.', 'error_resp_code' => $result_array['respCode'], 'error_resp_msg' => iconv('gb2312', 'UTF-8', $result_array['respMsg'])))); } echo json_encode(array('status' => 200, 'message' => 'Success'));