本文整理汇总了PHP中UserClass::MakePayment方法的典型用法代码示例。如果您正苦于以下问题:PHP UserClass::MakePayment方法的具体用法?PHP UserClass::MakePayment怎么用?PHP UserClass::MakePayment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserClass
的用法示例。
在下文中一共展示了UserClass::MakePayment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: BuyFixed
public static function BuyFixed($auctionId, $qty)
{
global $config, $user;
// validate args
$auctionId = (int) $auctionId;
$qty = (int) $qty;
if ($auctionId < 1) {
$_SESSION['error'][] = 'Invalid auction id!';
return FALSE;
}
if ($qty < 1) {
$_SESSION['error'][] = 'Invalid qty!';
return FALSE;
}
// has canBuy permissions
if (!$user->hasPerms('canBuy')) {
$_SESSION['error'][] = 'You don\'t have permission to buy.';
return FALSE;
}
// query auction
$auction = QueryAuctions::QuerySingle($auctionId);
if (!$auction) {
$_SESSION['error'][] = 'Auction not found!';
return FALSE;
}
$Item = $auction->getItemCopy();
// // is item allowed
// if (!itemAllowed($item->name, $item->damage)){
// $_SESSION['error'][] = $item->fullname.' is not allowed to be sold.';
// header("Location: ../myauctions.php");
// }
// buying validation
if ($auction->getSellerId() == $user->getId()) {
$_SESSION['error'][] = 'Can\'t buy from yourself!';
return FALSE;
}
if ($qty > $Item->getItemQty()) {
$_SESSION['error'][] = 'Not that many for sale!';
return FALSE;
}
$maxSellPrice = SettingsClass::getDouble('Max Sell Price');
$sellPrice = $auction->getPrice();
$priceTotal = $sellPrice * (double) $qty;
if ($maxSellPrice > 0.0 && $sellPrice > $maxSellPrice) {
$_SESSION['error'][] = 'Over max sell price of ' . SettingsClass::getBoolean('Currency Prefix') . $maxSellPrice . SettingsClass::getBoolean('Currency Prefix') . ' !';
return FALSE;
}
if ($priceTotal > $user->getMoney()) {
$_SESSION['error'][] = 'You don\'t have enough money!';
return FALSE;
}
// make payment from buyer to seller
UserClass::MakePayment($user->getName(), $user->getUUID(), $auction->getSeller(), $auction->getSellerUUID(), $priceTotal, 'Bought auction ' . (int) $auction->getTableRowId() . ' ' . $Item->getItemTitle() . ' x' . (int) $Item->getItemQty());
// remove auction
if (!self::RemoveAuction($auctionId, $qty < $Item->getItemQty() ? $qty : -1)) {
echo '<p style="color: red;">Error removing/updating auction!</p>';
exit;
}
// add to inventory
$Item->setItemQty($qty);
$tableRowId = ItemFuncs::AddCreateItem($user->getId(), $Item);
if (!$tableRowId) {
echo '<p style="color: red;">Error adding item to your inventory!</p>';
exit;
}
// add sale log
LogSales::addLog(LogSales::LOG_SALE, LogSales::SALE_BUYNOW, $auction->getSellerId(), $user->getId(), $Item, $sellPrice, FALSE, '', TRUE);
return TRUE;
}