public function region_step($param)
 {
     $dd = explode("/", base64_decode($param));
     $date = $dd[0];
     $region_id = $dd[1];
     $message = "";
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $owner = DB::select("select a.email from users a, region_manager b where a.id = b.user_id and b.id = ?", array($region_id));
         if ($owner[0]->email != "" && filter_var($owner[0]->email, FILTER_VALIDATE_EMAIL) && Config::get("app.paypal_email") != "" && filter_var(Config::get("app.paypal_email"), FILTER_VALIDATE_EMAIL)) {
             include "include/paypal/paypal.php";
             $name = Input::get("name");
             $email = Input::get("email");
             $overall = DB::table("users")->where("permission", -1)->first();
             $owner = DB::select("select a.email from users a, region_manager b where a.id = b.user_id and b.id = ?", array($region_id));
             $amount = Input::get("amount");
             $owner_email = $owner[0]->email;
             $owner_amount = Input::get("row1_unit_price");
             $overall_email = Config::get("app.paypal_email");
             $overall_amount = Input::get("row2_unit_price");
             $fee = Input::get("row3_unit_price");
             $transactionid = "TS-RG-" . $this->generate_rand(32);
             $return_url = Config::get("app.url") . "/share/region/" . $param . "/donation/success/" . $transactionid;
             $cancel_url = Config::get("app.url") . "/share/region/" . $param . "/donation/cancel/" . $transactionid;
             DB::table("region_transaction")->insert(array("id" => $transactionid, "region_id" => $region_id, "amount" => $owner_amount, "user_id" => 0, "name" => $name, "email" => $email, "status" => -100, "created_date" => date("Y-m-d H:i:s")));
             DB::table("overall_transaction")->insert(array("id" => null, "related_transaction_id" => $transactionid, "project_id" => $region_id, "project_type" => "region", "amount" => $overall_amount, "user_id" => 0, "name" => $name, "email" => $email, "status" => -100, "created_date" => date("Y-m-d H:i:s")));
             $paypal = new Paypal();
             $receiver = array(array("amount" => $owner_amount, "email" => $owner_email), array("amount" => $overall_amount, "email" => $overall_email));
             $item = array(array("name" => "Donation for region", "identifier" => "p1", "price" => $owner_amount, "itemPrice" => $owner_amount, "itemCount" => 1), array("name" => "Response for donation", "identifier" => "p2", "price" => $overall_amount, "itemPrice" => $overall_amount, "itemCount" => 1));
             $receiverOptions = array(array("receiver" => array("email" => $owner_email), "invoiceData" => array("item" => array(array("name" => "Donation for region", "price" => $owner_amount, "identifire" => "p1")))), array("receiver" => array("email" => $overall_email), "invoiceData" => array("item" => array(array("name" => "Responsive for donation", "price" => $overall_amount, "identifire" => "p2")))));
             $paypal->splitPay($receiver, $item, $return_url, $cancel_url, $receiverOptions);
             exit;
         } else {
             $message = $this->responsebox("Project paypal address is not set yet.");
         }
     }
     $top_projects = DB::table("topproject")->get();
     $about = DB::table("about")->first();
     $about_content = !empty($about) ? $about->content : "";
     $contact = DB::table("contact_us")->first();
     if (empty($contact)) {
         $contact = array("content" => "", "phone_number" => "", "address" => "", "email" => "");
         $contact = json_decode(json_encode($contact), FALSE);
     }
     return View::make("/frontend/region_donation")->with(array("key" => "", "message" => $message, "top_projects" => $top_projects, "about_content" => $about_content, "contact" => $contact));
 }
 public function request_donation($type, $id)
 {
     include "include/paypal/paypal.php";
     $project = DB::table($type)->where("id", $id)->first();
     $amount = Input::get("amount");
     $owner_email = $project->paypal_number;
     $owner_amount = Input::get("row1_unit_price");
     $overall_email = Config::get("app.paypal_email");
     $overall_amount = Input::get("row2_unit_price");
     $fee = Input::get("row3_unit_price");
     $transactionid = "TS-PR-" . $this->generate_rand(32);
     $return_url = Config::get("app.url") . "/project/" . $type . "/" . $id . "/donation/success/" . $transactionid;
     $cancel_url = Config::get("app.url") . "/project/" . $type . "/" . $id . "/donation/cancel/" . $transactionid;
     DB::table($type . "_transaction")->insert(array("id" => $transactionid, "project_id" => $id, "amount" => $owner_amount, "user_id" => Auth::user()->id, "name" => Auth::user()->first_name . " " . Auth::user()->last_name, "email" => Auth::user()->email, "status" => -100, "created_date" => date("Y-m-d H:i:s")));
     DB::table("overall_transaction")->insert(array("id" => null, "related_transaction_id" => $transactionid, "project_id" => $id, "project_type" => $type, "amount" => $overall_amount, "user_id" => Auth::user()->id, "name" => Auth::user()->first_name . " " . Auth::user()->last_name, "email" => Auth::user()->email, "status" => -100, "created_date" => date("Y-m-d H:i:s")));
     $paypal = new Paypal();
     $receiver = array(array("amount" => $owner_amount, "email" => $owner_email), array("amount" => $overall_amount, "email" => $overall_email));
     $item = array(array("name" => "Donation for " . $project->name, "identifier" => "p1", "price" => $owner_amount, "itemPrice" => $owner_amount, "itemCount" => 1), array("name" => "Response for donation", "identifier" => "p2", "price" => $overall_amount, "itemPrice" => $overall_amount, "itemCount" => 1));
     $receiverOptions = array(array("receiver" => array("email" => $owner_email), "invoiceData" => array("item" => array(array("name" => "Donation for " . $project->name, "price" => $owner_amount, "identifire" => "p1")))), array("receiver" => array("email" => $overall_email), "invoiceData" => array("item" => array(array("name" => "Responsive for donation", "price" => $overall_amount, "identifire" => "p2")))));
     $paypal->splitPay($receiver, $item, $return_url, $cancel_url, $receiverOptions);
     exit;
 }
Ejemplo n.º 3
0
<?php

require_once "config_sql.php";
// include the file connecting to the DB
require_once "paypal_class.php";
$p = new Paypal();
$action = $_REQUEST["action"];
switch ($action) {
    case "success":
        // success case to show the user payment got success
        echo "<h1>Payment Transaction Done Successfully</h1>";
        break;
    case "cancel":
        // case cancel to show user the transaction was cancelled
        echo "<h1>Transaction Cancelled";
        break;
    case "process":
        // it performs the parallel payment
        $p->splitPay();
        break;
}
 public function project_donation($type, $id, $amount, $a = "search")
 {
     $project = DB::table($type)->where("id", $id)->first();
     if ($project->paypal_number != "" && filter_var($project->paypal_number, FILTER_VALIDATE_EMAIL) && Config::get("app.paypal_email") != "" && filter_var(Config::get("app.paypal_email"), FILTER_VALIDATE_EMAIL)) {
         include "include/paypal/paypal.php";
         $project = DB::table($type)->where("id", $id)->first();
         $owner_email = $project->paypal_number;
         $owner_amount = $amount * 0.925;
         $overall_email = Config::get("app.paypal_email");
         $overall_amount = $amount * 0.075;
         $transactionid = "TS-PR-" . $this->generate_rand(32);
         $return_url = Config::get("app.url") . "/project/" . $type . "/" . $id . "/donation/success/" . $transactionid . "/" . $a;
         $cancel_url = Config::get("app.url") . "/project/" . $type . "/" . $id . "/donation/cancel/" . $transactionid . "/" . $a;
         DB::table($type . "_transaction")->insert(array("id" => $transactionid, "project_id" => $id, "amount" => $owner_amount, "user_id" => Auth::user()->id, "name" => Auth::user()->first_name . " " . Auth::user()->last_name, "email" => Auth::user()->email, "status" => -100, "created_date" => date("Y-m-d H:i:s")));
         DB::table("overall_transaction")->insert(array("id" => null, "related_transaction_id" => $transactionid, "project_id" => $id, "project_type" => $type, "amount" => $overall_amount, "user_id" => Auth::user()->id, "name" => Auth::user()->first_name . " " . Auth::user()->last_name, "email" => Auth::user()->email, "status" => -100, "created_date" => date("Y-m-d H:i:s")));
         $paypal = new Paypal();
         $receiver = array(array("amount" => $owner_amount, "email" => $owner_email), array("amount" => $overall_amount, "email" => $overall_email));
         $item = array(array("name" => "Donation for " . $project->name, "identifier" => "p1", "price" => $owner_amount, "itemPrice" => $owner_amount, "itemCount" => 1), array("name" => "Response for donation", "identifier" => "p2", "price" => $overall_amount, "itemPrice" => $overall_amount, "itemCount" => 1));
         $receiverOptions = array(array("receiver" => array("email" => $owner_email), "invoiceData" => array("item" => array(array("name" => "Donation for " . $project->name, "price" => $owner_amount, "identifire" => "p1")))), array("receiver" => array("email" => $overall_email), "invoiceData" => array("item" => array(array("name" => "Responsive for donation", "price" => $overall_amount, "identifire" => "p2")))));
         $paypal->splitPay($receiver, $item, $return_url, $cancel_url, $receiverOptions);
         exit;
     } else {
         $error = "<div class='alert alert-danger alert-dismissable'>\n                        <button aria-hidden='true' data-dismiss='alert' class='close' type='button'>×</button>\n                        Paypal address is not set yet.\n                    </div>";
         Session::set("error", $error);
     }
 }
 public function donate($type, $id)
 {
     $message = "";
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $project = DB::table($type)->where("id", $id)->first();
         if ($project->paypal_number != "" && filter_var($project->paypal_number, FILTER_VALIDATE_EMAIL)) {
             include "include/paypal/paypal.php";
             $project = DB::table($type)->where("id", $id)->first();
             $amount = Input::get("amount");
             $name = Input::get("donator_name");
             $email = Input::get("donator_email");
             $owner_email = $project->paypal_number;
             $owner_amount = $amount * 0.925;
             $overall_email = Config::get("app.paypal_email");
             $overall_amount = $amount * 0.075;
             $transactionid = "TS-" . $this->generate_rand(32);
             $return_url = Config::get("app.url") . "/project/" . $type . "/" . $id . "/donation/success/" . $transactionid . "/dashboard";
             $cancel_url = Config::get("app.url") . "/project/" . $type . "/" . $id . "/donation/cancel/" . $transactionid . "/dashboard";
             DB::table($type . "_transaction")->insert(array("id" => $transactionid, "project_id" => $id, "amount" => $owner_amount, "user_id" => 0, "name" => $name, "email" => $email, "status" => -100, "created_date" => date("Y-m-d H:i:s")));
             DB::table("overall_transaction")->insert(array("id" => null, "related_transaction_id" => $transactionid, "project_id" => $id, "project_type" => $type, "amount" => $overall_amount, "user_id" => 0, "name" => $name, "email" => $email, "status" => -100, "created_date" => date("Y-m-d H:i:s")));
             $paypal = new Paypal();
             $receiver = array(array("amount" => $owner_amount, "email" => $owner_email), array("amount" => $overall_amount, "email" => $overall_email));
             $item = array(array("name" => "Donation for " . $project->name, "identifier" => "p1", "price" => $owner_amount, "itemPrice" => $owner_amount, "itemCount" => 1), array("name" => "Response for donation", "identifier" => "p2", "price" => $overall_amount, "itemPrice" => $overall_amount, "itemCount" => 1));
             $receiverOptions = array(array("receiver" => array("email" => $owner_email), "invoiceData" => array("item" => array(array("name" => "Donation for " . $project->name, "price" => $owner_amount, "identifire" => "p1")))), array("receiver" => array("email" => $overall_email), "invoiceData" => array("item" => array(array("name" => "Responsive for donation", "price" => $overall_amount, "identifire" => "p2")))));
             $paypal->splitPay($receiver, $item, $return_url, $cancel_url, $receiverOptions);
             exit;
         } else {
             $message = $this->responsebox("Project payment source is not set yet.");
             Session::set("error", $message);
         }
     }
     $top_projects = DB::table("topproject")->get();
     return Redirect::to("/project/view/" . $type . "/" . $id);
 }
 public function request_donation($region_id, $date)
 {
     include "include/paypal/paypal.php";
     $overall = DB::table("users")->where("permission", -1)->first();
     $owner = DB::select("select a.email from users a, region_manager b where a.id = b.user_id and b.id = ?", array($region_id));
     $amount = Input::get("amount");
     $owner_email = $owner[0]->email;
     $owner_amount = $amount * 0.925;
     $overall_email = Config::get("app.paypal_email");
     $overall_amount = $amount * 0.075;
     $transactionid = "TS-RG-" . $this->generate_rand(32);
     $return_url = Config::get("app.url") . "/region/" . $region_id . "/donation/success/" . $transactionid . "/" . $date;
     $cancel_url = Config::get("app.url") . "/region/" . $region_id . "/donation/cancel/" . $transactionid . "/" . $date;
     DB::table("region_transaction")->insert(array("id" => $transactionid, "region_id" => $region_id, "amount" => $owner_amount, "user_id" => Auth::user()->id, "name" => Auth::user()->first_name . " " . Auth::user()->last_name, "email" => Auth::user()->email, "status" => -100, "created_date" => date("Y-m-d H:i:s")));
     DB::table("overall_transaction")->insert(array("id" => null, "related_transaction_id" => $transactionid, "project_id" => $region_id, "project_type" => "region", "amount" => $overall_amount, "user_id" => Auth::user()->id, "name" => Auth::user()->first_name . " " . Auth::user()->last_name, "email" => Auth::user()->email, "status" => -100, "created_date" => date("Y-m-d H:i:s")));
     $paypal = new Paypal();
     $receiver = array(array("amount" => $owner_amount, "email" => $owner_email), array("amount" => $overall_amount, "email" => $overall_email));
     $item = array(array("name" => "Donation for region", "identifier" => "p1", "price" => $owner_amount, "itemPrice" => $owner_amount, "itemCount" => 1), array("name" => "Response for donation", "identifier" => "p2", "price" => $overall_amount, "itemPrice" => $overall_amount, "itemCount" => 1));
     $receiverOptions = array(array("receiver" => array("email" => $owner_email), "invoiceData" => array("item" => array(array("name" => "Donation for region", "price" => $owner_amount, "identifire" => "p1")))), array("receiver" => array("email" => $overall_email), "invoiceData" => array("item" => array(array("name" => "Responsive for donation", "price" => $overall_amount, "identifire" => "p2")))));
     $paypal->splitPay($receiver, $item, $return_url, $cancel_url, $receiverOptions);
     exit;
 }