Why am I getting 'Uncaught TypeError: window[i] is not a function' when submitting authorize.net's AcceptUI form?
Why am I getting 'Uncaught TypeError: window[i] is not a function' when submitting authorize.net's AcceptUI form?
我正在尝试在 Vue.js 组件中使用 authorize.net AcceptUI 托管表单。 https://developer.authorize.net/api/reference/features/acceptjs.html#Integrating_the_Hosted_Payment_Information_Form
启动表单的按钮和表单正确显示。输入一些测试付款信息并点击提交后,表单类型或重新加载但不会按预期消失。在控制台中,我收到错误 AcceptUI.js:1 Uncaught TypeError: window[i] is not a function。
AcceptUI 脚本的相关部分是这样的:
A = function(t) {
"function" == typeof i ? i.call(null, t) : window[i](t)
};
我定义了一个 responseHandler 函数。我不确定为什么它不起作用。我将代码精简为与 authorize.net 提供的示例几乎相同,但我假设 Vue.js 或 Typescript 存在干扰。
请忽略与代码无关的任何问题。我只关心让 responseHandler 正常工作,然后我将构建其余功能。
<template>
<div>
<form id="paymentForm" method="POST">
<button type="button"
class="AcceptUI"
data-billingAddressOptions='{"show":true, "required":false}'
data-apiLoginID="<redacted>"
data-clientKey="<redacted>"
data-acceptUIFormBtnTxt="Submit"
data-acceptUIFormHeaderTxt="Card Information"
data-responseHandler="responseHandler">Pay
</button>
</form>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import Component from 'vue-class-component';
@Component
export default class SubscriptionManager extends Vue {
protected responseHandler(response: any) {
console.log(response);
}
protected paymentFormUpdate(opaqueData: any) {
const dataDescriptor: any = document.getElementById("dataDescriptor");
dataDescriptor.value = opaqueData.dataDescriptor;
const dataValue: any = document.getElementById("dataValue")
dataValue.value = opaqueData.dataValue;
// If using your own form to collect the sensitive data from the customer,
// blank out the fields before submitting them to your server.
const cardNumber: any = document.getElementById("cardNumber");
cardNumber.value = "";
const expMonth: any = document.getElementById("expMonth")
expMonth.value = "";
const expYear: any = document.getElementById("expYear")
expYear.value = "";
const cardCode: any = document.getElementById("cardCode")
cardCode.value = "";
const paymentForm: any = document.getElementById("paymentForm")
paymentForm.submit();
}
}
</script>
我今天 运行 遇到了同样的问题。我的问题是在执行响应回调时找不到 data-responseHandler 中命名的函数。我已经定义了 data-responseHandler="authnetResponseHandler" 但在测试之前忘记定义 function authnetResponseHandler(response)。
https://developer.authorize.net/api/reference/features/acceptjs.html#Handling_the_Response
我正在尝试在 Vue.js 组件中使用 authorize.net AcceptUI 托管表单。 https://developer.authorize.net/api/reference/features/acceptjs.html#Integrating_the_Hosted_Payment_Information_Form
启动表单的按钮和表单正确显示。输入一些测试付款信息并点击提交后,表单类型或重新加载但不会按预期消失。在控制台中,我收到错误 AcceptUI.js:1 Uncaught TypeError: window[i] is not a function。
AcceptUI 脚本的相关部分是这样的:
A = function(t) {
"function" == typeof i ? i.call(null, t) : window[i](t)
};
我定义了一个 responseHandler 函数。我不确定为什么它不起作用。我将代码精简为与 authorize.net 提供的示例几乎相同,但我假设 Vue.js 或 Typescript 存在干扰。
请忽略与代码无关的任何问题。我只关心让 responseHandler 正常工作,然后我将构建其余功能。
<template>
<div>
<form id="paymentForm" method="POST">
<button type="button"
class="AcceptUI"
data-billingAddressOptions='{"show":true, "required":false}'
data-apiLoginID="<redacted>"
data-clientKey="<redacted>"
data-acceptUIFormBtnTxt="Submit"
data-acceptUIFormHeaderTxt="Card Information"
data-responseHandler="responseHandler">Pay
</button>
</form>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import Component from 'vue-class-component';
@Component
export default class SubscriptionManager extends Vue {
protected responseHandler(response: any) {
console.log(response);
}
protected paymentFormUpdate(opaqueData: any) {
const dataDescriptor: any = document.getElementById("dataDescriptor");
dataDescriptor.value = opaqueData.dataDescriptor;
const dataValue: any = document.getElementById("dataValue")
dataValue.value = opaqueData.dataValue;
// If using your own form to collect the sensitive data from the customer,
// blank out the fields before submitting them to your server.
const cardNumber: any = document.getElementById("cardNumber");
cardNumber.value = "";
const expMonth: any = document.getElementById("expMonth")
expMonth.value = "";
const expYear: any = document.getElementById("expYear")
expYear.value = "";
const cardCode: any = document.getElementById("cardCode")
cardCode.value = "";
const paymentForm: any = document.getElementById("paymentForm")
paymentForm.submit();
}
}
</script>
我今天 运行 遇到了同样的问题。我的问题是在执行响应回调时找不到 data-responseHandler 中命名的函数。我已经定义了 data-responseHandler="authnetResponseHandler" 但在测试之前忘记定义 function authnetResponseHandler(response)。
https://developer.authorize.net/api/reference/features/acceptjs.html#Handling_the_Response