setIPAddress in etapestry
A post that I wrote trying make myself feel better with pat in my back.
August 05, 2022 • Code
For any of the poor souls experiencing lack of documentation with using setIPAddress, there’s few things that you should consider:
- Need to use error catching function if you want to check if there is an error.
- Need to use
- array("IP Address")
- as a parameter.
The code is as follows:
$nsc->call("setIPAddress", array($_SERVER['REMOTE_ADDR']));
if($nsc->fault || $nsc->getError())
{
$resp_obj['accountRef'] = $accountReference;
$resp_obj['error'] = checkStatus($nsc);
stopEtapestrySession($nsc);
return $this->asJson($resp_obj);
}
$transResponse = $nsc->call("processTransaction", array($transactionRequest));
The $_SERVER['REMOTE_ADDR'] gives client’s IP address. Also, right after the setIPAddress and error handling code, we run the transaction code.