public function __construct($overrides = array()) { $config = Obj2xml::getConfig($overrides); $this->config = $config; $request_dir = $config['litle_requests_path']; if (substr($request_dir, -1, 1) != DIRECTORY_SEPARATOR) { $request_dir = $request_dir . DIRECTORY_SEPARATOR; } $ts = str_replace(" ", "", substr(microtime(), 2)); $batches_filename = $request_dir . "request_" . $ts . "_batches"; $request_filename = $request_dir . "request_" . $ts; $response_filename = $request_dir . "response_" . $ts; // if either file already exists, let's try again! if (file_exists($batches_filename) || file_exists($request_filename) || file_exists($response_filename)) { $this->__construct(); } // if we were unable to write the file if (file_put_contents($batches_filename, "") === FALSE) { throw new \RuntimeException("A request file could not be written at {$batches_filename}. Please check your privilege."); } $this->batches_file = $batches_filename; // if we were unable to write the file if (file_put_contents($request_filename, "") === FALSE) { throw new \RuntimeException("A request file could not be written at {$request_filename}. Please check your privilege."); } $this->request_file = $request_filename; if (file_put_contents($response_filename, "") === FALSE) { throw new \RuntimeException("A response file could not be written at {$response_filename}. Please check your privilege."); } $this->response_file = $response_filename; }
public function setUp() { $this->direct = sys_get_temp_dir() . '/test'; if (!file_exists($this->direct)) { mkdir($this->direct); } $this->config = Obj2xml::getConfig(array('batch_requests_path' => $this->direct, 'litle_requests_path' => $this->direct)); $this->sale = array('card' => array('type' => 'VI', 'number' => '4100000000000000', 'expDate' => '1213', 'cardValidationNum' => '1213'), 'id' => '1211', 'orderId' => '2111', 'reportGroup' => 'Planets', 'orderSource' => 'ecommerce', 'amount' => '123'); }
public function setUp() { $this->direct = sys_get_temp_dir() . '/test'; if (!file_exists($this->direct)) { mkdir($this->direct); } $this->config = Obj2xml::getConfig(array('batch_requests_path' => $this->direct, 'litle_requests_path' => $this->direct)); $this->sale = array('id' => 'id', 'orderId' => '1864', 'amount' => '10010', 'orderSource' => 'ecommerce', 'billToAddress' => array('name' => 'John Smith', 'addressLine1' => '1 Main St.', 'city' => 'Burlington', 'state' => 'MA', 'zip' => '01803-3747', 'country' => 'US'), 'card' => array('number' => '4457010000000009', 'expDate' => '0112', 'cardValidationNum' => '349', 'type' => 'VI'), 'reportGroup' => 'Planets'); }