Hoi,
Voor het voltooien van maandelijkse eenmalige machtigingen werk ik met Buckaroo. Buckaroo geeft de mogelijkheid om batches door te sturen met informatie over de transacties die voltooid moeten worden via een SOAP / XML - koppeling. Ik krijg echter geen connectie met de server van Buckaroo en vroeg me af of jullie me hiermee kunnen helpen.
Het volgende script (ik heb het even in 1 bestand gepropt) zou moeten zorgen voor de verzending:
<?php
class Transaction {
// Send GET/POST data through sockets
function postToHost($data, $timeout = 30)
{
$fsp = fsockopen('payment.buckaroo.nl');
$res = '';
if($fsp)
{
// echo "\n\nSEND DATA: \n\n" . $data . "\n\n";
fputs($fsp, 'POST /soap/soap.asmx HTTP/1.1' . $this->CRLF);
fputs($fsp, 'Host: payment.buckaroo.nl' . $this->CRLF);
fputs($fsp, 'Content-Type: text/xml; charset=utf-8' . $this->CRLF);
fputs($fsp, 'Content-Length: ' . strlen($data) . $this->CRLF);
fputs($fsp, 'SOAPAction: "https://payment.buckaroo.nl/EenmaligeMachtiging"' . $this->CRLF . $this->CRLF);
fputs($fsp, $data, strlen($data));
while(!feof($fsp))
{
$res .= @fgets($fsp, 128);
}
fclose($fsp);
// echo "\n\nRECIEVED DATA: \n\n" . $res . "\n\n";
}
else
{
$this->setError('Error while connecting to Buckaroo', false, __FILE__, __LINE__);
}
return $res;
}
protected function setError($sDesc, $sCode = false, $sFile = 0, $sLine = 0)
{
$this->aErrors[] = array('desc' => $sDesc, 'code' => $sCode, 'file' => $sFile, 'line' => $sLine);
}
public function getErrors()
{
return $this->aErrors;
}
public function hasErrors()
{
return (sizeof($this->aErrors) ? true : false);
}
}
$data='<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<EenmaligeMachtiging xmlns="https://payment.buckaroo.nl/">
<XMLMessage>
<Payload VersionID="1.0" xmlns="">
<Control Test="1">
<Timestamp>2011-07-06 12:10:53</Timestamp>
<MerchantID>1</MerchantID>
</Control>
<Content>
<Transaction Id="1">
<Customer>
<Gender>1</Gender>
<Firstname>Test</Firstname>
<Lastname>Test</Lastname>
<Mail>[email protected]</Mail>
</Customer>
<AccountNumber>123456789</AccountNumber>
<AccountName>Test</AccountName>
<Amount Currency="EUR">1</Amount>
<CollectDate>2011-08-01</CollectDate>
<CollectType>recurring</CollectType>
<Invoice>11080000001</Invoice>
<Reference></Reference>
<Description>Abbonnement 08/11</Description>
</Transaction>
</Content>
</Payload>
</XMLMessage>
<XMLSignature>
<Signature xmlns="">
<Fingerprint>1</Fingerprint>
<DigestMethod>MD5</DigestMethod>
<CalculateMethod>111</CalculateMethod>
<SignatureValue>1</SignatureValue>
</Signature>
</XMLSignature>
</EenmaligeMachtiging>
</soap:Body>
</soap:Envelope>';
$transaction = new Transaction;
echo $transaction->postToHost($data);
if($transaction->hasErrors()){
print_r($transaction->getErrors());
}
?>
Ik krijg de volgende error: Array ( [0] => Array ( [desc] => Error while connecting to Buckaroo [code] => [file] => /var/www/vhosts/newsmail.nl/httpdocs/soap-xml.php [line] => 34 ) ).
Normaal gezien verzend ik de XML altijd op deze manier en geeft dit geen problemen. Weet iemand een oplossing hiervoor?
Bvd,
Niek
6.727 views