Javascript 2checkout-无法使用沙盒模式生成令牌
我在PHP项目中使用2checkout支付网关,在使用“沙盒”模式生成令牌时遇到问题。代码如下:Javascript 2checkout-无法使用沙盒模式生成令牌,javascript,php,2checkout,Javascript,Php,2checkout,我在PHP项目中使用2checkout支付网关,在使用“沙盒”模式生成令牌时遇到问题。代码如下: <form action="" method="post" id="frmSignup" name="frmSignup"> <input type="hidden" value="" name="token" id="token
<form action="" method="post" id="frmSignup" name="frmSignup">
<input type="hidden" value="" name="token" id="token" />
<script type="text/javascript" src="https://www.2checkout.com/checkout/api/2co.min.js"></script>
<script>
// Called when token created successfully.
var successCallback = function(data) {
console.log("success::"+data);
var myForm = document.getElementById('frmSignup');
// Set the token as the value for the token input
myForm.token.value = data.response.token.token;
// IMPORTANT: Here we call `submit()` on the form element directly instead of using jQuery to prevent and infinite token request loop.
myForm.submit();
};
// Called when token creation fails.
var errorCallback = function(data) {
// Retry the token request if ajax call fails
console.log("error::"+data.errorMsg);
if (data.errorCode === 200) {
// This error code indicates that the ajax call failed. We recommend that you retry the token request.
} else {
alert(data.errorMsg);
}
};
var tokenRequest = function() {
// Setup token request arguments
var args = {
sellerId: "<?php echo accountnumber_checkout; ?>",
publishableKey: "<?php echo publickey_checkout; ?>",
ccNo: $("#creditcardno").val(), //input field
cvv: $("#billingcvv").val(), //input field
expMonth: $("#expiryMonth").val(), //input field
expYear: $("#expiryYear").val() //input field
};
// Make the token request
TCO.requestToken(successCallback, errorCallback, args);
};
$(function() {
// Pull in the public encryption key for our environment
TCO.loadPubKey('sandbox');
$("#frmSignup").submit(function(e) {
// Call our token request function
tokenRequest();
// Prevent form from submitting
return false;
});
});
</script>
</form>
//成功创建令牌时调用。
var successCallback=函数(数据){
console.log(“成功::”+数据);
var myForm=document.getElementById('frmSignup');
//将令牌设置为令牌输入的值
myForm.token.value=data.response.token.token;
//重要提示:这里我们直接在表单元素上调用'submit()',而不是使用jQuery来防止和无限令牌请求循环。
myForm.submit();
};
//当令牌创建失败时调用。
var errorCallback=函数(数据){
//如果ajax调用失败,请重试令牌请求
log(“错误::”+data.errorMsg);
如果(data.errorCode==200){
//此错误代码表示ajax调用失败。建议您重试令牌请求。
}否则{
警报(data.errorMsg);
}
};
var tokenRequest=函数(){
//设置令牌请求参数
变量args={
sellerId:“,
可发布密钥:“”,
ccNo:$(“#creditcardno”).val(),//输入字段
cvv:$(“#billingcvv”).val(),//输入字段
expMonth:$(“#expiryMonth”).val(),//输入字段
expYear:$(“#expiryYear”).val()//输入字段
};
//发出令牌请求
requestToken(successCallback、errorCallback、args);
};
$(函数(){
//为我们的环境拉入公共加密密钥
TCO.loadPubKey(“沙箱”);
$(“#frmSignup”).submit(函数(e){
//调用我们的令牌请求函数
令牌请求();
//阻止表单提交
返回false;
});
});
面对这个错误:(在2co.min.js2:1628中)
未捕获引用错误:未定义tokenRequestUrl
如果我在TCO.loadPubKey('production')中使用'production'而不是'sandbox',则生成令牌。但是,在生产模式下,我无法使用测试卡:
检查?也许你没有使用沙盒帐户?他们已经删除了沙盒模式-检查?也许你没有使用沙盒帐户?他们已经删除了沙盒模式-