本文整理匯總了PHP中Booking::payment方法的典型用法代碼示例。如果您正苦於以下問題:PHP Booking::payment方法的具體用法?PHP Booking::payment怎麽用?PHP Booking::payment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Booking
的用法示例。
在下文中一共展示了Booking::payment方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: preProcess
public function preProcess()
{
if (!Tools::hasFunction('booking_list')) {
Tools::redirect('index.php');
}
if (Tools::getValue("settle") == 1) {
$this->brandNavi[] = array("name" => "Settlement", "url" => 'booking_list.php?settle=1');
} else {
$this->brandNavi[] = array("name" => "Booking List", "url" => $this->php_self);
}
if (Tools::isSubmit("change_pay")) {
$id = (int) Tools::getValue("id");
$status = (int) Tools::getValue("status");
Booking::changePayStatus($id, $status);
if ($status == 2) {
Booking::changeBookingStatus($id, 10);
// Successed
Booking::payment($id, $_POST['money']);
//給otherPrice值
}
exit;
} else {
if (Tools::isSubmit("change_status")) {
$id = (int) Tools::getValue("id");
$status = (int) Tools::getValue("status");
$roleid = self::$cookie->RoleID;
if ($status == 7) {
$bookingInfo = Booking::getBookingInfo($id);
$checkin = $bookingInfo['checkin'];
$nights = $bookingInfo['nights'];
$roomplan_list = array();
foreach ($bookingInfo['booked_roomplan_list'] as $booked_roomplan_list) {
$roomplan_list[] = $booked_roomplan_list['RoomPlanId'];
}
Stock::updateAmountStock($checkin, $nights, $roomplan_list);
}
Booking::changeBookingStatus($id, $status);
exit;
}
}
}
示例2: run
public function run()
{
$logStr = "";
$logFd = fopen(PAYPAL_IPN_LOG, "a");
//$booking_info = Booking::getBookingInfoByBN('TASF0000427');
// p($booking_info);
fwrite($logFd, "******************************START*****************************************************************\n");
//echo PAYPAL_IPN_LOG;
if (array_key_exists("txn_id", $_POST)) {
$logStr = "Received IPN, TX ID : " . htmlspecialchars($_POST["txn_id"]);
fwrite($logFd, strftime("%d %b %Y %H:%M:%S ") . "[IPNListner.php] {$logStr}\n");
} else {
$logStr = "IPN Listner recieved an HTTP request with out a Transaction ID.";
fwrite($logFd, strftime("%d %b %Y %H:%M:%S ") . "[IPNListner.php] {$logStr}\n");
fclose($logFd);
exit;
}
//從 PayPal 出讀取 POST 信息同時添加變量?cmd?
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&{$key}={$value}";
}
//建議在此將接受到的信息記錄到日誌文件中以確認是否收到 IPN 信息
$tmpAr = array_merge($_POST, array("cmd" => "_notify-validate"));
$postFieldsAr = array();
foreach ($tmpAr as $name => $value) {
$postFieldsAr[] = "{$name}={$value}";
}
$logStr = "Sending IPN values:\n" . implode("\n", $postFieldsAr);
fwrite($logFd, strftime("%d %b %Y %H:%M:%S ") . "[IPNListner.php] {$logStr}\n");
//將信息 POST 回給 PayPal 進行驗證
$ppResponseAr = Utils::PPHttpPost("https://www." . DEFAULT_ENV . ".paypal.com/cgi-bin/webscr", implode("&", $postFieldsAr), false);
if (!$ppResponseAr["status"]) {
fwrite($logFd, "--------------------\n");
$logStr = "IPN Listner recieved an Error:\n";
if (0 !== $ppResponseAr["error_no"]) {
$logStr .= "Error " . $ppResponseAr["error_no"] . ": ";
}
$logStr .= $ppResponseAr["error_msg"];
fwrite($logFd, strftime("%d %b %Y %H:%M:%S ") . "[IPNListner.php] {$logStr}\n");
fclose($logFd);
exit;
}
//將 POST 變量記錄在本地變量中
//該付款明細所有變量可參考:
//https://www.paypal.com/IntegrationCenter/ic_ipn-pdt-variable-reference.html
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
//…
//判斷回複 POST 是否創建成功
fwrite($logFd, "--------------------\n");
$logStr = "IPN Post Response:\n" . $ppResponseAr["httpResponse"];
fwrite($logFd, strftime("%d %b %Y %H:%M:%S ") . "[IPNListner.php] {$logStr}\n");
$res = $ppResponseAr["httpResponse"];
//已經通過認證
if (strcmp($res, "VERIFIED") == 0) {
fwrite($logFd, "----- VERIFIED -----------\n");
//檢查付款狀態
fwrite($logFd, "----- Payment Status:{$payment_status} -----------\n");
if ($payment_status == "Completed") {
//檢查 txn_id 是否已經處理過
fwrite($logFd, "-----Check Transaction ID :{$txn_id}-----------\n");
//檢查 receiver_email 是否是您的 PayPal 賬戶中的 EMAIL 地址
fwrite($logFd, "-----Check Receiver_email :{$receiver_email}-----------\n");
if ($receiver_email != DEFAULT_EMAIL_ADDRESS) {
fwrite($logFd, "----- Receiver_email Error :{$receiver_email}-----------\n");
} else {
//檢查付款金額和貨幣單位是否正確
//todo:$ammount
$booking_info = Booking::getBookingInfoByBN($item_name);
// fwrite($logFd, "-----Booking Info :-----------\n");
//fwrite($logFd, var_dump($booking_info));
$ammount = $booking_info['money'];
fwrite($logFd, "-----Check Payment Amount :{$payment_amount}-----------\n");
fwrite($logFd, "-----Check Payment Currency :{$payment_currency}-----------\n");
if ($payment_currency != DEFAULT_PAYMENT_CURRENCY) {
fwrite($logFd, "-----Payment Currency Error :{$payment_currency}-----------\n");
} elseif ($payment_amount != $ammount) {
fwrite($logFd, "-----Payment Error :{$payment_amount}---{$ammount}--------\n");
} else {
//處理這次付款,包括寫數據庫
fwrite($logFd, "----- changeBookingStatus -----------\n");
Booking::changeBookingStatus($booking_info['order_id'], 4);
fwrite($logFd, "----- changePayStatus -----------\n");
Booking::changePayStatus($booking_info['order_id'], 2);
fwrite($logFd, "----- payment -----------\n");
Booking::payment($booking_info['order_id'], $payment_amount);
//下訂單成功,此時需要發送郵件
fwrite($logFd, "----- ordermail -----------\n");
Tools::ordermail($booking_info['order_id']);
fwrite($logFd, "----- finish -----------\n");
}
}
//.........這裏部分代碼省略.........
示例3: process
public function process()
{
global $cookie;
if ($_POST["booking"] != 'confirm' && $_POST["booking"] != 'calculate' && $_REQUEST['booking'] != 'view' && $_POST['booking'] != 'payment' && $_POST["booking"] != 'finish' && $_POST["booking"] != 'save') {
Tools::redirect('index.php');
}
if ($_REQUEST['booking'] == 'view') {
// view page
if ($_REQUEST['vouch_info'] == 1 || $_REQUEST['savepdf'] == 1) {
$orderId = $_GET['oid'];
//獲取訂單編號
if ($_REQUEST['savepdf'] == 1) {
$booking_info = Booking::getBookingInfo($_GET['oid'], "en");
} else {
$booking_info = Booking::getBookingInfo($_GET['oid']);
}
$booking_info['agent_info'] = new Member($booking_info['OrderUserId']);
// make string of "Total No or rooms"
$_rooms = array();
foreach ($booking_info['booked_roomplan_list'] as $roomplan) {
if ($_rooms[$roomplan[RoomPlanId]]) {
$_rooms[$roomplan[RoomPlanId]]['count']++;
} else {
$_rooms[$roomplan[RoomPlanId]]['count'] = 1;
$_rooms[$roomplan[RoomPlanId]]['name'] = $roomplan[RoomPlanName];
}
}
$_roomsString = "";
foreach ($_rooms as $_room) {
if ($_roomsString != "") {
$_roomsString .= "& ";
}
$_roomsString .= $_room['count'] . " " . $_room['name'];
}
$booking_info['roomString'] = $_roomsString;
if ($_REQUEST['savepdf'] == 1) {
$this->printPDF($booking_info);
exit;
} else {
self::$smarty->assign("booking_info", $booking_info);
}
}
// move the engine to preprocess function
/*
$booking_info = Booking::getBookingInfo ( $_GET ['oid'] );
if (! $booking_info)
Tools::redirect ( 'index.php' );
if ($_REQUEST ['payment'])
self::$smarty->assign ( "payment", $_REQUEST ['payment'] );
self::$smarty->assign ( "method", 'view' );
*/
} else {
// other(build booking info from post variable for edit, confirm, finish)
$booking_info = Booking::buildBookingInfoFromPost(self::$cookie->CompanyID);
self::$smarty->assign("method", 'order');
self::$smarty->assign("booking_info", $booking_info);
foreach ($booking_info['booked_roomplan_list'] as $bi) {
//echo $bi['Check_0'];
if ($bi['Check_0'] == '0') {
$error['message'] = "満室のためご希望の日程には変更できません";
self::$smarty->assign("error", $error);
self::$smarty->display(_TAS_THEME_DIR_ . 'error_redirect.tpl');
exit;
}
}
//p($booking_info['booked_roomplan_list']);
}
if ($_POST["booking"] == 'calculate') {
$checkin = $_POST['checkin'];
//獲取checkin的值
$checkout = $_POST['checkout'];
//獲取checkout的值
//獲取roomPlanId
$ids = $_POST['ids'];
$rpid_list = array();
foreach ($ids as $id) {
$rpid_list[] = $_POST['roomplan_ids_' . $id];
}
//計算房間數量是否滿足條件,如果有一條不滿足則發出錯誤報告
$roomplan_list = RoomPlan::getRoomPlanListForBooking($rpid_list, $checkin, $checkout);
$plan_list = array();
foreach ($roomplan_list as $record) {
$plan_list[$record['RoomPlanId']] = $record;
}
//查看是否有房間不滿足條件
$isOk = true;
foreach ($rpid_list as $rpid) {
if (empty($plan_list[$rpid])) {
$isOk = false;
break;
}
}
if (!$isOk) {
$error['message'] = "There is not any room as requested";
self::$smarty->assign("error", $error);
self::$smarty->display(_TAS_THEME_DIR_ . 'error_redirect.tpl');
exit;
}
self::$smarty->assign("countries", Tools::getCountries());
self::$smarty->assign("method", 'edit');
//.........這裏部分代碼省略.........