- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在 Ionic 框架内使用 Braintree dropin UI 遇到了一个非常奇怪的行为。
所以我使用解决方案:Can't create Braintree client token with customer ID首次创建逻辑和回头客。
$http({
method: 'POST',
url: 'http://localhost:3000/api/v1/token',
data: {
customerId: braintreeReturnCustomerId
}
})
当我在客户端 View 中传入 customerId 时。在我的 nodejs 服务器中,我有一个逻辑来检查 customerId 是否未定义。如果未定义,则为首次客户。如果customerId有值,就是回头客。像这样非常直接:
app.post('/api/v1/token', jsonParser, function (request, response) {
var customerId = request.body.customerId;
if (customerId == undefined) {
gateway.clientToken.generate({}, function (err, res) {
if (err) throw err;
response.json({
"client_token": res.clientToken
});
});
} else {
console.log ("using exsiting customer!");
gateway.clientToken.generate({
customerId: customerId
}, function (err, res) {
if (err) throw err;
response.json({
"client_token": res.clientToken
});
});
}
});
我的客户在 ionic View 中。所以当我第一次付款时,它知道它是第一次用户,然后为我生成 customerId 并将其存储在我的数据库中。都好。然后不刷新(因为 Ionic 应用程序在状态更改时不刷新),我进入不同的状态并返回支付状态,它不显示商店信用卡。甚至我的服务器都记录了 customerId,我确定服务器代码正在运行 gateway.clientToken.generate({customerId: customerId} ...
如果我像使用一样在 View 中强制刷新
$window.location.reload(true);
在第一次付款成功后,或者我只是在我的 chrome 浏览器中手动刷新页面(就像我在 Ionic Serve 中一样),付款 Dropin UI 页面将显示第一次付款时的商店信用卡。
我尝试禁用像“cache: false”这样的 View 缓存。但这没有帮助。我必须强制刷新才能使 Dropin UI 第二次工作。我认为是 dropin UI 中的 javascript 代码导致了这个问题,但我不知道如何解决...
最佳答案
完全披露:我在 Braintree 工作。如果您还有任何疑问,请随时联系support .
您发布的方法非常不安全,因为它容易受到 Insecure Direct Object Reference 的攻击( OWASP Top 10 ) 并且很容易导致恶意用户进行跨用户收费。您实际上已经允许任何用户使用您的服务器为任何客户生成客户端 token 。
相反,您应该只在服务器上生成 token ,以避免用户代理选择其他用户的 ID。然后根据用户的凭据登录提供客户 ID,并且不允许他们传入要在 clientToken 生成期间使用的参数。有many guides online on how to build authentication .但是一旦您在服务器上创建了用户,您就可以:
if (userSession == undefined) {
//or force login if you want them to sign up for your site before buying things
gateway.clientToken.generate({}, function (err, res) {
if (err) throw err;
response.json({
"client_token": res.clientToken
});
});
} else {
console.log ("using exsiting customer!");
gateway.clientToken.generate({
customerId: userSession.user.BraintreeId
}, function (err, res) {
if (err) throw err;
response.json({
"client_token": res.clientToken
});
});
}
无论您做什么,都不要在生产中按原样使用此代码。在您重建以修复此漏洞之前,我不建议调试前端,因为方法会大不相同。但是,如果您再次回到这个问题,看起来可能有 an open issue related this behavior .
关于angularjs - 除非强制刷新,否则 Braintree Dropin UI 不适用于 Ionic Framework,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32531662/
这个问题在这里已经有了答案: 10年前关闭。 Possible Duplicates: What is a framework? What does it do? Why do we need a f
我在按照 http://msdn.microsoft.com/en-us/data/jj591621.aspx 处的 Microsoft Data Developer 过程启用代码优先迁移时遇到了一些
我正在从 迁移项目 Entity Framework 4.3 在 .net 4 上运行到 Entity Framework 5 在 .net 4.5 上运行。在不做任何更改的情况下,当我尝试运行该项目
我正在使用 Entity Framework 6 并使用 EntityFramework Extended 来执行一些批量更新和批量删除。批量更新和批量删除工作正常,但我还需要知道更新/删除的实体(即
我在实体上添加了一个列,然后从模型中生成数据库或构建解决方案,然后收到一条消息,提示我刚添加的新列未映射。该数据库以前是从模型创建的,没有错误。 当我右键单击Entity并选择Table Mappin
每次我尝试运行我的代码时都会崩溃,因为我尝试启动函数以调用 SDK 的任何部分。 我在构建过程中包含了 FoundationSDK: 并且我在头文件中包含了对 SDK 的引用: 但是每次我运行这个,我
我以前能够毫无问题地提交我的申请。我的工作流程中唯一改变的部分是使用 Sourcetree。在对以下框架进行更新后,我在提交到 iOS App Store 时收到此警告。我还收到一封电子邮件,其中包含
假设我为 Asp.NET Web 应用程序安装了 .NET Framework 2.0、3.0、3.5。 我意识到 Framework 3.0 和 3.5 只是 Framework 2 的扩展,不太清
是否有 SaveChanges 事件在保存更改后但在更新更改跟踪器之前触发? 我正在使用 EF 6。 我需要在某个实体的状态发生变化时执行任务。 我已经覆盖了 SaveChanges 来设置它。我可以
我正在使用一个现有的数据库,并且我已经将其中一个表映射为一个实体(因为我需要映射一个外键)。 因此,在初始化此数据库时,我希望 EF 忽略此实体,因为它已经存在。 我该怎么做? 最佳答案 您应该使用
我有 3 个表需要与 Entity Framework 进行映射,但我不确定解决此问题的正确方法。这是我的 3 个实体: public class User { [Key] public
我首先使用 VS 2010 和 Entity Framework 代码(版本 6)。我有两个实体,每个实体都在自己的上下文中,我想在它们之间创建一对多关系。 上下文 1 具有以下实体: public
我知道 EF 在 CodePlex 上是开源的,但我没有看到当前发布的 5.0 版本的分支。我在哪里可以得到这个源代码? 最佳答案 没有。他们只开源了 post 5 版本。第一次签到可能足够接近,但再
我们目前有一个数据库很大的系统,存储过程既用于CUD又用于查询。数据集用于从 SP 查询中检索结果。 现在我们正在研究使用 Entity Framework 针对同一个数据库开发另一个项目。在查询数据
我有一个每 10 秒运行一次的 Windows 服务......每次运行时,它都会获取一些测试数据,对其进行修改并使用 EntityFramework 将其保存到数据库中。但是,在每一秒运行时,当我尝
我对在我们的场景中仅将 Entity Framework 与存储过程一起使用的合理性有疑问。 我们计划拥有一个 N 层架构,包括 UI、BusinessLayer (BLL)、DataAccessLa
当我使用 Entity Framework 时,我想在上下文中查询出一条记录并将其添加到具有相同架构的另一个上下文中,在查询出记录后,我将其从上下文中分离出来,但是相关实体都没有了,是吗?有什么办法解
我正在使用 Entity Framework 5 构建 ASP.Net MVC4 Web 应用程序。我必须使用现有的 sql server 数据库,但也想使用 Code First,所以我遵循了本教程
在 Entity Framework 4.0 中使用 T4 模板创建 POCO 会丢失什么?为什么使用 Entity Framework 4.0 时的默认行为不创建 POCO? 最佳答案 你会失去很多
我在网上使用 Repository Pattern 和 EF 看了很多例子。但他们都没有真正谈到与相关实体的合作。 就像说用户可以有多个地址。 IUserRepository User CreateU
我是一名优秀的程序员,十分优秀!