private function _get_payu_transaction($reference)
 {
     $return_data = array();
     //-------------------------------------------------------------------
     //-------------------------------------------------------------------
     //-------
     //-------      Configs comes here
     //-------
     //-------------------------------------------------------------------
     //-------------------------------------------------------------------
     $baseUrl = 'https://staging.payu.co.za';
     $soapWdslUrl = $baseUrl . '/service/PayUAPI?wsdl';
     $payuRppUrl = $baseUrl . '/rpp.do?PayUReference=';
     $apiVersion = 'ONE_ZERO';
     /*
     Using staging integartion store 1 details
     Store ID: 100284
     Webservice username : Staging Integration Store 1
     Webservice password : 78cXrW1W
     Safekey: {45D5C765-16D2-45A4-8C41-8D6F84042F8C} 
     */
     $safeKey = '{45D5C765-16D2-45A4-8C41-8D6F84042F8C}';
     $soapUsername = '******';
     $soapPassword = '******';
     $payUReference = $reference;
     try {
         // 1. Building the Soap array  of data to send
         $soapDataArray = array();
         $soapDataArray['Api'] = $apiVersion;
         $soapDataArray['Safekey'] = $safeKey;
         $soapDataArray['AdditionalInformation']['payUReference'] = $payUReference;
         // 2. Creating a XML header for sending in the soap heaeder (creating it raw a.k.a xml mode)
         $headerXml = '<wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">';
         $headerXml .= '<wsse:UsernameToken wsu:Id="UsernameToken-9" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">';
         $headerXml .= '<wsse:Username>' . $soapUsername . '</wsse:Username>';
         $headerXml .= '<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">' . $soapPassword . '</wsse:Password>';
         $headerXml .= '</wsse:UsernameToken>';
         $headerXml .= '</wsse:Security>';
         $headerbody = new SoapVar($headerXml, XSD_ANYXML, null, null, null);
         // 3. Create Soap Header.
         $ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
         //Namespace of the WS.
         $header = new SOAPHeader($ns, 'Security', $headerbody, true);
         // 4. Make new instance of the PHP Soap client
         $soap_client = new SoapClient($soapWdslUrl, array("trace" => 1, "exception" => 0));
         // 5. Set the Headers of soap client.
         $soap_client->__setSoapHeaders($header);
         // 6. Do the setTransaction soap call to PayU
         $soapCallResult = $soap_client->getTransaction($soapDataArray);
         // 7. Decode the Soap Call Result
         $returnData = json_decode(json_encode($soapCallResult), true);
         //Get the PayUReference ->
         $payu_reference = $returnData['return']['payUReference'];
         $transaction = ClassRegistry::init('FinPayuTransaction');
         $q_r = $transaction->find('first', array('conditions' => array('FinPayuTransaction.payu_reference' => $payu_reference)));
         if ($q_r) {
             $transaction_state = $returnData['return']['transactionState'];
             $transaction_type = $returnData['return']['transactionType'];
             $result_code = $returnData['return']['resultCode'];
             $result_message = $returnData['return']['resultMessage'];
             $display_message = $returnData['return']['displayMessage'];
             $q_r['FinPayuTransaction']['transaction_state'] = $transaction_state;
             $q_r['FinPayuTransaction']['transaction_type'] = $transaction_type;
             $q_r['FinPayuTransaction']['result_code'] = $result_code;
             $q_r['FinPayuTransaction']['result_message'] = $result_message;
             $q_r['FinPayuTransaction']['display_message'] = $display_message;
             unset($q_r['FinPayuTransaction']['created']);
             unset($q_r['FinPayuTransaction']['modified']);
             //Update the record
             $transaction->save($q_r);
             $return_data['record'] = $q_r;
         } else {
             $return_data['error'] = "payUReference {$payu_reference} not recorded in local database";
         }
         return $return_data;
     } catch (Exception $e) {
         var_dump($e);
     }
 }
Example #2
0
 function getTransaction($payUReference)
 {
     //---Location of radclient----
     $this->settings = Configure::read('payu');
     // 1. Building the Soap array  of data to send
     $soapDataArray = array();
     $soapDataArray['Api'] = $this->settings['apiVersion'];
     $soapDataArray['Safekey'] = $this->settings['safeKey'];
     $soapDataArray['AdditionalInformation']['payUReference'] = $payUReference;
     // 2. Creating a XML header for sending in the soap heaeder (creating it raw a.k.a xml mode)
     $headerXml = '<wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">';
     $headerXml .= '<wsse:UsernameToken wsu:Id="UsernameToken-9" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">';
     $headerXml .= '<wsse:Username>' . $this->settings['soapUsername'] . '</wsse:Username>';
     $headerXml .= '<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">' . $this->settings['soapPassword'] . '</wsse:Password>';
     $headerXml .= '</wsse:UsernameToken>';
     $headerXml .= '</wsse:Security>';
     $headerbody = new SoapVar($headerXml, XSD_ANYXML, null, null, null);
     // 3. Create Soap Header.
     $ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
     //Namespace of the WS.
     $header = new SOAPHeader($ns, 'Security', $headerbody, true);
     // 4. Make new instance of the PHP Soap client
     $soap_client = new SoapClient($this->settings['soapWdslUrl'], array("trace" => 1, "exception" => 0));
     // 5. Set the Headers of soap client.
     $soap_client->__setSoapHeaders($header);
     // 6. Do the setTransaction soap call to PayU
     $soapCallResult = $soap_client->getTransaction($soapDataArray);
     // 7. Decode the Soap Call Result
     $returnData = json_decode(json_encode($soapCallResult), true);
     return $returnData;
 }
    $headerXml .= '<wsse:UsernameToken wsu:Id="UsernameToken-9" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">';
    $headerXml .= '<wsse:Username>' . $soapUsername . '</wsse:Username>';
    $headerXml .= '<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">' . $soapPassword . '</wsse:Password>';
    $headerXml .= '</wsse:UsernameToken>';
    $headerXml .= '</wsse:Security>';
    $headerbody = new SoapVar($headerXml, XSD_ANYXML, null, null, null);
    // 3. Create Soap Header.
    $ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
    //Namespace of the WS.
    $header = new SOAPHeader($ns, 'Security', $headerbody, true);
    // 4. Make new instance of the PHP Soap client
    $soap_client = new SoapClient($soapWdslUrl, array("trace" => 1, "exception" => 0));
    // 5. Set the Headers of soap client.
    $soap_client->__setSoapHeaders($header);
    // 6. Do the setTransaction soap call to PayU
    $soapCallResult = $soap_client->getTransaction($soapDataArray);
    // 7. Decode the Soap Call Result
    $returnData = json_decode(json_encode($soapCallResult), true);
    $decodedXmlData = json_decode(json_encode((array) simplexml_load_string($returnData)), true);
    print "<pre>";
    var_dump($decodedXmlData);
    print "</pre>";
} catch (Exception $e) {
    var_dump($e);
}
//-------------------------------------------------------------------
//-------------------------------------------------------------------
//-------
//-------      Checking response
//-------
//-------------------------------------------------------------------