Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何用php开发neteller Direct API?_Php_Ajax_Curl - Fatal编程技术网

如何用php开发neteller Direct API?

如何用php开发neteller Direct API?,php,ajax,curl,Php,Ajax,Curl,我正在网站上开发neteller direct api,用户可以将资金转移到我们的商户账户。API步骤包括: 在网站上创建表单 要求用户填写表格 将表单提交到neteller安全URL,该URL返回包含响应元素的XML页面 我不知道提交表格后下一步该做什么?当我们提交表单时,我们得到了xml页面,这很好,但是现在该怎么做呢?我需要将结果显示给用户,以便在提交表单后,用户能够看到一条消息,上面写着“Transaction Done”,或者基于XML批准值的类似消息。我尝试使用jQueryAJAXP

我正在网站上开发neteller direct api,用户可以将资金转移到我们的商户账户。API步骤包括:

  • 在网站上创建表单
  • 要求用户填写表格
  • 将表单提交到neteller安全URL,该URL返回包含响应元素的XML页面
  • 我不知道提交表格后下一步该做什么?当我们提交表单时,我们得到了xml页面,这很好,但是现在该怎么做呢?我需要将结果显示给用户,以便在提交表单后,用户能够看到一条消息,上面写着“Transaction Done”,或者基于XML批准值的类似消息。我尝试使用jQueryAJAXPOST方法,这样我可以在jQueryXML对象中接收响应,所有表单提交都在后台进行,当请求完成时,我可以获得响应XML对象以显示给用户。这不起作用,因为跨域发布不起作用。(我在网上的某个地方读到)那么,为用户提供最佳用户体验的正确步骤是什么?我们无法向用户显示此xml。那么想知道在提交表单后如何进行下一步吗

    表格示例:

    <form method="post" action="https://api.neteller.com/netdirect">
    <input type="text" name="version" value=" 4.1">
    <input type="text" name="amount" size="10" value="0.02" maxlength="10">
    <input type="text" name="currency" value="USD" size="10" maxlength="3">
    <input type="text" name="net_account" size="20" maxlength="100">
    <input type="text" name="secure_id" size="10" maxlength="6">
    <input type="hidden" name="merchant_id" value="">
    <input type="hidden" name="merch_key" value="">
    <input type="hidden" name="merch_transid" value="" maxlength="50">
    <input type="hidden" name="language_code" value="EN">
    <input type="hidden" name="merch_name" value="">
    <input type="hidden" name="merch_account" value="" maxlength="50">
    <input type="hidden" name="custom_1" value="test123" maxlength="50">
    <input type="hidden" name="custom_2" value="test123" maxlength="50">
    <input type="hidden" name="custom_3" value="test123" maxlength="50">
    <button type="submit" name="submit">Make Transfer</button>
    
    
    转帐
    


    有谁能帮我完成这件事吗?AJAX或CURL还是how?

    您不会将请求发送到neteller,而是发送到您的服务器 然后将请求从服务器发送到neteller

    --这样它就可以进入你的服务器

    function netellerPayment(){
        $.ajax({
            async: false,
            type: "POST",
            url: "http://localhost/neteller/notification.php",
            data: $("#netellerform").serialize(),
            success: function(data){
            }
        })
    }
    
    $(function() {
        $('#submitneteller').click(function( event ){
            event.preventDefault();
            netellerPayment();
        })
    })
    
    $urltopost = "https://api.neteller.com/netdirect";
    $data = $_POST;
    
    $urltopost = "https://api.neteller.com/netdirect";
    $ch = curl_init ($urltopost);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    $returndata = curl_exec ($ch);
    
    $xml = new DOMDocument ( '1.0', 'utf-8' );
    $xml->preserveWhiteSpace = false;
    $xml->loadXML ( $returndata );
    $errors = $xml->getElementsByTagName( 'error' );
    foreach ($errors as $error) {
        echo $error->nodeValue; 
    }
    
    --现在在您的服务器上安装php

    function netellerPayment(){
        $.ajax({
            async: false,
            type: "POST",
            url: "http://localhost/neteller/notification.php",
            data: $("#netellerform").serialize(),
            success: function(data){
            }
        })
    }
    
    $(function() {
        $('#submitneteller').click(function( event ){
            event.preventDefault();
            netellerPayment();
        })
    })
    
    $urltopost = "https://api.neteller.com/netdirect";
    $data = $_POST;
    
    $urltopost = "https://api.neteller.com/netdirect";
    $ch = curl_init ($urltopost);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    $returndata = curl_exec ($ch);
    
    $xml = new DOMDocument ( '1.0', 'utf-8' );
    $xml->preserveWhiteSpace = false;
    $xml->loadXML ( $returndata );
    $errors = $xml->getElementsByTagName( 'error' );
    foreach ($errors as $error) {
        echo $error->nodeValue; 
    }
    

    我可以通过卷曲来完成。我使用了curl方法发布到url,并以xml的形式获取结果,该结果随后由php方法simplexml_load_string()解析