PAN: Edit merchant info via API

The following sample script shows how to change the password of a network merchant via API.
NOTE: it requires network-owner login credentials OR if another merchant would like to use it, he/she would have to have 'network owner privileges'. 
//your PapApi.class.php file can be downloaded in the merchant panel: 
//Tools>Integration>API Integration>Download PAP API

include ("PapApi.class.php"); //this include assumes the PapApi.class.php is in the same dir as this script
$panURL ="https://localhost/pan"; //URL to PAN without trailing slash

//change it here for your nework-owner username and password 
$networkOwnerUsername = "";
$networkOwnerPassword = "123456";

//Details of the merchant whose password we want to change
$merchantUsername = ""; //username of merchant for whom the password has to be changed
$newMerchantPassword = 'NewPassword'; //new password for the particular merchant

$session = new Pap_Api_Session($panURL."/scripts/server.php"); 
//login as merchant
if(!$session->login($networkOwnerUsername, $networkOwnerPassword)) { 
  die("Cannot login. Message: ".$session->getMessage());


$request = new Gpf_Rpc_GridRequest("Pap_Features_MultipleMerchants_AdminsGrid","getRows" , $session);

try {
} catch(Exception $e) {
  die("API call error: ".$e->getMessage());

// request was successful, get the grid result
$grid = $request->getGrid();
// get recordset from the grid
$recordset = $grid->getRecordset();

foreach($recordset as $rec) {
	if ($merchantUsername == $rec->get('username')) {
		//Display merchant details. 
		//echo 'ID: '.$rec->get('id'). ' || AccountId: ' . $rec->get('accountid'). ' || Name: ' . $rec->get('firstname').' '.$rec->get('lastname').' || Email: ' . $rec->get('username').' || Status: ' . $rec->get('rstatus').'<br>';
		$request = new Gpf_Rpc_FormRequest("Pap_Features_MultipleMerchants_AdminForm", "save", $session);
		//ID and username are mandatory fields even if you are changing only the password
		//set the new password
		try {
		} catch(Exception $e) {
			die("API call error: ".$e->getMessage());
		$response = $request->getStdResponse();

		if ($response->success == 'Y') {
			echo 'Success: ' . $response->message;
		} else {
			echo 'Unsuccess: ' . $response->message;