コード例 #1
0
     $mail_neworder = render_cnt_template($mail_neworder, 'PAYMENT', $_tmpl['config']['label_payby_' . $payment]);
 } else {
     $mail_customer = render_cnt_template($mail_customer, 'PAYBY_' . strtoupper($payment), 'n.a.');
     $mail_neworder = render_cnt_template($mail_neworder, 'PAYMENT', 'n.a.');
     $payment = 'n.a.';
 }
 if ($subtotal['shipping_calc_type'] === 2) {
     $mail_customer = render_cnt_template($mail_customer, 'SHIPPING_DISTANCE', number_format($subtotal['shipping_distance'] / 1000, 1, $_tmpl['config']['dec_point'], $_tmpl['config']['thousands_sep']));
     $mail_neworder = render_cnt_template($mail_neworder, 'SHIPPING_DISTANCE', number_format($subtotal['shipping_distance'] / 1000, 1, $_tmpl['config']['dec_point'], $_tmpl['config']['thousands_sep']));
     $mail_customer = str_replace('{SHIPPING_DISTANCE_LABEL}', $subtotal['shipping_distance_details']['label'], $mail_customer);
     $mail_neworder = str_replace('{SHIPPING_DISTANCE_LABEL}', $subtotal['shipping_distance_details']['label'], $mail_neworder);
 } else {
     $mail_customer = render_cnt_template($mail_customer, 'SHIPPING_DISTANCE', '');
     $mail_neworder = render_cnt_template($mail_neworder, 'SHIPPING_DISTANCE', '');
 }
 $payment_options = get_payment_options();
 foreach ($payment_options as $item_key => $row) {
     $mail_customer = render_cnt_template($mail_customer, 'PAYBY_' . strtoupper($item_key), '');
     $mail_neworder = render_cnt_template($mail_neworder, 'PAYBY_' . strtoupper($item_key), '');
 }
 $mail_customer = str_replace(array('{CURRENCY_SYMBOL}', '{$}'), $_shopPref['shop_pref_currency'], $mail_customer);
 $mail_neworder = str_replace(array('{CURRENCY_SYMBOL}', '{$}'), $_shopPref['shop_pref_currency'], $mail_neworder);
 // store order in database
 $order_data = array('order_number' => $order_num, 'order_date' => gmdate('Y-m-d H:i'), 'order_name' => $_SESSION[CART_KEY]['step1']['INV_NAME'], 'order_firstname' => $_SESSION[CART_KEY]['step1']['INV_FIRSTNAME'], 'order_email' => $_SESSION[CART_KEY]['step1']['EMAIL'], 'order_net' => $subtotal['float_total_net'], 'order_gross' => $subtotal['float_total_gross'], 'order_payment' => $payment, 'order_data' => @serialize(array('cart' => $cart_data, 'address' => $_SESSION[CART_KEY]['step1'], 'mail_customer' => $mail_customer, 'mail_self' => $mail_neworder, 'subtotal' => array('subtotal_net' => $subtotal['float_net'], 'subtotal_gross' => $subtotal['float_gross']), 'shipping' => array('shipping_net' => $subtotal['float_shipping_net'], 'shipping_gross' => $subtotal['float_shipping_gross'], 'shipping_distance' => $subtotal['shipping_distance'] === false ? 0 : $subtotal['shipping_distance']), 'discount' => array('discount_net' => $subtotal['float_discount_net'], 'discount_gross' => $subtotal['float_discount_gross']), 'loworder' => array('loworder_net' => $subtotal['float_loworder_net'], 'loworder_gross' => $subtotal['float_loworder_gross']), 'weight' => $subtotal['float_weight'], 'lang' => $phpwcms['default_lang'], 'distance' => $subtotal['shipping_distance'] === false ? null : $subtotal['shipping_distance_details'])), 'order_status' => 'NEW-ORDER');
 // receive order db ID
 $order_data = _dbInsert('phpwcms_shop_orders', $order_data);
 // send mail to customer
 $email_from = _getConfig('shop_pref_email_from', '_shopPref');
 if (!is_valid_email($email_from)) {
     $email_from = $phpwcms['SMTP_FROM_EMAIL'];
 }
コード例 #2
0
function geodir_ipn_handler_googlewallet()
{
    global $wpdb;
    require_once GEODIR_PAYMENT_MANAGER_PATH . '/googlewallet/JWT.php';
    $paymentOpts = get_payment_options('googlechkout');
    $merchantkey = $paymentOpts['merchantsecret'];
    $currency_code = geodir_get_currency_type();
    $merchantid = $paymentOpts['merchantid'];
    $merchantkey = $paymentOpts['merchantsecret'];
    $encoded_jwt = $_POST['jwt'];
    $decodedJWT = JWT::decode($encoded_jwt, $merchantkey);
    $post_title = $decodedJWT->request->name;
    $payable_amount = $decodedJWT->request->price;
    // yes valid recipt
    $p_arr = explode(",", $decodedJWT->request->sellerData);
    $p_arr2 = explode(":", $p_arr[1]);
    $last_postid = $p_arr2[1];
    require_once GEODIR_PAYMENT_MANAGER_PATH . '/googlewallet/generate_token.php';
    //$encoded_jwt = $_POST['jwt'];
    // get orderId
    $orderId = $decodedJWT->response->orderId;
    if ($_POST['jwt']) {
        if ($orderId) {
            // yes valid recipt
            $p_arr = explode(",", $decodedJWT->request->sellerData);
            $p_arr2 = explode(":", $p_arr[1]);
            $postid = $p_arr2[1];
            $item_name = $decodedJWT->request->name;
            $txn_id = $orderId;
            $payment_status = 'PAID';
            $payment_type = 'Google Wallet';
            $payment_date = date("F j, Y, g:i a");
            $txn_type = $decodedJWT->typ;
            $mc_currency = $decodedJWT->request->currencyCode;
            // get curancy code
            $mc_gross = $decodedJWT->request->price;
            $mc_amount3 = $decodedJWT->request->price;
            ################################################################################################################################################################################
            global $wpdb;
            $header = '';
            // get current post status
            $current_post_status = get_post_status($postid);
            $post_pkg = geodir_get_post_meta($postid, 'package_id', true);
            /* get the post price package ID*/
            global $wpdb;
            $pricesql = $wpdb->prepare("select * from " . GEODIR_PRICE_TABLE . " where status=1 and pid=%d", array($post_pkg));
            $priceinfo = $wpdb->get_row($pricesql, ARRAY_A);
            /* Get the price package info*/
            $pkg_price = $priceinfo['amount'];
            /* get the price of the package		*/
            $currency_code = geodir_get_currency_type();
            /* get the actual curency code		*/
            $merchantid = $paymentOpts['merchantid'];
            /* Get the site paypal address*/
            if ($mc_gross) {
                $paid_amt = $mc_gross;
            } else {
                $paid_amt = $mc_amount3;
            }
            $productinfosql = $wpdb->prepare("select ID,post_title,guid,post_author from {$wpdb->posts} where ID = %d", array($postid));
            $productinfo = $wpdb->get_results($productinfosql);
            foreach ($productinfo as $productinfoObj) {
                /*$post_link = home_url().'/?ptype=preview&alook=1&pid='.$postid;*/
                $post_title = '<a href="' . get_permalink($postid) . '">' . $productinfoObj->post_title . '</a>';
                $aid = $productinfoObj->post_author;
                $userInfo = geodir_get_author_info($aid);
                $to_name = $userInfo->user_nicename;
                $to_email = $userInfo->user_email;
                $user_email = $userInfo->user_email;
            }
            /*######################################
            		######## PAYMENT SUCCESSFUL ##########
            		######################################*/
            if ($txn_type) {
                $post_default_status = geodir_new_post_default_status();
                if ($post_default_status == '') {
                    $post_default_status = 'publish';
                }
                geodir_set_post_status($postid, $post_default_status);
                $transaction_details = '';
                $paid_amount_with_currency = get_option('geodir_currencysym') . $paid_amt;
                $transaction_details .= "--------------------------------------------------<br />";
                $transaction_details .= sprintf(__("Payment Details for Listing ID #%s", GEODIRPAYMENT_TEXTDOMAIN), $postid) . "<br />";
                $transaction_details .= "--------------------------------------------------<br />";
                $transaction_details .= sprintf(__("Listing Title: %s", GEODIRPAYMENT_TEXTDOMAIN), $item_name) . "<br />";
                $transaction_details .= "--------------------------------------------------<br />";
                $transaction_details .= sprintf(__("Trans ID: %s", GEODIRPAYMENT_TEXTDOMAIN), $txn_id) . "<br />";
                $transaction_details .= sprintf(__("Status: %s", GEODIRPAYMENT_TEXTDOMAIN), $payment_status) . "<br />";
                $transaction_details .= sprintf(__("Amount: %s", GEODIRPAYMENT_TEXTDOMAIN), $paid_amount_with_currency) . "<br />";
                $transaction_details .= sprintf(__("Type: %s", GEODIRPAYMENT_TEXTDOMAIN), $payment_type) . "<br />";
                $transaction_details .= sprintf(__("Date: %s", GEODIRPAYMENT_TEXTDOMAIN), $payment_date) . "<br />";
                $transaction_details .= sprintf(__("  Method: %s", GEODIRPAYMENT_TEXTDOMAIN), $txn_type) . "<br />";
                $transaction_details .= "--------------------------------------------------<br />";
                $transaction_details .= __("Information Submitted URL", GEODIRPAYMENT_TEXTDOMAIN) . "<br />";
                $transaction_details .= "--------------------------------------------------<br />";
                $transaction_details .= "  {$post_title}<br />";
                // Extend expire date start
                $invoice_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . INVOICE_TABLE . " WHERE post_id = %d AND is_current=%s", array($postid, '1')));
                $invoice_id = $invoice_info->id;
                $invoice_package_id = '';
                if (!empty($invoice_info) && isset($invoice_info->package_id)) {
                    $invoice_package_id = $invoice_info->package_id;
                    $invoice_alive_days = $invoice_info->alive_days;
                    $invoice_status = $invoice_info->status;
                }
                $geodir_post_info = geodir_get_post_info($postid);
                if (!empty($geodir_post_info)) {
                    $post_package_id = $geodir_post_info->package_id;
                    $post_expire_date = $geodir_post_info->expire_date;
                    if (!empty($invoice_package_id) && $invoice_alive_days > 0 && $invoice_package_id == $post_package_id && strtolower($post_expire_date) != 'never' && strtotime($post_expire_date) >= strtotime(date('Y-m-d')) && $current_post_status == 'publish') {
                        $alive_days = (int) ($geodir_post_info->alive_days + $invoice_alive_days);
                        $expire_date = date('Y-m-d', strtotime($post_expire_date . "+" . $invoice_alive_days . " days"));
                    } else {
                        $alive_days = (int) $geodir_post_info->alive_days;
                        if (strtolower($post_expire_date) != 'never' && strtotime($post_expire_date) < strtotime(date('Y-m-d'))) {
                            $alive_days = $invoice_alive_days;
                        }
                        $expire_date = $alive_days > 0 ? date('Y-m-d', strtotime(date('Y-m-d') . "+" . $alive_days . " days")) : 'Never';
                    }
                    geodir_save_post_meta($postid, 'alive_days', $alive_days);
                    geodir_save_post_meta($postid, 'expire_date', $expire_date);
                }
                // Extend expire date start	end
                /*############ SET THE INVOICE STATUS START ############*/
                // update invoice statuse and transactio details
                geodir_update_invoice_status($invoice_id, 'Paid');
                geodir_update_invoice_transaction_details($invoice_id, $transaction_details);
                /*############ SET THE INVOICE STATUS END ############*/
                geodir_payment_adminEmail($postid, $aid, 'payment_success', $transaction_details);
                /*email to admin*/
                geodir_payment_clientEmail($postid, $aid, 'payment_success', $transaction_details);
                /*email to client*/
            }
            /*######################################
            	
            				######## PAYMENT SUCCESSFUL ##########
            				######################################*/
            header("HTTP/1.0 200 OK");
            echo $orderId;
        } else {
            if (strcmp($res, "INVALID") == 0) {
                geodir_payment_adminEmail($_POST['custom'], '1', 'payment_fail');
                /* email to admin*/
            }
        }
    }
}