Ejemplo n.º 1
0
function process_payment($invoice_id = null, $params)
{
    $success = false;
    $invoice = PackageInvoice::find_by_id($invoice_id);
    // process payment
    $clint = Employer::find_by_id($invoice->fk_employer_id);
    if ($invoice->cv_views == "Y") {
        $clint->cv_qty = $invoice->posts_quantity;
        $clint->add_cvs();
        $success = true;
    }
    if ($invoice->spotlight == "Y") {
        $clint->spotlight_qty = $invoice->posts_quantity;
        $clint->add_more_spotlight_job_post();
        $success = true;
    }
    if ($invoice->standard == "Y") {
        $clint->job_qty = $invoice->posts_quantity;
        $clint->add_more_job_post();
        $success = true;
    } else {
    }
    if ($success) {
        $invoice->package_status = 'Completed';
        $invoice->processed_date = date("Y-m-d H:i:s", time());
        $invoice->update_package_status();
        $invoice_item = new Invoice();
        /* start **/
        /**		
        		$param['payment_status'] = ""; //what is the status of the payment
        		$param['amount'] = ""; // how much was paid for this total amount for each item
        		$param['currency'] = ""; //what currecy they used to pay for this
        		$param['receiver_id'] = ""; // what is the id of person who is paying
        		$param['payment_email']; // what email have they used to pay
        		$param['txn_id'] = ""; // txt id
        		$param['txn_type'] = ""; // how are they pay for this web or ext.
        		$param['payer_status'] = ""; //is user verfied by the method they pay from
        		$param['residence_country'] = ""; //which country does user belogn to
        		//$param['origin'] = ""; //where is the payment come from
        		$param['payment_method'] = ""; // what methoid of payment they used e.g. paypal, ccbill
        		$param['payment_vars'] = ""; //get all var which are return from online site.
        		$param['payment_type'] = ""; //how they pay for this
        		$param['reason'] = ""; // if they cancel then tell user why
        **/
        $invoice_item->fk_invoice_id = $invoice_id;
        $invoice_item->payment_status = $params['payment_status'];
        $invoice_item->payment_type = $params['payment_type'];
        $invoice_item->amount = $params['amount'];
        $invoice_item->currency = $params['currency'];
        $invoice_item->receiver_id = $params['receiver_id'];
        $invoice_item->payment_email = $params['payment_email'];
        $invoice_item->txn_id = $params['txn_id'];
        $invoice_item->txn_type = $params['txn_type'];
        $invoice_item->payer_status = $params['payer_status'];
        $invoice_item->residence_country = $params['residence_country'];
        $invoice_item->payment_date = date("Y-m-d H:i:s", time());
        $invoice_item->reason = $params['reason'];
        $invoice_item->origin = $params['payment_method'];
        $invoice_item->payment_vars = $params['payment_vars'];
        if ($invoice_item->save()) {
            /** EMAIL TEXT **/
            $email_template = get_lang('email_template', 'confirm_order');
            $subject = str_replace("#SiteName#", SITE_NAME, $email_template['email_subject']);
            $body = $email_template['email_text'];
            $body = str_replace("#FullName#", $clint->full_name(), $body);
            $body = str_replace("#SiteName#", SITE_NAME, $body);
            $body = str_replace("#InvoiceId#", $invoice_id, $body);
            $body = str_replace("#Qty#", $invoice->posts_quantity, $body);
            $body = str_replace("#Amount#", $invoice->amount, $body);
            $body = str_replace("#PayMethod#", 'None', $body);
            $body = str_replace("#Domain#", $_SERVER['HTTP_HOST'], $body);
            $body = str_replace("#ContactUs#", ADMIN_EMAIL, $body);
            $body = str_replace("#Link#", BASE_URL, $body);
            $to = array("email" => $clint->email_address, "name" => $clint->full_name());
            $from = array("email" => NO_REPLY_EMAIL, "name" => SITE_NAME);
            /** end email text **/
            $mail = send_mail($body, $subject, $to, $from, "", "");
            //redirect_to(BASE_URL."employer/credits/");
            //die;
            return $mail;
        }
    }
    return false;
}
Ejemplo n.º 2
0
            $packageinvoice->amount = $package->package_price;
            $packageinvoice->item_name = $package->package_name;
            $packageinvoice->subscr_date = "";
            $packageinvoice->payment_method = "";
            $packageinvoice->currency_code = "";
            $packageinvoice->currency_rate = "";
            $packageinvoice->reason = "";
            if ($packageinvoice && $packageinvoice->save()) {
                $invoice_id = $db->insert_id();
            } else {
            }
        }
    }
    $packageinvoice->id = $invoice_id;
    $packageinvoice->delete_inactive_invoice();
    $found_invoice = PackageInvoice::find_by_id($invoice_id);
    if (!$found_invoice) {
        redirect_to(BASE_URL . "employer/credits/");
    }
    $smarty->assign('found_invoice', $found_invoice);
} else {
    redirect_to(BASE_URL . "employer/credits/");
}
//payment_method.tpl
$PaymentModules = PaymentModules::find_all_active();
if ($PaymentModules) {
    $i = 1;
    $manage_lists = array();
    foreach ($PaymentModules as $row) {
        $manage_lists[$i]['id'] = $row->id;
        $manage_lists[$i]['name'] = $row->name;
//confirmation_page.php
if (FREE_SITE == "Y") {
    redirect_to(BASE_URL . "employer/account/");
    die;
}
$invoice_id = (int) $_REQUEST['invoice_id'];
$payment_method = $_REQUEST['payment_method'];
if (!isset($invoice_id)) {
    redirect_to(BASE_URL . "employer/credits/");
}
$user_id = $session->get_user_id();
$smarty->assign('user_id', $user_id);
$username = $session->get_username();
$smarty->assign('username', $username);
$user = Employer::find_by_id($user_id);
$packageinvoice = PackageInvoice::find_by_id($invoice_id);
$status = 'Confirmed';
$packageinvoice->package_status = $status;
$packageinvoice->payment_method = $payment_method;
if ($packageinvoice->amount == 0.0) {
    $payment_method = 'free';
    $packageinvoice->payment_method = 'free';
}
//
if ($packageinvoice->amount != 0.0 && $payment_method == 'free') {
    $session->message("<div class='error'>" . format_lang('error', 'noPaymentSelected') . "</div>");
    redirect_to(BASE_URL . "employer/credits/");
    exit;
}
$packageinvoice->save();
$smarty->assign('p_invoice', $packageinvoice);
Ejemplo n.º 4
0
            $body = str_replace("#Domain#", $_SERVER['HTTP_HOST'], $body);
            $body = str_replace("#ContactUs#", ADMIN_EMAIL, $body);
            $body = str_replace("#Link#", BASE_URL, $body);
            $to = array("email" => $clint->email_address, "name" => $clint->full_name());
            $from = array("email" => NO_REPLY_EMAIL, "name" => SITE_NAME);
            /** end email text **/
            $mail = send_mail($body, $subject, $to, $from, "", "");
            redirect_to(BASE_URL . "employer/credits/");
            die;
        }
    }
}
if (isset($_POST['bt_confirm'])) {
    if ($package_invoice->package_status != "Confirmed") {
        $id = $package_invoice->id;
        $packageinvoice = new PackageInvoice();
        $packageinvoice->id = $id;
        $packageinvoice->package_status = "Confirmed";
        $packageinvoice->update_package_status();
    }
    $package_invoice = PackageInvoice::find_by_id($_POST['invoice_id']);
    $smarty->assign('package_invoice', $package_invoice);
} else {
    redirect_to(BASE_URL . "employer/credits/");
    die;
}
$smarty->assign('dont_include_left', true);
$html_title = SITE_NAME . " - Credits ";
$smarty->assign('lang', $lang);
$smarty->assign('message', $message);
$smarty->assign('rendered_page', $smarty->fetch('employer/payment.tpl'));
Ejemplo n.º 5
0
function processing($payment_status, $params)
{
    global $paypal_email, $paypal_currency;
    $invoice_id = $params['item_number'];
    $invoice = PackageInvoice::find_by_id($invoice_id);
    switch ($payment_status) {
        case "Canceled_Reversal":
            $invoice->package_status = 'Canceled_Reversal';
            $invoice->update_package_status();
            break;
        case "Completed":
            if ($paypal_email == $params['receiver_email'] && $paypal_currency == $params['mc_currency'] && $invoice->amount == $params['mc_gross'] && $invoice->package_status != "Completed") {
                $param['payment_status'] = "Completed";
                //what is the status of the payment
                $param['amount'] = $params['mc_gross'];
                // how much was paid for this total amount for each item
                $param['currency'] = $paypal_currency;
                //what currecy they used to pay for this
                $param['receiver_id'] = $params['receiver_id'];
                // what is the id of person who is paying
                $param['payment_email'] = $params['payer_email'];
                // what email have they used to pay
                $param['txn_id'] = $params['txn_id'];
                // txt id
                $param['txn_type'] = $params['txn_type'];
                // how are they pay for this web or ext.
                $param['payer_status'] = $params['payer_status'];
                //is user verfied by the method they pay from
                $param['residence_country'] = $params['residence_country'];
                //which country does user belogn to
                //$params['origin'] = ""; //where is the payment come from
                $param['payment_method'] = "paypal";
                // what methoid of payment they used e.g. paypal, ccbill
                $param['payment_vars'] = addslashes(serialize($params));
                //get all var which are return from online site.
                $param['payment_type'] = $params['payment_type'];
                //how they pay for this
                $param['reason'] = "";
                // if they cancel then tell user why
                process_payment($invoice_id, $param);
            }
            break;
        case "Denied":
            // denied by merchant
            //$invoice->id = $invoice_id;
            $invoice->package_status = 'Denied';
            $invoice->update_package_status();
            break;
        case "Failed":
            // only happens when payment is from customers' bank account
            //$invoice->id = $invoice_id;
            $invoice->package_status = 'Failed';
            $invoice->update_package_status();
            break;
        case "Pending":
            //$invoice->id = $invoice_id;
            $invoice->package_status = 'Pending';
            $invoice->update_package_status();
            break;
        case "Refunded":
            //$invoice->id = $invoice_id;
            $invoice->package_status = 'Refunded';
            $invoice->update_package_status();
            break;
        case "Reversed":
            //$invoice->id = $invoice_id;
            $invoice->package_status = 'Reversed';
            $invoice->update_package_status();
            break;
        case "Expired":
            //$invoice->id = $invoice_id;
            $invoice->package_status = 'Expired';
            $invoice->update_package_status();
            break;
        default:
            break;
    }
}