HTTP / 1.1 405方法不允许允许authorized.net

时间:2014-07-10 10:27:07

标签: xml magento authorize.net recurring-billing http-status-code-405

我在magento中创建了authorized.net的定期订阅。我成功创建了subscription.I添加了一个取消订阅和传递xml的选项,但它不接受。

                $loginname="******";
            $transactionkey="*******";
            $host = "apitest.authorize.net";

                    $content=
                    "<?xml version=\"1.0\" encoding=\"utf-8\"?>".
                    "<ARBCancelSubscriptionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">".
                    "<merchantAuthentication>".
                    "<name>" . $loginname . "</name>".
                    "<transactionKey>" . $transactionkey . "</transactionKey>".
                    "</merchantAuthentication>" .
                    "<subscriptionId>" . 2179811  . "</subscriptionId>".
                    "</ARBCancelSubscriptionRequest>";

                    echo $response = send_request_via_curl($host,$path,$content);die;

不允许405方法。请帮助!

1 个答案:

答案 0 :(得分:1)

最后,我通过修改我的代码来解决它。基本上问题是标题

`public function cancelSubscriptionAction()
        {
                $xml_str ='<?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>
                <ARBCancelSubscription xmlns="https://api.authorize.net/soap/v1/">
                <merchantAuthentication>
                <name>******</name>
                <transactionKey>******</transactionKey>
                </merchantAuthentication>
                <subscriptionId>******</subscriptionId>
                </ARBCancelSubscription>
                </soap:Body>
                </soap:Envelope>';

                $headers = array( 
                'Content-Type: text/xml; charset="utf-8"', 
                'Content-Length: '.strlen($xml_str), 
                'Accept: text/xml', 
                'Cache-Control: no-cache', 
                'Pragma: no-cache', 
                ); 

                $remote_url = 'https://apitest.authorize.net/soap/v1/Service.asmx';
                $process = curl_init($remote_url);
                curl_setopt($process, CURLOPT_HTTPHEADER, $headers);
                curl_setopt($process, CURLOPT_HEADER, 1);
                curl_setopt($process, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
                curl_setopt($process, CURLOPT_TIMEOUT, 30);
                curl_setopt($process, CURLOPT_POST, 1);
                curl_setopt($process, CURLOPT_POSTFIELDS, $xml_str);
                curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
                $return = curl_exec($process);
                $finale = list ($resultCode, $code, $text, $subscriptionId) =parse_return($return);
                print_r($finale );
                curl_close($process);

        }`