我正在努力发送信息从格子链接按钮使用这教程从条纹。
我向onSuccess函数添加了以下代码:
onSuccess: function(public_token, metadata) {
// Send the public_token and account ID to your app server.
var form = $('#payment-form');
form.append("<input type='hidden' name='plaid_public_token' value='" + public_token + "'/>");
form.append("<input type='hidden' name='plaid_account_id' value='" + metadata.account_id + "'/>");
form.get(0).submit();
}
我认为当用户使用Plaid链接成功地添加他们的银行时,会调用这个函数。本质上,这将在表单关闭时被调用。
但是,当用户打开Plaid链接时,该行为似乎会提交表单,并将空白数据发送给我的控制器。
当Plaid完成时,如何将此信息发送到服务器?目前,它说变量是空的,但是我认为这是因为在抛出这个错误之前,我甚至不能使用Plaid弹出。
Plaid::InvalidRequestError (
Error Type : INVALID_REQUEST
Error Code : INVALID_FIELD
Error Message : public_token must be a non-empty string
Display Message :
Request ID : A1AXs
):
发布于 2021-09-14 06:53:10
关于,“public_token必须是一个非空字符串”和从条带中提供的链接。
当您创建Plaid并给它一个配置时,您可能没有给它您的链接令牌,如示例所示。首先,创建一个包含所有所需道具的对象,即: onSuccess、onExits和令牌
根据您拥有的内容和所提供的内容,应该如下所示:
const configs = {
// where linkData.link_token is data returned from the call to the link api.
token: linkData.link_token || '',
onLoad: function() {
// The Link module finished loading.
},
onSuccess: function(public_token, metadata) {
// Send the public_token and account ID to your app server.
var form = $('#payment-form');
form.append("<input type='hidden' name='plaid_public_token' value='" + public_token + "'/>");
form.append("<input type='hidden' name='plaid_account_id' value='" + metadata.account_id + "'/>");
form.get(0).submit();
},
onExit: async function(err, metadata) {
// The user exited the Link flow.
if (err != null) {
// The user encountered a Plaid API error
// prior to exiting.
}
// metadata contains information about the institution
// that the user selected and the most recent
// API request IDs.
// Storing this information can be helpful for support.
},
};
var linkHandler = Plaid.create(configs);
https://stackoverflow.com/questions/46723846
复制