问题描述
嗨,我尝试在基于Codeigniter的系统中使2checkout完整化。在沙盒环境中,不会生成令牌。没有令牌怎么能测试?我也尝试通过演示令牌和
demo=true;
这是我传递给twocheckout库的数组。我已经在构造函数中加载了商家代码和私钥。
$charge = Twocheckout_Charge::auth(array(
"sellerId" => $twocheckout->merchantcode,"merchantOrderId" => $merchantOrderID,"token" => 'MjFiYzIzYjAtYjE4YS00ZmI0LTg4YzYtNDIzMTBlMjc0MDlk',"currency" => $currency,"total" => $amount,"demo" => true,"billingAddr" => array(
"name" => $patientdetails->name,"addrLine1" => $patientdetails->address,"city" => $patientdetails->address,"state" => "Alaska","zipCode" => "99501","country" => "USA","email" => $patientdetails->email,"phoneNumber" => $patientdetails->phone
);
我使用了the library of 2checkout in php
我的js
<script type="text/javascript" src="https://www.2checkout.com/checkout/api/2co.min.js"></script>
<script>
// $(document).ready(function () {
// Called when token created successfully.
var successCallback = function (data) {
var myForm = document.getElementById('editPaymentForm');
// Set the token as the value for the token input
// alert(data.response.token.token);
$("#editPaymentForm").append("<input type='hidden' name='token' value='" + data.response.token.token + "' />");
// 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) {
if (data.errorCode === 200) {
tokenRequest();
} else {
alert(data.errorMsg);
}
};
var tokenRequest = function () {
<?PHP $twocheckout = $this->db->get_where('paymentGateway',array('name =' => '2Checkout'))->row(); ?>
// Setup token request arguments
var expire = $("#expire").val();
var expiresep = expire.split("/");
var dateformat = moment(expiresep[1],"YY");
var year = dateformat.format("YYYY");
var args = {
sellerId: "<?PHP echo $twocheckout->merchantcode; ?>",publishableKey: "<?PHP echo $twocheckout->publishablekey; ?>",ccNo: $("#card").val(),cvv: $("#cvv").val(),expMonth: expiresep[0],expYear: year
};
// Make the token request
TCO.requestToken(successCallback,errorCallback,args);
};
// });
功能twoCheckoutPay(e){ e.preventDefault();
// try {
// Pull in the public encryption key for our environment
TCO.loadPubKey('production');
// $("#editPaymentForm").submit(function (e) {
// Call our token request function
tokenRequest();
// Prevent form from submitting
return false;
// });
// } catch (e) {
// alert(e.toSource());
// }
}
// Pull in the public encryption key for our environment
//});
</script>
尽管我传递了文档中所说的所有参数,但它总是给我不好的要求。现在,根据他们的新api文档,我应该对测试情绪和生产进行哪些更改?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)