条纹api检查现有卡 [英] stripe api checking for existing card
问题描述
我确定我在这里遗漏了一些明显的东西,但是我无法理解如何针对客户检查现有卡.
I'm sure I'm missing something obvious here, but I can't get my head around how to check for an existing card against a customer.
我正在使用laravel应用中的Stripe Connect API来代表他人管理付款,其基本过程如下:
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
- a stripe
token
is created viastripe.js
and submitted with the payment form - if the customer exists in the local database, I grab their
stripe_id
, otherwise a new customer is created using the token as the source/card - a
charge
is then created using the retrieved or new customerstripe_id
当前,如果客户退货并使用其他卡,由于费用仅包括客户而不是来源,因此无论如何,都将使用其默认卡进行收费.
Currently, if the customer returns and uses a different card, as the charge only includes a customer, not source, it'll be charged against their default card regardless.
我想做的是:
- 创建条纹
token
- 针对本地数据库等检查
customer
- 对照客户卡检查
card
指纹 - 如有必要,在客户记录上创建新的
card
- 同时使用
customer
和card
ID创建费用
- create a stripe
token
- check
customer
against local database etc - check
card
fingerprint against customer's cards - if necessary, create new
card
on customer's record - create charge using both
customer
andcard
ids
简单地说::我看不到在该过程中何处生成持久性card_id
; stripe.js
响应中使用的那些,以及在条纹仪表板中创建的那些,看起来都是唯一的,这意味着每次收费都会在条纹中创建一个全新的卡对象.
Simply put: I can't see where in the process a persistent card_id
is generated; both those used in the stripe.js
response, and when created in the stripe dashboard, appear to be unique, meaning every charge creates a brand-new card object in stripe.
我知道我可以检索针对客户帐户存储的卡的列表-但是我从哪里获得初始的card_id
来进行搜索?
I know I can retrieve a list of cards stored against a customer's account - but where do I get the initial card_id
from to search against?
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.
更简单的版本-如此处的条带文档所述,有没有办法获取fingerprint
- https://stripe.com/docs/api/php#card_object -无需先创建卡对象?
Simpler version - is there a way to get the fingerprint
as described in the stripe docs here - https://stripe.com/docs/api/php#card_object - without having to first create a card object ?
推荐答案
所以这里的想法是在
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.
获取新卡令牌后,您可以通过获取令牌 API来查找它,并查看card
哈希中的fingerprint
.
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.
您将在数据库中保留与特定客户和/或卡关联的已知指纹列表,以便您可以检测到重复的卡.
You would keep a list of known fingerprints in your database associated with a specific customer and/or card so that you can detect duplicate cards.
注意::请确保您使用秘密密钥来获取这些信息.否则,如果您使用的是可发布密钥,则可能无法获取指纹值.
NOTE: make sure you are using the secret keys to get those information. otherwise if you are using the publishable key, you might not get the fingerprint value.
这篇关于条纹api检查现有卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!