⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 verisign.php

📁 apache windows下的一款好
💻 PHP
📖 第 1 页 / 共 2 页
字号:
    $this->params['AMT'] = number_format($amount, 2, '.', '');

    return $this->process('C');
  }

  /* refund_transaction: refund a specific earlier transaction - no card required */

  function refund_transaction($origid)
  {
    if (!$origid or !strlen($origid)) {
      return new VerisignException('You must provide the original PNREF id for a transaction refund');
    }

    $this->params['ORIGID'] = $origid;

    return $this->process('C');
  }

  /* voice_auth: voice authorised transaction */

  function voice_auth($amount, $authcode)
  {
    if (!$amount or $amount <= 0) {
      return new VerisignException('You cannot perform an authorisation on a negative or zero amount');
    }

    if (!$authcode or !strlen($authcode)) {
      return new VerisignException('You must provide an authcode for a voice authorisation');
    }

    $this->params['AMT'] = number_format($amount, 2, '.', '');

    $this->params['AUTHCODE'] = $authcode;

    return $this->process('F');
  }

  function void($origid)
  {
    if (!$origid or !strlen($origid)) {
      return new VerisignException('You must provide the original PNREF id for a transaction refund');
    }

    $this->params['ORIGID'] = $origid;

    return $this->process('V');
  }

  /* Central processing function */

  function process($trxtype, $tender = 'C')
  {
    if (!extension_loaded('pfpro')) {
      return new VerisignException('Payflow Pro module is not compiled into PHP. Compile PHP using --with-pfpro.');
    }

    if (!$this->params['USER']) {
      if ($this->username and strlen($this->username)) {
	$this->params['USER'] = $this->username;
      }
      else {
	return new VerisignException('You have not specified the Verisign user name');
      }
    }

    if (!$this->params['PWD']) {
      if ($this->password and strlen($this->password)) {
	$this->params['PWD'] = $this->username;
      }
      else {
	return new VerisignException('You have not specified the Verisign password');
      }
    }

    if (!$this->params['ACCT']) {
      if ($this->cardnumber and strlen($this->cardnumer)) {
	$this->params['ACCT'] = $this->cardnumber;
      }
      else if ($this->params['ORIGID'] and
	       ($trxtype == 'C' or $trxtype == 'D' or $trxtype == 'V')) {
	/* don't need card number if we're crediting or capturing
	 * or voiding a specific transaction */
      }
      else {
	return new VerisignException('You have not specified the card number');
      }
    }

    if (!$this->params['EXPDATE']) {
      if ($this->expiredate and strlen($this->expiredate)) {
	$this->params['EXPDATE'] = $this->expiredate;
      }
      else if ($this->params['ORIGID'] and
	       ($trxtype == 'C' or $trxtype == 'D' or $trxtype == 'V')) {
	/* don't need expiry date if we're crediting or capturing
	 * or voiding a specific transaction */
      }
      else {
	return new VerisignException('You have not specified the expiry date');
      }
    }

    if (!$trxtype or !strlen($trxtype)) {
      return new VerisignException('Invalid transaction type');
    }

    $this->params['TRXTYPE'] = $trxtype;

    if (!$tender or !strlen($tender)) {
      return new VerisignException('Invalid tender');
    }

    $this->params['TENDER'] = $tender;

    /* Some final validation of our member variables */

    if (!$this->hostaddress or !strlen($this->hostaddress)) {
      return new VerisignException('No host address specified');
    }

    if (!$this->hostport or $this->hostport < 1) {
      return new VerisignException('No host port specified');
    }

    /* Now process it */

    if ($this->proxypassword and strlen($this->proxypassword)) {
      $response = pfpro_process($this->params, $this->hostaddress, $this->hostport, $this->timeout, $this->proxyaddress, $this->proxyport, $this->proxylogon, $this->proxypassword);
    }
    else if ($this->proxylogon and strlen($this->proxylogon)) {
      $response = pfpro_process($this->params, $this->hostaddress, $this->hostport, $this->timeout, $this->proxyaddress, $this->proxyport, $this->proxylogon);
    }
    else if ($this->proxyport and $this->proxyport > 0) {
      $response = pfpro_process($this->params, $this->hostaddress, $this->hostport, $this->timeout, $this->proxyaddress, $this->proxyport);
    }
    else if ($this->proxyaddress and strlen($this->proxyaddress)) {
      $response = pfpro_process($this->params, $this->hostaddress, $this->hostport, $this->timeout, $this->proxyaddress);
    }
    else if ($this->timeout and $this->timeout > 0) {
      $response = pfpro_process($this->params, $this->hostaddress, $this->hostport, $this->timeout);
    }
    else if ($this->hostport and $this->hostport > 0) {
      $response = pfpro_process($this->params, $this->hostaddress, $this->hostport);
    }
    else if ($this->hostaddress and ($this->hostaddress)) {
      $response = pfpro_process($this->params, $this->hostaddress);
    }
    else {
      $response = pfpro_process($this->params);
    }

    if (!$response) {
      return new VerisignException('No response received from Payflow Pro!');
    }

    if (!$response['RESULT']) {
      $response['RESULT'] = -999;
    }

    return $response;
  }

  /* Decode the myriad of Verisign response codes into a meaningful few */



  function decode_response($code)
  {
    if (is_array($code)) {
      $code = $code['RESULT'];
    }
    else if (!is_integer($code)) {
      return new VerisignException('Result code must be an integer');
    }

    switch ($code) {

    case 0:    /* Approved                                  */
      return VERISIGN_SUCCESS;

    case 12:   /* Declined                                  */
    case 23:   /* Invalid account number                    */
    case 50:   /* Insufficient funds available              */
    case 112:  /* Failed AVS check                          */
      return VERISIGN_BAD_CARD;

    case 24:   /* Invalid expiry date                       */
      return VERISIGN_INVALID_EXPIRY;

    case 2:    /* Invalid tender                            */
	return VERISIGN_BAD_CARD_TYPE;

    case 1:    /* User authentication failed                */
    case 3:    /* Invalid transaction type                  */
    case 4:    /* Invalid amount                            */
    case 5:    /* Invalid merchant information              */
    case 7:    /* Field format error                        */
    case 19:   /* Original transaction ID not found         */
    case 20:   /* Cannot find the customer reference number */
    case 22:   /* Invalid ABA number                        */
    case 25:   /* Transaction type not mapped to this host  */
    case 100:  /* Invalid transaction returned from host    */
    case 105:  /* Credit error                              */
    case 108:  /* Void error                                */
    case 111:  /* Capture error                             */
    case 113:  /* Cannot exceed sales cap                   */
      return VERISIGN_CONFIG_ERROR;

    case 11:   /* Client timeout waiting for response       */
    case 101:  /* Timeout value too small                   */
    case 102:  /* Host unavailable                          */
    case 103:  /* Error reading response from host          */
    case 104:  /* Tiemout waiting for host response         */
    case -1:   /* Server socket unavailable                 */
    case -2:   /* Hostname lookup failed                    */
    case -3:   /* Client time out                           */
    case -4:   /* Socket initialisation error               */
    case -5:   /* SSL context initialisation failed         */
    case -6:   /* SSL verification policy error             */
    case -7:   /* SSL verify location error                 */
    case -8:   /* X509 certification verification error     */
    case -99:  /* Internal error to the library             */
    case -999: /* Error from this class, no result found    */
      return VERISIGN_TEMPORARY_ERROR;

    case 13:   /* Referral                                  */
      return VERISIGN_REFERRAL;
    }

    /* 99: General error */
    /* 1000: Generic host error */
    /* and any others */

    return VERISIGN_UNRECOGNISED_RESPONSE;
  }


  /*
   * bool isError ($var)
   *  Determine whether or not a variable is a PEAR exception
   */
  function isError ($var)
  {
    return (is_object ($var) and
	    substr (get_class ($var), -9) == 'Exception');
  }
	
  /*
   *    double Payment_Verisign_version(void)
   *      Returns the current Payment_Verisign version.
   */
  function Payment_Verisign_version()
  {
    return (0.1);
  }

}

class VerisignException extends PEAR_Error
{
  var $classname             = 'VerisignException';
  var $error_message_prepend = 'Error in Payment_Verisign';

  function VerisignException($message)
  {
    $this->PEAR_Error($message);
  }
}

?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -