* depends: RJSES * RJDL * RJSHOP * RJDGTXN */ include dirname(__FILE__) . '/../../../../wp-load.php'; $ar = wp_parse_args($_REQUEST); $dl = false; if (empty($ar['i']) || !is_numeric($ar['i'])) { // session_id() } else { RJSES::start(); $i = new RJDGSHOP($ar['i']); $txn = new RJDGPPTXN(); //$txn->loadByShopObj($i); if ($txn->loadBy('transaction_id', $ar['txn_id']) && $i->isLoaded()) { if ($txn->isComplete($i)) { status_header(200); //show pdf if (RJDL::http($i->pathname)) { $dl = true; } } else { status_header(404); $a = $txn->getStatus($i); array_walk($a, create_function('&$i,$k', '$i="<li>$i</li>";')); get_header(); echo '<h3>failed with the following erros</h3><ul>' . join('', $a) . '</ul>'; get_footer(); } }
switch ($idata->q) { case 'status': $t = new RJDGPPTXN(); if ($t->loadBy('session_id', session_id())) { if ($t->isComplete()) { $i = new RJDGSHOP($t->shop_id); if ($i->id) { $url = $i->getDownloadLink(); $odata['data']['link'] = $url; } } } break; case 'helper': if ($idata->txn_id) { $txn = new RJDGPPTXN(); $txn->loadBy('transaction_id', $idata->txn_id); if ($txn->isLoaded()) { $file = new RJDGSHOP($txn->shop_id); if ($file->isLoaded() && $txn->isValid()) { $odata['data'] = array('name' => $file->name, 'link' => RJDGPP::getDownloadLink($file) . '&txn_id=' . $txn->transaction_id, 'txn_price' => $txn->price, 'item_price' => $file->price, 'txn_stat' => $txn->payment_status, 'txn_id' => $txn->transaction_id); $odata['response'] = 'success'; } } } break; default: } } //idata->q echo json_encode($odata);
public function isValid(&$shop = null) { if (empty($shop) || !$shop instanceof RJDGSHOP) { $shop = new RJDGSHOP($this->shop_id); } if ($shop->isLoaded()) { if ('completed' == strtolower($this->payment_status) && $shop->price == $this->price) { return true; } } return false; }