/** * @depends testInterface * @return null */ public function testGetSetMultiResultOptions() { $this->assertEquals(array(), $this->request->getMultiResultOptions()); $options = array(1, 2, 3); $this->assertSame($this->request, $this->request->setMultiResultOptions($options)); $this->assertEquals($options, $this->request->getMultiResultOptions()); /* empty array is valid */ $options = array(); $this->assertSame($this->request, $this->request->setMultiResultOptions($options)); $this->assertEquals($options, $this->request->getMultiResultOptions()); }
<?php include dirname(__FILE__) . "/../common/header.php"; require dirname(__FILE__) . "/../../payzippy-sdk/QueryRequest.php"; try { // To perform a query, get an instance of the QueryRequest $pz_query_request = new QueryRequest(); // Set all the parameters that you want to send in the request. // You can also overwrite the default parameters set in the Config.php file. $pz_query_request->set_merchant_transaction_id($_GET["merchant_transaction_id"])->set_payzippy_transaction_id($_GET["payzippy_transaction_id"])->set_transaction_type($_GET["transaction_type"])->set_merchant_key_id($_GET["merchant_key_id"])->set_hash_method($_GET["hash_method"]); // Finally, call the query function. It returns an instance of QueryResponse. $pz_query_response = $pz_query_request->query(); // Call the validate function, to check the integrity of the response // by verifying the hash returned $hash_match = $pz_query_response->validate(); if ($hash_match) { echo "<p class='text-success'><b>Hash matches. The response is valid.</b></p>"; } else { echo "<p class='text-error'><b>Hash mismatch. Response is invalid</b></p>"; } echo "Status Code: {$pz_query_response->get_status_code()}<br/>"; echo "Status Message: {$pz_query_response->get_status_message()}<br/>"; echo "Error Code: {$pz_query_response->get_error_code()}<br/>"; echo "Error Message: {$pz_query_response->get_error_message()}<br/>"; echo "Merchant ID: {$pz_query_response->get_merchant_id()}<br/>"; echo "Merchant Key ID: {$pz_query_response->get_merchant_key_id()}<br/>"; echo "Hash Method: {$pz_query_response->get_hash_method()}<br/>"; echo "Hash: {$pz_query_response->get_hash()}<br/>"; echo "<br/>"; // Calling get_transaction_responses() on the QueryResponse object // returns an array of QueryTransactionResponse objects. QueryTransactionResponse
function displayQueryResults($records, $queryTimeElapsed, QueryRequest $queryRequest) { if (is_numeric($records)) { $countString = "Query would return {$records} record"; $countString .= $records == 1 ? "." : "s."; displayInfo($countString); return; } if (!$records) { displayWarning("Sorry, no records returned."); return; } if (WorkbenchConfig::get()->value("areTablesSortable")) { addFooterScript("<script type='text/javascript' src='" . getPathToStaticResource('/script/sortable.js') . "></script>"); } print "<a name='qr'></a><div style='clear: both;'><br/><h2>Query Results</h2>\n"; if (isset($this->queryLocator)) { preg_match("/-(\\d+)/", $this->queryLocator, $lastRecord); $rowOffset = $lastRecord[1]; } else { $rowOffset = 0; } $minRowNum = $rowOffset + 1; $maxRowNum = $rowOffset + count($records); print "<p>Returned records {$minRowNum} - {$maxRowNum} of " . $this->totalQuerySize . " total record" . ($this->totalQuerySize !== 1 ? "s" : "") . " in " . sprintf("%01.3f", $queryTimeElapsed) . " seconds:</p>\n"; if (!WorkbenchConfig::get()->value("autoRunQueryMore") && $this->nextQueryLocator) { print "<p><input type='hidden' name='queryLocator' value='" . $this->nextQueryLocator . "' /></p>\n"; print "<p><input type='submit' name='queryMore' id='queryMoreButtonTop' value='More...' /></p>\n"; } print addLinksToIds($queryRequest->getExportTo() == 'matrix' ? $this->createQueryResultsMatrix($records, $queryRequest->getMatrixCols(), $queryRequest->getMatrixRows()) : $this->createQueryResultTable($records, $minRowNum)); if (!WorkbenchConfig::get()->value("autoRunQueryMore") && $this->nextQueryLocator) { print "<p><input type='hidden' name='queryLocator' value='" . $this->nextQueryLocator . "' /></p>\n"; print "<p><input type='submit' name='queryMore' id='queryMoreButtonBottom' value='More...' /></p>"; } print "</form></div>\n"; }
/** * @depends testInterface * @expectedException Exception * @dataProvider provideInvalidArray * @return null */ public function testSetMultiResultNotArray_Failure($values) { $this->request->setMultiResultOptions($values); }
$persistedSavedQueryRequestsKey = "PSQR@"; if (isset($_COOKIE[$persistedSavedQueryRequestsKey])) { setcookie($persistedSavedQueryRequestsKey, null, time() - 3600); } $defaultSettings['numFilters'] = 1; if (isset($_POST['justUpdate']) && $_POST['justUpdate'] == true) { $queryRequest = new QueryRequest($defaultSettings); $queryRequest->setObject($_POST['QB_object_sel']); } else { if (isset($_POST['querySubmit'])) { $queryRequest = new QueryRequest($_REQUEST); } else { if (isset($_SESSION['lastQueryRequest'])) { $queryRequest = $_SESSION['lastQueryRequest']; } else { $queryRequest = new QueryRequest($defaultSettings); $queryRequest->setObject(WorkbenchContext::get()->getDefaultObject()); } } } if (isset($_GET['qrjb'])) { if ($queryRequestJsonString = base64_decode($_REQUEST['qrjb'], true)) { if ($queryRequestJson = json_decode($queryRequestJsonString, true)) { $queryRequest = new QueryRequest($queryRequestJson); $_POST['querySubmit'] = 'Query'; //simulate the user clicking 'Query' to run immediately } else { displayErrorBeforeForm('Could not parse query request'); } } else { displayErrorBeforeForm('Could not decode query request');
if (WorkbenchConfig::get()->value("savedQueriesAndSearchesPersistanceLevel") == 'ALL') { $persistedSavedQueryRequestsKey .= "ALL"; } } } //populate queryRequest for this page view. first see if user wants to retreive a saved query, //then see if there was a last query, else just show a null query with default object. if (isset($_REQUEST['getQr']) && $_REQUEST['getQr'] != "" && isset($_SESSION['savedQueryRequests'][$_REQUEST['getQr']])) { $queryRequest = $_SESSION['savedQueryRequests'][$_REQUEST['getQr']]; $_POST['querySubmit'] = 'Query'; //simulate the user clicking 'Query' to run immediately } else { if (isset($_SESSION['lastQueryRequest'])) { $queryRequest = $_SESSION['lastQueryRequest']; } else { $queryRequest = new QueryRequest($defaultSettings); $queryRequest->setObject(WorkbenchContext::get()->getDefaultObject()); if (WorkbenchConfig::get()->value("savedQueriesAndSearchesPersistanceLevel") != 'NONE' && !isset($_SESSION['savedQueryRequests']) && isset($_COOKIE[$persistedSavedQueryRequestsKey])) { $_SESSION['savedQueryRequests'] = unserialize($_COOKIE[$persistedSavedQueryRequestsKey]); } } } //clear all saved queries in scope if user requests if (isset($_POST['clearAllQr']) && $_POST['clearAllQr'] == 'Clear All') { $_SESSION['savedQueryRequests'] = null; if (WorkbenchConfig::get()->value("savedQueriesAndSearchesPersistanceLevel") != 'NONE') { setcookie($persistedSavedQueryRequestsKey, null, time() - 3600); } } //save as named query if (isset($_POST['doSaveQr']) && $_POST['doSaveQr'] == 'Save' && isset($_REQUEST['saveQr']) && strlen($_REQUEST['saveQr']) > 0) {
/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { return array_merge(parent::rules(), []); }