简体   繁体   English

如何在Flutter Dart上使用Dwolla API

[英]How to use dwolla api on Flutter dart

I want to be able to use the Dwolla api on my flutter project! 我希望能够在我的flutter项目中使用Dwolla api! It would have been easy since most of the work is done in the backend. 由于大多数工作都在后端完成,所以这很容易。

Now, there's a part of it that needs the ui, where javascript and html has to be implelmented. 现在,其中一部分需要使用ui,必须在其中实现javascript和html。

That's where my problem comes... How do I implement this part of the api in flutter: 这就是我的问题所在。如何在flutter中实现api的这一部分:

Then, you'll pass this single-use IAV token to the client-side of your application where it will be used in the JavaScript function dwolla.iav.start. 然后,将此一次性IAV令牌传递给应用程序的客户端,该令牌将在JavaScript函数dwolla.iav.start中使用。 This token will be used to authenticate the request asking Dwolla to render the IAV flow. 该令牌将用于验证请求Dwolla呈现IAV流的请求。 Before calling this function you'll want to include dwolla.js in the HEAD of your page. 在调用此函数之前,您需要在页面的HEAD中包含dwolla.js。

<head>
<script src="https://cdn.dwolla.com/1/dwolla.js"></script>
</head>
<head>
<script src="https://cdn.dwolla.com/1/dwolla.js"></script>
</head>

Next, you'll add in a container to the body of your page where you want to render the IAV flow. 接下来,您将在您要呈现IAV流的页面正文中添加一个容器。

<div id="mainContainer">
  <input type="button" id="start" value="Add Bank">
</div>

<div id="iavContainer"></div>
<div id="mainContainer">
  <input type="button" id="start" value="Add Bank">
</div>

<div id="iavContainer"></div>

Now that you have dwolla.js initialized on the page and the container created where you'll render the IAV flow, you'll create a JavaScript function that responds to the Customer clicking the “Add bank” button on your page. 现在,您已经在页面上初始化了dwolla.js并创建了用于渲染IAV流的容器,接下来,您将创建一个JavaScript函数,该函数响应客户单击页面上的“添加银行”按钮。 Once the Customer clicks “Add Bank”, your application will call dwolla.iav.start() passing in the following arguments: a string value of your single-use IAV token, options such as the iavContainer element where IAV will render, and a callback function that will handle any error or response. 客户单击“添加银行”后,您的应用程序将调用dwolla.iav.start(),并传递以下参数:一次性IAV令牌的字符串值,IAV将在其中渲染的iavContainer元素等选项以及回调函数,将处理任何错误或响应。

<script type="text/javascript">
$('#start').click(function() {
  var iavToken = '4adF858jPeQ9RnojMHdqSD2KwsvmhO7Ti7cI5woOiBGCpH5krY';
  dwolla.configure('sandbox');
  dwolla.iav.start(iavToken, {
          container: 'iavContainer',
          stylesheets: [
            'http://fonts.googleapis.com/css?family=Lato&subset=latin,latin-ext',
            'http://localhost:8080/iav/customStylesheet.css'
          ],
          microDeposits: 'true',
          fallbackToMicroDeposits: (fallbackToMicroDeposits.value === 'true')
        }, function(err, res) {
    console.log('Error: ' + JSON.stringify(err) + ' -- Response: ' + JSON.stringify(res));
  });
});
</script>
<script type="text/javascript">
$('#start').click(function() {
  var iavToken = '4adF858jPeQ9RnojMHdqSD2KwsvmhO7Ti7cI5woOiBGCpH5krY';
  dwolla.configure('sandbox');
  dwolla.iav.start(iavToken, {
          container: 'iavContainer',
          stylesheets: [
            'http://fonts.googleapis.com/css?family=Lato&subset=latin,latin-ext',
            'http://localhost:8080/iav/customStylesheet.css'
          ],
          microDeposits: 'true',
          fallbackToMicroDeposits: (fallbackToMicroDeposits.value === 'true')
        }, function(err, res) {
    console.log('Error: ' + JSON.stringify(err) + ' -- Response: ' + JSON.stringify(res));
  });
});
</script>

"The customer will complete the IAV flow by authenticating with their online banking credentials. You'll know their bank account was successfully added and verified if you receive a JSON response in your callback that includes a link to the newly created funding source." “客户将通过使用其在线银行凭证进行身份验证来完成IAV流程。如果您在回调中收到包含指向新创建的资金来源的链接的JSON响应,您将知道他们的银行帐户已成功添加和验证。”

Note: Dwolla has no sdk's for mobile. 注意:Dwolla没有用于移动的sdk。

So I guess my question is, how do you go about integrating such an API on flutter? 所以我想我的问题是,如何在Flutter上集成这样的API?

Dwolla's IAV should work for mobile apps inside of a WebView . Dwolla的IAV应该可用于WebView内的移动应用程序。 At the moment there is no way to do it entirely through a backend server via APIs. 目前,尚无法通过API通过后端服务器完全完成此操作。 According to this post , it looks like the Flutter team has created a plugin that allows you to incorporate WebViews into your Flutter app. 根据这篇文章 ,Flutter团队似乎已经创建了一个插件,该插件可让您将WebViews集成到Flutter应用中。 Unfortunately you will need to host a webpage that includes the Dwolla.js Javascript library in order to facilitate this flow. 不幸的是,您将需要托管一个包含Dwolla.js Javascript库的网页,以简化此流程。 We're continuing to look for ways to enhance this solution and provide additional resources for developers looking to do everything within their native mobile applications. 我们一直在寻找增强此解决方案的方法,并为希望在其本机移动应用程序中完成所有工作的开发人员提供更多资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM