![](/img/trans.png)
[英]Why am I getting “Uncaught TypeError: download is not a function”
[英]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 function。 我不确定为什么它不起作用。 我将代码精简为与 authorize.net 提供的示例几乎相同,但我假设 Vue.js 或 Typescript 会干扰。
请忽略与代码无关的任何问题。 我只关心让 responseHandler 工作,然后我将构建功能的 rest。
<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 中命名的 function。 我已经定义了data-responseHandler="authnetResponseHandler"但在测试之前忘记定义function authnetResponseHandler(response) 。
https://developer.authorize.net/api/reference/features/acceptjs.html#Handling_the_Response
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.