Commit 4a1f8559 authored by GiorgosK's avatar GiorgosK

Better exception handling doing the SoapClient request

parent 94a03d47
......@@ -61,7 +61,7 @@ class WinbankPaymentRedirectForm extends BasePaymentOffsiteForm implements Conta
try {
$result = $this->getNewTicket($amount, $order->id(), $config);
if ($result->IssueNewTicketResult->ResultCode == 0) {
if ($result !== null && $result->IssueNewTicketResult->ResultCode == 0) {
// Save response data for validating response later.
$order->setData("IssueNewTicketResult", [
......@@ -78,12 +78,16 @@ class WinbankPaymentRedirectForm extends BasePaymentOffsiteForm implements Conta
}
else {
$message = 'There was a problem connecting ot the ticket issuer: ' . $result->IssueNewTicketResult->ResultDescription;
$message = 'There was a problem connecting ot the ticket issuer.';
if(isset($result->IssueNewTicketResult->ResultDescription)){
$message .= " " . $result->IssueNewTicketResult->ResultDescription;
}
throw new InvalidResponseException($message);
}
}
catch (Exception $e) {
throw new InvalidResponseException('Could not connect to bank ticket issuer');
$message = 'Could not connect to bank ticket issuer';
throw new InvalidResponseException($message);
}
// Prepare redirect form.
......@@ -123,26 +127,32 @@ class WinbankPaymentRedirectForm extends BasePaymentOffsiteForm implements Conta
'location' => $config['tickets_url'],
'uri' => $config['tickets_url'],
];
$soap = new \SoapClient(NULL, $options);
$ticketRequest = [
'Username' => $config['username'],
'Password' => hash('md5', $config['password']),
'MerchantId' => $config['merchant_id'],
'PosId' => $config['pos_id'],
'AcquirerId' => $config['acquirer_id'],
'MerchantReference' => $orderid,
'RequestType' => $config['request_type'],
'ExpirePreauth' => 0,
'Amount' => $amount,
'CurrencyCode' => $config['currency_code'],
'Installments' => 0,
'Bnpl' => '0',
'Parameters' => '',
];
$xml = [
'Request' => $ticketRequest,
];
return $soap->IssueNewTicket($xml);
try {
$soap = new \SoapClient(NULL, $options);
$ticketRequest = [
'Username' => $config['username'],
'Password' => hash('md5', $config['password']),
'MerchantId' => $config['merchant_id'],
'PosId' => $config['pos_id'],
'AcquirerId' => $config['acquirer_id'],
'MerchantReference' => $orderid,
'RequestType' => $config['request_type'],
'ExpirePreauth' => 0,
'Amount' => $amount,
'CurrencyCode' => $config['currency_code'],
'Installments' => 0,
'Bnpl' => '0',
'Parameters' => '',
];
$xml = [
'Request' => $ticketRequest,
];
return $soap->IssueNewTicket($xml);
}
catch (\SoapFault $exception) {
$message = "Trying to IssueNewTicket on " . $config['tickets_url'] . ". " . $exception->getMessage();
$this->logger->alert($message);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment