gpt4 book ai didi

grails - E_WC_14 : Accept. js 加密失败?

转载 作者:行者123 更新时间:2023-12-01 01:46:02 24 4
gpt4 key购买 nike

我有一个付款表格如下

<body>
<g:if test="${flash.message}">
<div class="message">${flash.message}</div>
</g:if>
<div class="content">
<h1>Secure Checkout</h1>

<g:form name="paymentForm"
method="POST"
action="processAcceptPayment" >
<input type="text" name="cardNumber" id="cardNumber" placeholder="cardNumber"/> <br><br>
<input type="text" name="expMonth" id="expMonth" placeholder="expMonth"/> <br><br>
<input type="text" name="expYear" id="expYear" placeholder="expYear"/> <br><br>
<input type="text" name="cardCode" id="cardCode" placeholder="cardCode"/> <br><br>
<input type="hidden" name="dataValue" id="dataValue" />
<input type="hidden" name="dataDescriptor" id="dataDescriptor" />
<button type="button" onclick="sendPaymentDataToAnet()">Pay</button>
</g:form>


</div>




<g:javascript>


function sendPaymentDataToAnet() {
var authData = {};
authData.clientKey = "valid key";
authData.apiLoginID = "valid id";

var cardData = {};
cardData.cardNumber = document.getElementById("cardNumber").value;
cardData.month = document.getElementById("expMonth").value;
cardData.year = document.getElementById("expYear").value;
cardData.cardCode = document.getElementById("cardCode").value;

var secureData = {};
secureData.authData = authData;
secureData.cardData = cardData;
// If using banking information instead of card information,
// send the bankData object instead of the cardData object.
//
// secureData.bankData = bankData;

Accept.dispatchData(secureData, responseHandler);

}

function responseHandler(response) {
if (response.messages.resultCode === "Error") {
var i = 0;
while (i < response.messages.message.length) {
console.log(
response.messages.message[i].code + ": " +
response.messages.message[i].text
);
i = i + 1;
}
} else {
paymentFormUpdate(response.opaqueData);
}
}

function paymentFormUpdate(opaqueData) {
document.getElementById("dataDescriptor").value = opaqueData.dataDescriptor;
document.getElementById("dataValue").value = opaqueData.dataValue;

document.getElementById("cardNumber").value = "";
document.getElementById("expMonth").value = "";
document.getElementById("expYear").value = "";
document.getElementById("cardCode").value = "";
document.getElementById("accountNumber").value = "";
document.getElementById("routingNumber").value = "";
document.getElementById("nameOnAccount").value = "";
document.getElementById("accountType").value = "";

document.getElementById("paymentForm").submit();
}


</g:javascript>
</body>

这将生成如下形式

enter image description here

我输入测试信用卡号并点击支付。

enter image description here

我在我的 javascript 控制台中收到以下错误。

enter image description here

我只是在关注官方页面上的 accept.js 教程。

https://developer.authorize.net/api/reference/features/acceptjs.html

我很感激有关此“加密失败”错误的原因的任何帮助?谢谢!

更新:

好的,所以我做了更多的调试。我放了一个测试代码"console.log("test");"在 responseHandler() 函数中,并注意到它被调用了两次。我现在想知道为什么 responseHandler() 被调用两次。

最佳答案

当 Accept.js 由于页面上发生其他一些 Javascript 错误而两次触发回调函数时,您可以通过将回调函数的内容包装在 try/catch 块中来快速追踪该错误的来源:

Accept.dispatchData(secureData, responseHandler);

...

function responseHandler(response) {
try {
if (response.messages.resultCode === "Error") {
var i = 0;
while (i < response.messages.message.length) {
console.log(
response.messages.message[i].code + ": " +
response.messages.message[i].text
);
i = i + 1;
}
}
} catch (error) {
console.log(error);
}
}

关于grails - E_WC_14 : Accept. js 加密失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49217727/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com