我确信我在这里遗漏了一些明显的东西,但是我想不通如何针对客户判断现有的卡.

I'm using the stripe connect api within an laravel app to manage payments on behalf of others, and the basic process is as follows:

  • 通过stripe.js创建条带token,并将其与付款表格一起提交
  • 如果客户存在于本地数据库中,我将获取他们的stripe_id,否则将使用令牌作为源/卡创建一个新客户
  • 然后使用检索到的或新的客户stripe_id创建charge

目前,如果客户返回并使用另一张卡,因为费用只包括客户,而不包括来源,那么不管怎样,都将从他们的默认卡中收取费用.

What I'd like to do is:

  • 创建条带token
  • check customer against local database etc
  • check card fingerprint against customer's cards
  • 如有必要,在客户记录中创建新的card
  • create charge using both customer and card ids

Simply put:我看不到进程中在哪里生成了持久card_idstripe.js响应中使用的持久化card_id和在条纹仪表板中创建的持久化card_id似乎都是唯一的,这意味着每笔费用都会在条纹中创建一个全新的卡对象.

我知道我可以根据客户的帐户检索存储的卡列表-但我从哪里获得要搜索的最初card_id张卡呢?

I've seen a question that touches on this here - Can I check whether stripe a card is already existed before going to create new one? - but I don't know Ruby, so can't make head nor tail of it.

EDIT:

更简单的版本——有没有一种方法可以在不需要先创建卡片对象的情况下,按照这里的stripe docs(https://stripe.com/docs/api/php#card_object)中的描述获得fingerprint

推荐答案

So the idea here would be to use the fingerprint on the Card object or the Token object and not the id itself as those would be different if you add the same card multiple times.

When you get a new card token you can retrieve it through the Retrieve Token API and look for the fingerprint in the card hash.

你会在数据库中保留一份与特定客户和/或卡相关的已知 fingerprint 列表,以便检测重复的卡.

NOTE:确保您使用的是密钥来获取这些信息.否则,如果您使用的是可发布密钥,则可能得不到 fingerprint 值.

Laravel相关问答推荐

提交表格后如何在Livewire 3中调度模式窗口?

在Laravel Livewire中,如果一个输入基于另一个唯一的字段是唯一的,如何判断验证?

我在 laravel 中插入多个复选框值.我怎样才能做到这一点?

使用正则表达式 laravel 忘记缓存

Laravel:使用 Input::old 时 textarea 不会重新填充

Laravel 5.2 中的正则表达式验证

Laravel timestamps() 不会创建 CURRENT_TIMESTAMP

Laravel Passport Route [login] 未定义

Homestead:文件夹映射到错误的文档根目录

Laravel - 更新时禁用更新时间

Laravel 全部返回 ID 变为 0

我如何从给定的日期时间 struct 创建Carbon 对象?

Laravel 4 - 如何将所有字段的所有验证错误消息作为 JSON struct 返回?

Laravel 项目旁边的 Wordpress 项目(在 public_html 文件夹中)

使用 Laravel 使用 2 个磁盘复制文件

如何在 laravel 用户删除中重置自动增量?

控制器中的laravel foreach循环

如何获取 Laravel 块的返回值?

将参数传递给 Laravel 中的中间件

Laravel 排序集合,然后按键