Uncaught TypeError: paymentForm.requestCardNonce is not a function 令牌未生成

问题描述

未捕获的类型错误:paymentForm.requestCardNonce 不是函数令牌未生成。请发送任何建议或任何链接。实际上我集成了 Square Payment API,但它没有加载或错误。如果您有任何参考,请发送给我和显示 const moviesRouteMatch = useRouteMatch("/movies"); const newsRouteMatch = useRouteMatch("/news"); const uploadRouteMatch = useRouteMatch("/uploads");

const PaymentForm = ({ paymentForm }) => {
  const [details,setDetails] = useState({
    cardBrand: '',nonce: undefined,googlePay: false,applePay: false,masterpass: false,});
  const requestCardNonce = () => {
    paymentForm.requestCardNonce();
  };
  useEffect(() => {
    const config = {
      applicationId: 'sandBox-sq0idb-5SScYBbnEFt3pv9JwVjeRw',locationId: 'LQTHZ296Y4X5N',inputClass: 'sq-input',autoBuild: false,inputStyles: [
        {
          fontSize: '16px',fontFamily: 'Helvetica Neue',padding: '16px',color: '#373F4A',backgroundColor: 'transparent',lineHeight: '1.15em',placeholderColor: '#000',_webkitFontSmoothing: 'antialiased',_mozOsxFontSmoothing: 'grayscale',},],applePay: {
        elementId: 'sq-apple-pay',masterpass: {
        elementId: 'sq-masterpass',googlePay: {
        elementId: 'sq-google-pay',cardNumber: {
        elementId: 'sq-card-number',placeholder: '• • • •  • • • •  • • • •  • • • •',cvv: {
        elementId: 'sq-cvv',placeholder: 'CVV',expirationDate: {
        elementId: 'sq-expiration-date',placeholder: 'MM/YY',postalCode: {
        elementId: 'sq-postal-code',placeholder: 'Zip',callbacks: {
        methodsSupported: (methods) => {
          if (methods.googlePay) {
            setDetails({
              ...details,googlePay: methods.googlePay,});
          }
          if (methods.applePay) {
            setDetails({
              ...details,applePay: methods.applePay,});
          }
          if (methods.masterpass) {
            setDetails({
              ...details,masterpass: methods.masterpass,});
          }
          return;
        },createPaymentRequest: () => {
          return {
            requestShippingAddress: false,requestBillingInfo: true,currencyCode: 'USD',countryCode: 'US',total: {
              label: 'MERCHANT NAME',amount: '100',pending: false,lineItems: [
              {
                label: 'Subtotal',};
        },cardNonceResponseReceived: (errors,nonce,cardData) => {
          if (errors) {
            // Log errors from nonce generation to the Javascript console
            console.log('Encountered errors:');
            errors.forEach(function (error) {
              console.log('  ' + error.message);
            });
            return;
          }
          setDetails({
            ...details,nonce: nonce,});
        },unsupportedbrowserDetected: () => {},inputEventReceived: (inputEvent) => {
          switch (inputEvent.eventType) {
            case 'focusClassAdded':
              break;
            case 'focusClassRemoved':
              break;
            case 'errorClassAdded':
              document.getElementById('error').innerHTML =
                'Please fix card information errors before continuing.';
              break;
            case 'errorClassRemoved':
              document.getElementById('error').style.display = 'none';
              break;
            case 'cardBrandChanged':
              if (inputEvent.cardBrand !== 'unkNown') {
                setDetails({
                  ...details,cardBrand: inputEvent.cardBrand,});
              } else {
                setDetails({
                  ...details,cardBrand: '',});
              }
              break;
            case 'postalCodeChanged':
              break;
            default:
              break;
          }
        },paymentFormloaded: function () {
          document.getElementById('name').style.display = 'inline-flex';
        },};
    paymentForm = new paymentForm(config);
    paymentForm.build();
  },[]);**

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)