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