コード例 #1
0
 /**
  * Call this function when the confirmation URL is called by the Scheme Operator.
  * The function will write ShopResponseDetails to the $outputStream in case of
  * BankConfirmationDetails.
  * 
  * @param callable $confirmationCallback a callable to send BankConfirmationDetails to.
  * Will be called with the raw post data as first parameter and an Instance of
  * BankConfirmationDetails as second parameter. This callable must return TRUE.
  * @param callable $vitalityCheckCallback an optional callable for the vitalityCheck
  * @param string $rawPostStream will read from this stream or file with file_get_contents
  * @param string $outputStream will write to this stream the expected responses for the
  * Scheme Operator
  * @throws InvalidCallbackException when callback is not callable
  * @throws CallbackResponseException when callback does not return TRUE
  * @throws XmlValidationException when $rawInputStream does not validate against XSD
  * @throws \UnexpectedValueException when using security suffix without security seed
  * @throws UnknownRemittanceIdentifierException when security suffix does not match
  */
 public function HandleConfirmationUrl($confirmationCallback, $vitalityCheckCallback = null, $rawPostStream = 'php://input', $outputStream = 'php://output')
 {
     $shopResponseDetails = new ShopResponseDetails();
     try {
         $this->TestCallability($confirmationCallback, 'confirmationCallback');
         if ($vitalityCheckCallback != null) {
             $this->TestCallability($vitalityCheckCallback, 'vitalityCheckCallback');
         }
         $HTTP_RAW_POST_DATA = file_get_contents($rawPostStream);
         XmlValidator::ValidateEpsProtocol($HTTP_RAW_POST_DATA);
         $xml = new \SimpleXMLElement($HTTP_RAW_POST_DATA);
         $epspChildren = $xml->children(XMLNS_epsp);
         $firstChildName = $epspChildren[0]->getName();
         if ($firstChildName == 'VitalityCheckDetails') {
             $this->WriteLog('Vitality Check');
             if ($vitalityCheckCallback != null) {
                 $VitalityCheckDetails = new VitalityCheckDetails($xml);
                 $this->ConfirmationUrlCallback($vitalityCheckCallback, 'vitality check', array($HTTP_RAW_POST_DATA, $VitalityCheckDetails));
             }
             // 7.1.9 Schritt III-3: Bestätigung Vitality Check Händler-eps SO
             file_put_contents($outputStream, $HTTP_RAW_POST_DATA);
         } else {
             if ($firstChildName == 'BankConfirmationDetails') {
                 $this->WriteLog('Bank Confirmation');
                 $BankConfirmationDetails = new BankConfirmationDetails($xml);
                 // Strip security hash from remittance identifier
                 $BankConfirmationDetails->SetRemittanceIdentifier($this->StripHash($BankConfirmationDetails->GetRemittanceIdentifier()));
                 $shopResponseDetails->SessionId = $BankConfirmationDetails->GetSessionId();
                 $shopResponseDetails->StatusCode = $BankConfirmationDetails->GetStatusCode();
                 $shopResponseDetails->PaymentReferenceIdentifier = $BankConfirmationDetails->GetPaymentReferenceIdentifier();
                 $this->WriteLog(sprintf('Calling confirmationUrlCallback for remittance identifier "%s" with status code %s', $BankConfirmationDetails->GetRemittanceIdentifier(), $BankConfirmationDetails->GetStatusCode()));
                 $this->ConfirmationUrlCallback($confirmationCallback, 'confirmation', array($HTTP_RAW_POST_DATA, $BankConfirmationDetails));
                 // Schritt III-8: Bestätigung Erhalt eps Zahlungsbestätigung Händler-eps SO
                 $this->WriteLog('III-8 Confirming payment receipt');
                 file_put_contents($outputStream, $shopResponseDetails->GetSimpleXml()->asXml());
             }
         }
     } catch (\Exception $e) {
         $this->WriteLog($e->getMessage());
         if (is_subclass_of($e, 'at\\externet\\eps_bank_transfer\\ShopResponseException')) {
             $shopResponseDetails->ErrorMsg = $e->GetShopResponseErrorMessage();
         } else {
             $shopResponseDetails->ErrorMsg = 'An exception of type "' . get_class($e) . '" occurred during handling of the confirmation url';
         }
         file_put_contents($outputStream, $shopResponseDetails->GetSimpleXml()->asXml());
         throw $e;
     }
 }
 public function testGetReferenceIdentifier()
 {
     $t = new BankConfirmationDetails($this->simpleXmls['WithSignature']);
     $actual = $t->GetReferenceIdentifier();
     $this->assertEquals('1234567890ABCDEFG', $actual);
 }