Hardik
Hardik

Reputation: 1411

PHP SOAP API call with XML request

I have not worked with SOAP API before. I want to execute a SOAP API with XML data request. I have tried but did not get success. https://www.getpayments.com/docs/#processrealtimetokenpayment This is the payment gateway URL which I have want to call.

I have used below code :

$xml = '<?xml version="1.0" encoding="utf-8"?>
  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:px="https://px.ezidebit.com.au/">
  <soapenv:Header />
  <soapenv:Body>
    <px:ProcessRealtimeTokenPayment>
      <px:digitalKey>715C0799-307B-4BF4-7B1D-4153201FC0A1</px:digitalKey>
      <px:token>3723758</px:token>
      <px:paymentAmountInCents>1600</px:paymentAmountInCents>
      <px:customerName>Hiren Patel</px:customerName>
      <px:paymentReference>123456789</px:paymentReference>
    </px:ProcessRealtimeTokenPayment>
  </soapenv:Body>
</soapenv:Envelope>';
$soapUrl = "https://api.demo.ezidebit.com.au/v3-5/pci?singleWsdl";
$soap_do = curl_init(); 
curl_setopt($soap_do, CURLOPT_URL,            $soapUrl );   
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10); 
curl_setopt($soap_do, CURLOPT_TIMEOUT,        10); 
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);  
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false); 
curl_setopt($soap_do, CURLOPT_POST,           true ); 
curl_setopt($soap_do, CURLOPT_POSTFIELDS,    $xml); 
curl_setopt($soap_do, CURLOPT_HTTPHEADER,     array('Content-Type: text/xml; charset=utf-8', 'Content-Length: '.strlen($xml) )); 
$result = curl_exec($soap_do);
$err = curl_error($soap_do);  
curl_close($soap_do);
echo "<pre>";print_r($result);
die;

It throws below error :

a:ActionNotSupportedThe message with Action 'ProcessRealtimeTokenPayment' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).Curl call success.

Please anyone can guide me in this? Thank you in advance.

Upvotes: 0

Views: 1106

Answers (1)

Vladimir Kanazir
Vladimir Kanazir

Reputation: 140

Here is an example with SoapClient:

<?php

$soap = new SoapClient(
    'https://api.demo.ezidebit.com.au/v3-5/pci?singleWsdl',
    array(
        'trace' => 1,
        'exceptions' => 1
    )
);

$soap->ProcessRealtimeCreditCardPayment(
    array(
        'DigitalKey' => '715C0799-307B-4BF4-7B1D-4153201FC0A1',
        'Token' => '3723758',
        'PaymentAmountInCents' => '1600',
        'CustomerName' => 'Hiren Patel',
        'PaymentReference' => '123456789'
    )
);

echo $soap->__getLastRequest() . "\n";
echo $soap->__getLastResponse() . "\n";

You can save it into the file and run with:

php file.php

Upvotes: 1

Related Questions