示例#1
0
文件: paypal.php 项目: tareqy/Caracal
 /**
  * Public function that creates a single instance
  */
 public static function getInstance()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
示例#2
0
 public function action_ipn()
 {
     //todo delete
     //paypal::validate_ipn();
     $this->auto_render = FALSE;
     //START PAYPAL IPN
     //manual checks
     $id_order = Core::post('item_number');
     $paypal_amount = Core::post('mc_gross');
     $payer_id = Core::post('payer_id');
     //retrieve info for the item in DB
     $order = new Model_Order();
     $order = $order->where('id_order', '=', $id_order)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
     if ($order->loaded()) {
         //same amount and same currency
         if (Core::post('payment_status') == 'Completed' and Core::post('mc_gross') == number_format($order->amount, 2, '.', '') and Core::post('mc_currency') == $order->currency and Core::post('receiver_email') == core::config('payment.paypal_account') || Core::post('business') == core::config('payment.paypal_account')) {
             //same price , currency and email no cheating ;)
             if (paypal::validate_ipn()) {
                 $order->confirm_payment('paypal', Core::post('txn_id'), NULL, NULL, NULL, Core::post('mc_fee'));
             } else {
                 Kohana::$log->add(Log::ERROR, 'A payment has been made but is flagged as INVALID');
                 $this->response->body('KO');
             }
         } else {
             Kohana::$log->add(Log::ERROR, 'Attempt illegal actions with transaction');
             $this->response->body('KO');
         }
     } else {
         Kohana::$log->add(Log::ERROR, 'Order not loaded');
         $this->response->body('KO');
     }
     $this->response->body('OK');
 }
示例#3
0
 public function action_ipn()
 {
     //todo delete
     //paypal::validate_ipn();
     $this->auto_render = FALSE;
     //START PAYPAL IPN
     //manual checks
     $id_order = Core::post('item_number');
     $paypal_amount = Core::post('mc_gross');
     $payer_id = Core::post('payer_id');
     //retrieve info for the item in DB
     $order = new Model_Order();
     $order = $order->where('id_order', '=', $id_order)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
     if ($order->loaded()) {
         // detect product to be processed
         if (is_numeric($order->id_product)) {
             $id_category = new Model_Category();
             $id_category = $id_category->where('id_category', '=', $order->id_product)->limit(1)->find();
             $product_id = $id_category->id_category;
         } else {
             $product_id = $order->id_product;
         }
         if (Core::post('mc_gross') == number_format($order->amount, 2, '.', '') && Core::post('mc_currency') == core::config('payment.paypal_currency') && (Core::post('receiver_email') == core::config('payment.paypal_account') || Core::post('business') == core::config('payment.paypal_account'))) {
             //same price , currency and email no cheating ;)
             if (paypal::validate_ipn()) {
                 $order->confirm_payment($id_order, core::config('general.moderation'));
             } else {
                 Kohana::$log->add(Log::ERROR, 'A payment has been made but is flagged as INVALID');
                 $this->response->body('KO');
             }
         } else {
             Kohana::$log->add(Log::ERROR, 'Attempt illegal actions with transaction');
             $this->response->body('KO');
         }
     } else {
         Kohana::$log->add(Log::ERROR, 'Order not loaded');
         $this->response->body('KO');
     }
     $this->response->body('OK');
 }
示例#4
0
<?php

include_once 'config/db_conn.php';
include_once 'db_config/db_admin_paypal_id.php';
$paypal = new paypal();
$rs_paypal = $paypal->paypal_list();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Orders - Admin </title>
<link rel="stylesheet" type="text/css" href="css/theme.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script>
   var StyleFile = "theme" + document.cookie.charAt(6) + ".css";
   document.writeln('<link rel="stylesheet" type="text/css" href="css/' + StyleFile + '">');
</script>
<script>
function confirmDelete(delUrl) {
  if (confirm("Are you sure you want to delete")) {
    document.location = delUrl;
  }
}
</script>
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="css/ie-sucks.css" />
<![endif]-->
</head>

<body>
示例#5
0
     echo 'number';
 } else {
     if (!isset($expire_month)) {
         echo 'expire_month';
     } else {
         if (!isset($expire_year)) {
             echo 'expire_year';
         } else {
             if (!isset($first_name)) {
                 echo 'first_name';
             } else {
                 if (!isset($last_name)) {
                     echo 'last_name';
                 } else {
                     require_once '/home/areality/public_html/futurestore/paypal/rest-apis/requests.php';
                     $paypal = new paypal();
                     $type = strtolower($type);
                     $credit_card = array("type" => $type, "number" => $number, "expire_month" => $expire_month, "expire_year" => $expire_year, "first_name" => $first_name, "last_name" => $last_name);
                     $response = $paypal->store_cc($credit_card);
                     $bodyname = $response['body']->name;
                     $cc_state = $response['body']->state;
                     if ($bodyname == 'VALIDATION_ERROR') {
                         $details = $response['body']->details;
                         for ($i = 0; $i < count($details); $i++) {
                             $issues['errors'][] = ReadableNames($details[$i]->field) . ': ' . $details[$i]->issue;
                         }
                         $issues['error_count'] = count($details);
                         echo json_encode($issues);
                     } else {
                         if ($cc_state == 'ok') {
                             $id_cc = $response['body']->id;
示例#6
0
<?php

//$ccid = "CARD-35Y54265JC7133454KFM5G4I";
//require_once('/home/areality/public_html/futurestore/_debug.php');
if (!isset($ccid)) {
    echo 'ccid needed';
} else {
    require_once '/home/areality/public_html/futurestore/paypal/rest-apis/requests.php';
    $paypal = new paypal();
    $response = $paypal->fetch_cc($ccid);
    $state = $response['body']->state;
    if ($state == 'ok') {
        $json['state'] = 'ok';
    } else {
        $json['state'] = 'expired';
    }
    echo json_encode($json);
}
示例#7
0
<?php

//require_once('/home/areality/public_html/futurestore/_debug.php');
if (!isset($ccid)) {
    echo 'ccid needed';
} else {
    if (!isset($price)) {
        echo 'price needed';
    } else {
        require_once '/home/areality/public_html/futurestore/paypal/rest-apis/requests.php';
        $paypal = new paypal();
        $request = '{
  "intent":"sale",
  "redirect_urls":{
    "return_url":"http://www.return.com",
    "cancel_url":"http://www.cancel.com"
  },
  "payer":{
    "payment_method":"credit_card",
	"funding_instruments":[
	 {
		"credit_card_token":{
			"credit_card_id":"CARD-6FT46537T0847725XKKEJMLY"
		}
	 }
	]
  },
  "transactions":[
    {
      "amount":{
        "total":"' . $price . '",
示例#8
0
        echo '<form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="paypal">
			<input type="hidden" name="no_note" value="1">
			<input type="hidden" name="cmd" value="_xclick">
			<input type="hidden" name="item_name" value="' . _PEDIDO . '">
			<input type="hidden" name="item_number" value="' . $codPedido . '">
			<input type="hidden" name="amount" value="100.00">
			<input type="hidden" name="no_shipping" value="1">
			<input type="hidden" name="rm" value="2">
			<input type="hidden" name="return" value="' . $urlBack . '">
			<input type="hidden" name="cancel_return" value="http://nok.php">
			' . $parametros . '
			</form>';
        echo '<p><br><br><a class="botlink" href="javascript:document.paypal.submit()">' . _REALIZAR_PAGO_MEDIANTE . ' PayPal</a>';
        echo '
		<SCRIPT language="JavaScript">
			setTimeout(\'sendForm()\',5000)
				
			function sendForm(){
			  document.paypal.submit();
			}
		</SCRIPT> ';
    }
}
//// OFICIAL /////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
/** @main_class_definition oficial_paypal */
class paypal extends oficial_paypal
{
}
$iface_paypal = new paypal();
$iface_paypal->contenidos($codigo);
示例#9
0
<?php

session_start();
include_once 'config/db_conn.php';
include_once 'db_config/db_gigs.php';
include_once 'db_config/db_admin_paypal_id.php';
$paypal = new paypal();
$rs_paypal = $paypal->uniq_paypal_list('id', 1);
$data_paypal = mysql_fetch_array($rs_paypal);
$arr_var = explode('_', $_REQUEST['title']);
$gigs_title = str_replace('-', ' ', $arr_var[3]);
if ($_REQUEST['title'] != '') {
    //
    //
}
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php 
echo SITE_TITLE;
?>
</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="javascript/jquery.min.js"></script>
<script type="text/javascript" src="javascript/jquery.simplemodal.js"></script>
<script type="text/javascript" src="javascript/init.js"></script>
<script type="text/javascript" src="javascript/init1.js"></script>
示例#10
0
<?php

include_once 'config/db_conn.php';
include_once 'db_config/db_admin_paypal_id.php';
$paypal = new paypal();
$rs_paypal = $paypal->uniq_paypal_list('id', 1);
$data_paypal = mysql_fetch_array($rs_paypal);
if ($_REQUEST['submit']) {
    $table = 'ninerr_admin_paypal_id';
    $paypal_id = $_REQUEST['paypal_id'];
    $dataArray = array("paypal_id" => $paypal_id);
    $fldArray = array("id" => 1);
    $paypal->dataUpdate($table, $dataArray, $fldArray);
    reDirect('paypal_desc.php');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Orders - Admin</title>
<link rel="stylesheet" type="text/css" href="css/theme.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script>
   var StyleFile = "theme" + document.cookie.charAt(6) + ".css";
   document.writeln('<link rel="stylesheet" type="text/css" href="css/' + StyleFile + '">');
</script>
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="css/ie-sucks.css" />
<![endif]-->
</head>
示例#11
0
<?php

require_once "requests.php";
$paypal = new paypal();
$request = array("intent" => "authorize", "payer" => array("payment_method" => "credit_card", "funding_instruments" => array(array("credit_card" => array("number" => "5500005555555559", "type" => "mastercard", "expire_month" => 12, "expire_year" => 2018, "cvv2" => 111, "first_name" => "Joe", "last_name" => "Shopper")))), "transactions" => array(array("amount" => array("total" => "7.47", "currency" => "USD"), "description" => "This is my payment description")));
//print_r($paypal->process_cc_payment($request));
$credit_card = array("type" => "visa", "number" => "4417119669820331", "expire_month" => "11", "expire_year" => "2018", "first_name" => "Joe", "last_name" => "Shopper");
//print_r($paypal->store_cc($credit_card));
//$ccid = "CARD-35Y54265JC7133454KFM5G4I";
//print_r($paypal->fetch_cc($ccid));
//$id = "PAY-5JH752195H683312PKFM5GNI";
//print_r($paypal->fetch_single_payment($id));
/*$sale_id = "8RV385008S218341G";
$paypal->refund_sale($sale_id);*/
$id = "4PR70582UT282945J";
$request = array("is_final_capture" => true, "amount" => array("currency" => "USD", "total" => "4.54"));
//print_r($paypal->capture_authorization($id, $request));
if (isset($_COOKIE['id'])) {
    $request = array("payer_id" => $_GET['PayerID']);
    print_r($paypal->execute_payment($_COOKIE['id'], $request));
} else {
    $request = array("intent" => "sale", "payer" => array("payment_method" => "paypal"), "transactions" => array(array("amount" => array("total" => "7.47", "currency" => "USD"), "description" => "This is my payment description")), "redirect_urls" => array("return_url" => "http://localhost/paypal/example.php", "cancel_url" => "http://localhost/paypal/example.php"));
    $paypal->process_pp_payment($request);
}