我正在寻找任何类型的帮助(通用或特定),为客户端库生成 Braintree Payments API 的 Vaadin 客户端 Java 实现。
我可以满足 Braintree protocol 的所有服务器端 Java 要求并且还在一段内联 JavaScript 代码之间进行 RPC,但无法使用 Braintree .js API。
客户端代码,全部总结在here中,建议使用我开放的“托管字段”以及他们的 Drop-In UI。真的,一切都会发生。
hostedFieldsInstance.tokenize(function (tokenizeErr, payload) {
if (tokenizeErr) {
// Handle error in Hosted Fields tokenization
return;
}
// Put `payload.nonce` into the `payment-method-nonce` input, and then
// submit the form. Alternatively, you could send the nonce to your server
// with AJAX.
document.querySelector('input[name="payment-method-nonce"]').value = payload.nonce;
也应该可以 directly tokenize the credit card information这是我继续前进的最关键的一步。这应该是一个不同的集成 Vaadin 的过程,也许有人更了解这种方式?
我该如何处理这样的事情?
最佳答案
最简单、最快的方法可能是使用 AbstractJavascriptComponent 或 AbstractJavasciptExtension。它们是可子类化的,并提供了一种将 JS 代码链接到可在服务器端操作的组件的简单方法。 AbstractJavascriptComponent 可能是两者中最好的,因为它们为您提供了一个 div 元素,您可以使用 js 完全控制该元素,而无需 vaadin 接触它。在我看来,这更容易,因为您可以避免 GWT 并使用其中的连接器类。
这里有一些可以帮助您入门的链接
https://vaadin.com/blog/-/blogs/vaadin-7-loves-javascript-components
https://vaadin.com/wiki/-/wiki/Main/Integrating%20a%20JavaScript%20library%20as%20an%20extension
关于javascript - Vaadin JavaScript API 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42495947/