/** * Constructor. * * @param string $rawResponse The raw response from the gateway * @return mixed boolean true on success, PEAR_Error on failure */ function __construct($rawResponse, Payment_Process2_Common $request) { $this->_validateResponse($rawResponse); parent::__construct($rawResponse, $request); $res = $this->parse(); /** @todo This is Wrong WRONG WRONGGGG! Constructors do no work! */ }
public function testShouldCreateObjectWithFactory() { $object = Payment_Process2_Result::factory('Bibit', null, new Payment_Process2_Common()); $this->assertTrue($object instanceof Payment_Process2_Result_Bibit); }
/** * Process a payment * * @return Payment_Process2_Result_ANZ */ public function process() { // Sanity check $this->validate(); // Prepare the data $this->_prepare(); $request = clone $this->_request; $request->setUrl($this->getOption('url')); $request->setMethod(HTTP_Request2::METHOD_POST); $request->addPostParameter($this->prepareRequestData()); $response = $request->send(); if ($response->getStatus() != 200) { $error_msg = "Payment Gateway HTTP Error " . $response->getStatus() . " " . $response->getReasonPhrase(); throw new Payment_Process2_Exception($error_msg); } $result = Payment_Process2_Result::factory($this->_driver, $response->getBody(), $this); $result->parse(); return $result; }
/** * Parses the data received from the payment gateway callback * * @access public * @todo Implement support for PayPal's IPN? */ function parseCallback() { return parent::parseCallback(); }
/** * Process the (dummy) transaction * * @return mixed Payment_Process2_Result instance or PEAR_Error */ function process() { // Sanity check $this->validate(); return Payment_Process2_Result::factory('Dummy', null, $this); }
/** * Process the transaction. * * @return mixed Payment_Process2_Result on success, PEAR_Error on failure */ function process() { // Sanity check $this->validate(); // Prepare the data $this->_prepare(); $req = clone $this->_request; $req->setURL($this->_options['authorizeUri']); $req->setMethod('POST'); $req->addPostParameter($this->prepareRequestData()); $res = $req->send(); $this->_processed = true; $response = trim($res->getBody()); $result = Payment_Process2_Result::factory('Transfirst', $response, $this); $result->_request = $this; $this->_result = $result; return $result; }
/** * Process the transaction. * * @author Joe Stump <*****@*****.**> * @access public * @return mixed Payment_Process2_Result on success, PEAR_Error on failure */ function process() { // Sanity check $this->validate(); // Prepare the data $this->_prepare(); $xml = $this->renderRequestDocument(); $url = 'https://' . $this->_options['host'] . ':' . $this->_options['port'] . '/LSGSXML'; $request = clone $this->_request; $request->setURL($url); $request->addPostParameter($this->prepareRequestData()); $request->setMethod('post'); $request->setBody($xml); /** If we are empty, raise exception? */ if (!empty($this->_options['keyfile'])) { $request->setConfig('ssl_local_cert', $this->_options['keyfile']); } // LinkPoint's staging server has a boned certificate. If they are // testing against staging we need to turn off SSL host verification. if ($this->_options['host'] == 'staging.linkpt.net') { $request->setConfig('ssl_verify_peer', false); $request->setConfig('ssl_verify_host', false); } $result = $request->send(); $responseBody = trim($result->getBody()); $this->_processed = true; $response = Payment_Process2_Result::factory($this->_driver, $responseBody, $this); $response->parse(); return $response; }
/** * Statically check a Payment_Result class for success * * @param mixed $obj Object to check * * @return bool * @author Joe Stump <*****@*****.**> */ public static function isSuccess(Payment_Process2_Result $obj) { return $obj->getCode() == Payment_Process2::RESULT_APPROVED; }
public function aResult($case) { $result = Payment_Process2_Result::factory('TrustCommerce', $this->fetchData($case), new Payment_Process2_Common()); $result->parse(); return $result; }
public function testShouldValidateCorrectlyWithCvvCheck3() { $processor = Payment_Process2::factory('Dummy'); $processor->setOption('cvvCheck', true); $processor->setPayment($this->aValidPayment()); $r = new Payment_Process2_Result(null, $processor); $r->_statusCodeMap[null] = Payment_Process2::RESULT_APPROVED; $r->_cvvCodeMap[1] = Payment_Process2::CVV_MATCH; $r->cvvCode = 2; $this->assertNotSame(Payment_Process2::CVV_MATCH, $r->getCvvCode()); try { $r->validate(); $this->fail("Expected an exception: We haven't got a valid Cvv code set"); } catch (Payment_Process2_Exception $ppe) { } }
/** * Process the transaction. * * @return mixed Payment_Process2_Result on success, PEAR_Error on failure */ function process() { // Sanity check $this->validate(); // Prepare the data $this->_prepare(); if (empty($this->_payment)) { throw new Payment_Process2_Exception("Payment type not set"); } /** @todo Refactor this method, it does two things at once! */ $fields = $this->prepareRequestData(); $request = clone $this->_request; $request->setURL('https://vault.trustcommerce.com/trans/'); $request->setMethod('POST'); $request->addPostParameter($fields); $result = $request->send(); $responseBody = trim($result->getBody()); $this->_processed = true; $response = Payment_Process2_Result::factory($this->_driver, $responseBody, $this); $response->parse(); return $response; }
/** * Processes the transaction. * * Success here doesn't mean the transaction was approved. It means * the transaction was sent and processed without technical difficulties. * * @return mixed Payment_Process2_Result on success, PEAR_Error on failure * @access public */ function process() { // Sanity check $this->validate(); // Prepare the data $this->_prepare(); $fields = $this->prepareRequestData(); $fields['VERSION'] = '3.2'; $request = clone $this->_request; $request->setURL($this->_options['paypalUri']); $request->setMethod('post'); $request->addPostParameter($fields); $result = $request->send(); $responseBody = trim($result->getBody()); $this->_processed = true; $response = Payment_Process2_Result::factory($this->_driver, $responseBody, $this); $response->parse(); $r = $response->isLegitimate(); if ($r === false) { throw new Payment_Process2_Exception('Illegitimate response from gateway'); } $response->action = $this->action; return $response; }
/** * Processes a callback from payment gateway * * Success here doesn't mean the transaction was approved. It means * the callback was received and processed without technical difficulties. * * @return mixed Payment_Process2_Result on success, PEAR_Error on failure */ function processCallback() { $this->_responseBody = $_POST; $this->_processed = true; $response = Payment_Process2_Result::factory($this->_driver, $this->_responseBody); $response->_request =& $this; $response->parseCallback(); $r = $response->isLegitimate(); if ($r === false) { throw new Payment_Process2_Exception('Illegitimate callback from gateway.'); } return $response; }
/** * Process the transaction. * * @return mixed Payment_Process2_Result on success, PEAR_Error on failure */ function process() { // Sanity check $this->validate(); // Prepare the data $this->_prepare(); $url = isset($this->_options['live']) ? $this->_options['authorizeUri'] : $this->_options['authorizeTestUri']; $request = clone $this->_request; $request->setURL($url); $request->setBody($this->renderRequestDocument()); $request->setMethod('put'); $request->setAuth($this->_data['x_login'], $this->_data['x_password']); $result = $request->send(); $responseBody = trim($result->getBody()); $this->_processed = true; $response = Payment_Process2_Result::factory($this->_driver, $responseBody, $this); $response->parse(); return $response; }