public function testTransferInitiatorDetailsWithUnstructuredRemittanceIdentifier() { $transferMsgDetails = new TransferMsgDetails("http://10.18.70.8:7001/vendorconfirmation", "http://10.18.70.8:7001/transactionok?danke.asp", "http://10.18.70.8:7001/transactionnok?fehler.asp"); $transferMsgDetails->TargetWindowNok = $transferMsgDetails->TargetWindowOk = 'Mustershop'; $data = new TransferInitiatorDetails('AKLJS231534', 'topSecret', 'GAWIATW1XXX', 'Max Mustermann', 'AT611904300234573201', '1234567890ABCDEFG', 15000, $transferMsgDetails, '2007-03-16'); $data->UnstructuredRemittanceIdentifier = 'Foo is not Bar'; $data->SetExpirationMinutes(5); $aSimpleXml = $data->GetSimpleXml(); $actual = $aSimpleXml->asXML(); XmlValidator::ValidateEpsProtocol($actual); $this->assertContains('UnstructuredRemittanceIdentifier>Foo is not Bar', $actual); }
public function testHandleConfirmationUrlThrowsExceptionOnInvalidSecuritySetup() { $dataPath = $this->GetEpsDataPath('BankConfirmationDetailsWithSignature.xml'); $temp = tempnam(sys_get_temp_dir(), 'SoCommunicatorTest_'); $this->target->ObscuritySuffixLength = 3; try { $this->target->HandleConfirmationUrl(function () { }, null, $dataPath, $temp); } catch (\UnexpectedValueException $e) { // expected } $actual = file_get_contents($temp); XmlValidator::ValidateEpsProtocol($actual); $this->assertContains('ShopResponseDetails>', $actual); $this->assertContains('ErrorMsg>An exception of type "UnexpectedValueException" occurred during handling of the confirmation url', $actual); }
/** * 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 testWithSignatureReturnsTrue() { $ret = XmlValidator::ValidateEpsProtocol($this->GetEpsData('BankConfirmationDetailsWithSignature.xml')); $this->assertTrue($ret); }