【问题标题】:how can i check whether a Stripe customer already has a specific card before adding a new one in django python在 django python 中添加新卡之前,我如何检查 Stripe 客户是否已经拥有特定卡
【发布时间】:2019-11-10 06:49:57
【问题描述】:

我想为客户在条带上存储多张卡。在这种情况下,客户尝试在条带上添加新卡,检查这张卡是否存储在 django python 中

我使用下面的代码在条带上添加客户卡

 card = stripe.Customer.create_source(
                    'customer_stripe_id'
                    source =request.POST['stripeToken']
                )

【问题讨论】:

    标签: python django stripe-payments


    【解决方案1】:

    一旦您使用客户创建源 api 存储卡详细信息(卡 ID、指纹等)

    stripe.Customer.create_source(
                        'customer_stripe_id'
                        source =request.POST['stripeToken']
                    )
    

    您可以通过卡片列表 api 列出卡片,然后检查您将在响应中获得的卡片指纹来检查客户是否存在同一张卡片:

    cards = stripe.Customer.list_sources(
      'cus_FMsdyCbtYeOCJr',
      object='card'
    )
    

    为此,您需要存储客户 ID 和其他所需的卡详细信息。

    所有卡片的指纹都是独一无二的

    供您参考:Stripe Documentation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-02
      • 1970-01-01
      • 2015-05-08
      • 1970-01-01
      • 2010-12-21
      • 1970-01-01
      • 2014-08-30
      • 1970-01-01
      相关资源
      最近更新 更多