Payment_Process2
[ class tree: Payment_Process2 ] [ index: Payment_Process2 ] [ all elements ]

Source for file Bibit.php

Documentation is available at Bibit.php

  1. <?php
  2. require_once 'Payment/Process2/Result.php';
  3.  
  4.  
  5. /**
  6.  * Payment_Process2_Bibit_Result
  7.  *
  8.  * @category Payment
  9.  * @package  Payment_Process2
  10.  * @author   Robin Ericsson <lobbin@localhost.nu>
  11.  * @license  http://www.opensource.org/licenses/bsd-license.php BSD License
  12.  * @version  Release: @package_version@
  13.  * @link     http://pear.php.net/package/Payment_Process2
  14.  */
  15. {
  16.     var $_returnCode = Payment_Process2::RESULT_DECLINED;
  17.  
  18.     var $_lastEvent = null;
  19.  
  20.     var $_fieldMap = array(
  21.     );
  22.  
  23.     /**
  24.      * Class constructor
  25.      *
  26.      * @param mixed $rawResponse Raw response
  27.      */
  28.     function __construct($rawResponse)
  29.     {
  30.         $this->_rawResponse = $rawResponse;
  31.     }
  32.  
  33.     /**
  34.      * Return error code
  35.      *
  36.      * @return integer 
  37.      */
  38.     function getErrorCode()
  39.     {
  40.         return $this->_errorCode;
  41.     }
  42.  
  43.     /**
  44.      * Return response code
  45.      *
  46.      * @return mixed 
  47.      */
  48.     function getCode()
  49.     {
  50.         return $this->_returnCode;
  51.     }
  52.  
  53.     /**
  54.      * Parses response
  55.      *
  56.      * @todo Make this better - if its empty, the response code is... ?
  57.      * @return void 
  58.      */
  59.     function parse()
  60.     {
  61.         $sxe simplexml_load_string($this->_rawResponse);
  62.  
  63.         if (!$sxe{
  64.             return;
  65.         }
  66.  
  67.         $matches $sxe->xpath('//reply/error/attribute::code');
  68.         if (!empty($matches)) {
  69.             $this->_returnCode Payment_Process2::RESULT_OTHER;
  70.             $this->_errorCode  = (string)$matches[0];
  71.  
  72.             $matches $sxe->xpath('//reply/error/text()');
  73.             if (!empty($matches)) {
  74.                 $this->message = (string)$matches[0];
  75.             }
  76.  
  77.             return;
  78.         }
  79.  
  80.         $orderType $this->_request->_data['x_action'];
  81.         switch ($orderType{
  82.         case Payment_Process2_Bibit::ACTION_BIBIT_AUTH:
  83.             $matches $sxe->xpath('//reply/orderStatus/payment/lastEvent/text()');
  84.             if (!empty($matches)) {
  85.                 $this->_lastEvent = (string)$matches[0];
  86.             }
  87.  
  88.             $matches $doc->evaluate('//reply/orderStatus/payment/amount/attribute::value');
  89.             if (!empty($matches)) {
  90.                 if ($this->_lastEvent == 'AUTHORISED'{
  91.                     $this->_returnCode Payment_Process2::RESULT_APPROVED;
  92.                     $this->message     = '';
  93.                     return;
  94.                 }
  95.             }
  96.  
  97.             break;
  98.         case Payment_Process2_Bibit::ACTION_BIBIT_CAPTURE:
  99.             $matches $doc->evaluate('//reply/ok/captureReceived/amount/attribute::value');
  100.             if (!empty($matches)) {
  101.                 $this->_returnCode Payment_Process2::RESULT_APPROVED;
  102.                 return;
  103.             }
  104.  
  105.             break;
  106.         case Payment_Process2_Bibit::ACTION_BIBIT_REFUND:
  107.             $matches $doc->evaluate('//reply/ok/refundReceived/amount/attribute::value');
  108.             if (!empty($matches)) {
  109.                 $this->_returnCode Payment_Process2::RESULT_APPROVED;
  110.                 return;
  111.             }
  112.             break;
  113.         }
  114.     }
  115. }

Documentation generated on Mon, 11 Mar 2019 15:40:37 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.