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.
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:
- 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.
What I'd like to do is:
- 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
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.
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.
EDIT:
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 ?