예제 #1
0
파일: yahoo.php 프로젝트: sherdog/wnd
 function create_transaction($playerID)
 {
     //we are going to create a pending order.. we are just intiatng a transaction id - then we will set the order to status pending.
     Validate::player($playerID);
     $store = new StoreModel();
     $player = new PlayerModel();
     $itemID = filter_input(INPUT_POST, 'item');
     LOg::add('Received create transaction request with payload: ' . print_r($item, true));
     $transactionID = 'y_' . time() . md5(uniqid(rand(), true));
     $data['transaction_id'] = $transactionID;
     $data['player_id'] = $playerID;
     $data['order_date'] = date('Y-m-d H:i:s');
     $data['uid'] = $player->getUidFromPlayerId($playerID);
     $data['quantity'] = 1;
     $data['currency'] = 'USD';
     $data['updated_at'] = date('Y-m-d H:i:s');
     $data['status'] = 'pending';
     $data['item'] = $itemID;
     Log::add('Adding pending transaction sending data to model: ' . print_r($data, true));
     $response = $store->addPendingPurchase($data);
     $item = $store->getItem($itemID);
     $status = $response['status'];
     if ($status === 'ok') {
         $icon = 'coinItem.png';
         if ($item->type == 1) {
             $icon = 'coinItem.png';
         }
         if ($item->type == 2) {
             $icon = 'lifeItem.png';
         }
         $this->printJson(array('status' => 'ok', 'transactionid' => $response['transaction_id'], 'item' => $itemID, 'name' => $item->title, 'description' => $item->description, 'icon' => Config::get('storage.url') . 'game_assets/' . $icon, 'currency' => 'usd', 'amount' => $item->price));
     } else {
         $this->printJson(array('status' => 'error'));
     }
 }
예제 #2
0
파일: shop.php 프로젝트: sherdog/wnd
 public function getprice()
 {
     //we are going to get the item and return the required data to facebook.
     if (!$_POST['signed_request']) {
         Log::add('Signed request missing');
     }
     $req = Util::parseSignedRequest($_POST['signed_request']);
     $payment = $req['payment'];
     $product = $payment['product'];
     $quantity = $payment['quantity'];
     $currency = $payment['user_currency'];
     $requestID = $payment['request_id'];
     $method = $_POST['method'];
     $user = $req['user'];
     $country = $user['country'];
     $locale = $user['locale'];
     $age = $user['age']['min'];
     $facebookUserID = $req['user_id'];
     $itemID = substr(strrchr($product, '/'), 1);
     if (!$itemID) {
         Log::add('itemID was not found');
     }
     $storeModel = new StoreModel();
     $item = $storeModel->getItem($itemID);
     $return['content'] = array('product' => $product, 'amount' => $item->price / 100 * $quantity, 'currency' => $currency);
     $return['method'] = $method;
     $this->printJson($return);
 }