简体   繁体   English

集成 NAB 支付网关时未收到任何错误或成功消息

[英]Not getting any error or success message while integrating NAB payment gateway

I have tried so far:到目前为止我已经尝试过:

<?php
    $url = "https://demo.transact.nab.com.au/xmlapi/payment";
        $ch = curl_init();
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, "XML=".$xml);
            $content=curl_exec($ch);
            curl_close($ch);
           print_r('<pre>');
            print_r($content);
            print_r('</pre>');


            $array_data = json_decode(json_encode(simplexml_load_string($content)), true);



            print_r('<pre>');
            print_r($array_data);
            print_r('</pre>');

            ?>

I am not getting any success or error message while trying the same code.尝试相同的代码时,我没有收到任何成功或错误消息。 Not getting any message in JSON or array format.没有收到任何 JSON 或数组格式的消息。
It's a NAB Transact payment gateway.这是一个 NAB Transact 支付网关。

I have to write this as an answer, because of the code examples.由于代码示例,我必须将其写为答案。

Did you look in the NabTransact Integration Guide, or anything that has been sent to you before you've started this issue?您是否查看了 NabTransact 集成指南,或在您开始此问题之前发送给您的任何内容? Error 515 means there is a " fatal error due to unknown reasons ".错误 515 表示存在“由于未知原因导致的致命错误”。 Once I've had a similar error, my headers were not right.一旦我遇到类似的错误,我的标题就不正确。

You could try to use use CURLOPT_HTTPHEADER since it is not defined:您可以尝试使用CURLOPT_HTTPHEADER因为它没有定义:

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
                                   'Content-type: application/xml', 
                                   'Content-length: ' . strlen($xml)
                                 ));

And making sure $xml is all in one-line.并确保$xml全部在一行中。

. .

What does the Integration Guide say?集成指南怎么说?

The Integration Guide says the following:集成指南说明如下:

Chapter 8. XML Over HTTP第 8 章 HTTP 上的 XML

The structure of the HTTP request and response messages will need to conform to the HTTP 1.1 network protocol. HTTP 请求和响应消息的结构需要符合 HTTP 1.1 网络协议。 (...) Important: The HTTP communication between the client als NAB Transact Payment Gateway must be done via SSL socket so that sensitive information included in the request and response messages are encrypted. (...)重要提示:客户端和 NAB 交易支付网关之间的 HTTP 通信必须通过 SSL 套接字完成,以便对请求和响应消息中包含的敏感信息进行加密。

8.1 Request 8.1 请求

POST /test/payment HTTP/1.1 host: www.NABTransact.com.au content-type: text/xml content-length: 677 <?xml-rubbish here, all in one-line>

. .

8.2 Response 8.2 响应

The initial HTTP server response (100 continue) is to indicate that the request has been received and should be ignored.最初的 HTTP 服务器响应(100 continue)表示请求已经收到,应该被忽略。 The 200 response should follow with the XML response message. 200 响应应跟随 XML 响应消息。 If content length is 0 and no XML response is included then the request could not be understood and no response was produced.如果内容长度为 0 且未包含 XML 响应,则无法理解该请求且未产生响应。

Followed by a XML-response with data.随后是带有数据的 XML 响应。

So, make sure you're using the correct headers in your cURL and using SSL.因此,请确保在 cURL 中使用正确的标头使用 SSL。 If you cannot use an official SSL certificate because you're working on localhost, there are tricks in cURL where you can use your own certificate or bypassing the SSL-check.如果由于在本地主机上工作而无法使用官方 SSL 证书,cURL 中有一些技巧,您可以使用自己的证书或绕过 SSL 检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM