如何使用php开发neteller Direct API?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了如何使用php开发neteller Direct API?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3340字,纯文字阅读大概需要5分钟。
内容图文
![如何使用php开发neteller Direct API?](/upload/InfoBanner/zyjiaocheng/678/512c7f444c534706bd2d269bc46457d7.jpg)
我正在网站上的neteller Direct API上工作,用户可以在其中将资金转移到我们的商人帐户. API步骤如下:
>在网站上创建表格
>要求用户填写表格
>将表单提交到neteller安全URL,该URL返回带有响应元素的XML页面
提交表格后,我下一步该怎么办?当我们提交表单时,我们得到xml页面,这很好,但是现在该怎么办?我需要将结果显示给用户,以便在提交表单后,用户将能够看到显示“ Transaction Done”的消息或基于XML批准值的类似消息.我尝试使用jQuery ajax POST方法,以便可以在jQuery XML对象中接收响应,并且所有表单提交都在后台进行,当请求完成时,我可以将响应xml对象显示给用户.由于跨域POST无法正常运行,因此无法正常工作. (我在网上的某个地方读过)那么为用户提供最佳用户体验的正确步骤是什么?我们无法将此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还是如何?
解决方法:
我能够通过CURL完成此操作.我已经使用curl方法发布到url并在xml中获取结果,该结果随后由php方法simplexml_load_string()解析.
// open curl connection
$ch = curl_init('https://api.neteller.com/netdirect');
// get the vars from POST request and add them as POST fields
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
'version' => $_POST['version'],
'amount' => urlencode($_POST['amount']),
'currency' => $_POST['currency'],
'net_account' => urlencode($_POST['net_account']),
'secure_id' => urlencode($_POST['secure_id']),
'merchant_id' => urlencode($_POST['merchant_id']),
'merch_key' => urlencode($_POST['merch_key']),
'merch_transid' => urlencode($_POST['merch_transid']),
'language_code' => $_POST['language_code'],
'merch_name' => urlencode($_POST['merch_name']),
'merch_account' => urlencode($_POST['merch_account']),
'custom_1' => urlencode($_POST['custom_1']),
'custom_2' => urlencode($_POST['custom_2']),
'custom_3' => urlencode($_POST['custom_3']),
'button' => 'Make Transfer'
]));
// set other curl options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
// execute post
$output = curl_exec($ch);
$info = curl_getinfo($ch);
$error = '';
$approval = '';
// check if curl request processed or not
if(($output == false) or ($output == '')) {
$curlerror = curl_error($ch);
$error = 'Server Error. ';
} else {
$response = simplexml_load_string($output);
$approval = $response->approval;
}
// close curl connection
curl_close($ch);
内容总结
以上是互联网集市为您收集整理的如何使用php开发neteller Direct API?全部内容,希望文章能够帮你解决如何使用php开发neteller Direct API?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。