Orbital Paymentech

Тема у розділі 'www', створена користувачем fortestsite, 18 лип 2012.

  1. fortestsite

    fortestsite New Member

    Цікавить система оплати Orbital Paymentech

    Добрий день! Пошукавши матеріали в Google написав такий клас

    // file Orbital.php
    <?php

    class Orbital {

    protected $_url;
    protected $_payment = array();
    protected $_billingAddress = array();
    protected $_order = array();
    protected $_amount;
    protected $_configData = array();

    public function __construct(
    $url,
    $payment,
    $billingAddress,
    $order,
    $amount,
    $configData
    )
    {
    $this->_url = $url;
    $this->_payment = $payment;
    $this->_billingAddress = $billingAddress;
    $this->_order = $order;
    $this->_amount = $amount;
    $this->_configData = $configData;
    }

    public function callDoDirectPayment()
    {
    $payment = $this->_payment;
    $billing = $this->_billingAddress;
    $order = $this->_order;
    $configData = $this->_configData;
    $amount = $this->_amount;

    if (strlen($payment['CcExpMonth'])==1)
    $exp="0".$payment['CcExpMonth'].substr($payment['CcExpYear'],-2);
    else
    $exp=$payment['CcExpMonth'].substr($payment['CcExpYear'],-2);

    $amt=str_replace('.','',$amount);
    $xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    $xml .= "<Request>";
    $xml .= "<NewOrder>";
    $xml .= "<IndustryType>EC</IndustryType>";
    $xml .= "<MessageType>AC</MessageType>";
    $xml .= "<BIN>".htmlentities(trim($configData['bin_no']),ENT_QUOTES, 'UTF-8')."</BIN>";
    $xml .= "<MerchantID>".htmlentities(trim($configData['merchant_id']),ENT_QUOTES, 'UTF-8')."</MerchantID>";
    $xml .= "<TerminalID>".htmlentities(trim($configData['terminal_id']),ENT_QUOTES, 'UTF-8')."</TerminalID>";
    $xml .= "<AccountNum>".htmlentities(trim($payment['CcNumber']),ENT_QUOTES, 'UTF-8')."</AccountNum>";
    $xml .= "<Exp>".htmlentities(trim($exp),ENT_QUOTES, 'UTF-8')."</Exp>";
    if (($payment['CcType']=='VI') || ($payment['CcType']=='DI'))
    $xml .= "<CardSecValInd>1</CardSecValInd>";
    $xml .= "<CardSecVal>".htmlentities(trim($payment['CcCid']),ENT_QUOTES, 'UTF-8')."</CardSecVal>";
    $xml .= "<AVSzip>".htmlentities(trim($billing['Postcode']),ENT_QUOTES, 'UTF-8')."</AVSzip>";
    $xml .= "<AVSaddress1>".htmlentities(trim($billing['Street1']),ENT_QUOTES, 'UTF-8')."</AVSaddress1>";
    $xml .= "<AVSaddress2>".htmlentities(trim($billing['Street2']),ENT_QUOTES, 'UTF-8')."</AVSaddress2>";
    $xml .= "<AVScity>".htmlentities(trim($billing['City']),ENT_QUOTES, 'UTF-8')."</AVScity>";
    $xml .= "<AVSstate>CA</AVSstate>";
    $xml .= "<AVSname>".htmlentities(trim($billing['Firstname']),ENT_QUOTES, 'UTF-8')."</AVSname>";
    $xml .= "<OrderID>".htmlentities(trim($order['IncrementId']),ENT_QUOTES, 'UTF-8')."</OrderID>";
    $xml .= "<Amount>".htmlentities(trim($amt),ENT_QUOTES, 'UTF-8')."</Amount>";
    $xml .= "<Comments>AC</Comments>";
    $xml .= "<ShippingRef></ShippingRef>";
    $xml .= "</NewOrder>";
    $xml .= "</Request>";

    $resultArr = $this->call($xml);
    if ($resultArr === false)
    return false;

    return $resultArr;
    }

    public function call($xml)
    {
    $url = $this->_url;

    $header= "POST /AUTHORIZE HTTP/1.0\r\n";
    $header.= "MIME-Version: 1.0\r\n";
    $header.= "Content-type: application/PTI49\r\n";
    $header.= "Content-length: " .strlen($xml) . "\r\n";
    $header.= "Content-transfer-encoding: text\r\n";
    $header.= "Request-number: 1\r\n";
    $header.= "Document-type: Request\r\n";
    $header.= "Interface-Version: Test 1.4\r\n";
    $header.= "Connection: close \r\n\r\n";
    $header.= $xml;

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $response = curl_exec($ch);

    if (curl_errno($ch))
    print curl_error($ch);
    else
    curl_close($ch);

    $xml_parser = xml_parser_create();
    xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,0);
    xml_parser_set_option($xml_parser,XML_OPTION_SKIP_WHITE,1);
    xml_parse_into_struct($xml_parser, $response, $vals, $index);
    xml_parser_free($xml_parser);

    $parsedResArr = $this->parseXmlResponse($vals);

    var_dump($parsedResArr);

    if (@$parsedResArr['ProcStatus'] == 0)
    {
    if (@$parsedResArr['ApprovalStatus'] == 1)
    return $parsedResArr;
    }
    else
    {
    if ($parsedResArr['ProcStatus']!=0)
    {
    $message = 'System Error : '.$parsedResArr['StatusMsg'];
    $message = str_replace(' ','',$message);
    return $message;
    }
    else if (
    $parsedResArr['ApprovalStatus'] == 0 ||
    $parsedResArr['ApprovalStatus'] == 2
    )
    {
    $message = 'Card is in Decline State';
    return $message;
    }
    else if ($parsedResArr['CVV2RespCode']!='M')
    {
    $message ='Cardholder Verification : '.$parsedResArr['RespMsg'];
    $message = str_replace(' ','',$message);
    return $message;
    }
    else if(
    $parsedResArr['AVSRespCode'] !='Z' ||
    $parsedResArr['AVSRespCode'] !='9' ||
    $parsedResArr['AVSRespCode'] !='H'
    )
    {
    $message ='Address Verfication : '.$parsedResArr['RespMsg'];
    $message = str_replace(' ','',$message);
    return $message;
    }
    }
    return false;
    }

    private function parseXmlResponse($xmlResponse)
    {
    $newResArr = array();
    foreach ($xmlResponse as $val)
    {
    $tagval=$val['tag'];
    if (($val['tag']!='Response') && ($val['tag']!='NewOrderResp')) {
    if (isset($val['value']))
    $newResArr[$tagval]=$val['value'];
    else
    $newResArr[$tagval]='';
    }
    }
    return $newResArr;
    }

    }

    ?>

    // file index.php
    <?php

    include_once "Orbital.php";

    //$url = 'https://orbital1.paymentech.net';
    $url = 'https://orbitalvar1.paymentech.net';

    $payment['CcNumber'] = '2456750000012345';
    $payment['CcType'] = 'VI';
    $payment['CcCid'] = '124';
    $payment['CcExpMonth'] = '01';
    $payment['CcExpYear'] = '13';

    $billing['Postcode'] = '25541';
    $billing['Street1'] = '123 Test Street';
    $billing['Street2'] = 'Suite 350';
    $billing['City'] = 'Test City';
    $billing['Firstname'] = 'Jon Smith';

    $order['IncrementId'] = '1';

    $amount = '100';

    $configData['bin_no'] = '000002';
    $configData['merchant_id'] = '22200208567';
    $configData['terminal_id'] = '001';

    $orbital = new Orbital(
    $url,
    $payment,
    $billing,
    $order,
    $amount,
    $configData
    );

    var_dump(
    $orbital->callDoDirectPayment()
    );

    ?>

    Але виникає помилка:
    array
    'QuickResponse' => string'' (length = 0)
    'ProcStatus' => string '20412 '(length = 5)
    'StatusMsg' => string 'Precondition Failed: Security Information is missing' (length = 52)

    string 'SystemError: PreconditionFailed: SecurityInformationismissing' (length = 59)

    Хто працював з системою? Кажуть, що потрібно створити тестовий профіль і підписати контракт. Опишіть вихід з цієї ситуації. І ще якщо є - підкажіть де є ZF клас.
    На офіційному сайті документації є тільки на інших мовах http://download.chasepaymentech.com. На ZF або чистому PHP немає.
     
а де твій аватар? :)