Квадратная форма оплаты не работает с реагировать родной - PullRequest
0 голосов
/ 12 декабря 2018

Мы пытаемся использовать Квадратную Платежную Форму в собственном приложении реагирования и можем отображать форму с помощью веб-просмотра, но мы вообще не можем взаимодействовать с формой.

Вот компонент squareFormс WebView:

import React, { Component } from 'react'
import { View, WebView, StyleSheet } from 'react-native'

const squareForm = require('./square/squareForm.html');

const SquareForm = () => {
   return (
      <View style = {{flex: 1}}>
         <WebView
             source = {squareForm}
         />
      </View>
   )
}

export default SquareForm;

Здесь вызывается:

import React, { Component } from 'react';
import {StyleSheet, View, Text} from 'react-native';
import { Container, Content, Form, Item, Label, Input, Button } from 'native-base';

import SquareForm from '../components/SquareForm'


export default class CardAdd extends Component {
  render() {
    return (
        <Container>
            <SquareForm />
        </Container>
    )}
};

Файлы html, css и javascript были получены непосредственно из репозитория Square: https://github.com/square/connect-api-examples/tree/master/templates/web-ui/payment-form/basic и находятся внутри квадратной папки.

Мы также пытались связать файл js с помощью свойства webview: injectedJavaScript следующим образом:

import React, { Component } from 'react'
import { View, StyleSheet, WebView } from 'react-native'

const squareForm = require('./square/squareForm.html')
const injectedJs = require('./square/squareForm.js')

const SquareCard = () => {
   return (
      <View style = {{flex: 1}}>
         <WebView
            javaScriptEnabled={true}
            domStorageEnabled={true}
            startInLoadingState={true}
            javaScriptEnabledAndroid={true}
            mixedContentMode={'compatibility'}
            injectedJavaScript={injectedJs}
            javaScriptEnabledAndroid={true}
            source = {squareForm}
         />
      </View>
   )
}

export default SquareCard;

Но это привело к следующей ошибке: sqPaymentForm is not defined и форма не отображается, потому что мы не можем подключить это: https://js.squareup.com/v2/paymentform

...