Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to prevent to customer to add same credit card

I am using stripe as my payment provider and storing encrypted credit card id in my db returned from stripe.

My question is that from GUI customer can add same card again. I see stripe do not prevent to add same card multiple time for same customer. Since stripe always generates different encrypted card id for same card so I can't use it to validate if same card is being added again.

How can stop customer to add same card again again.

like image 698
Vijay Kumar Rajput Avatar asked May 25 '15 08:05

Vijay Kumar Rajput


1 Answers

Looks like I got that . I can use fingerprint returned in json response. I saw stripe dashboard and found that fingerprint is always same for same card which I was adding again again.

Here is json request and response to confirm

Request

{
  "source": {
    "number": "378282246310005",
    "cvc": "123",
    "address_line2": "4th Floor",
    "address_line1": "140 2nd Street",
    "address_country": "USA",
    "name": "VIAY KUMAR",
    "address_state": "CA",
    "exp_month": 12,
    "exp_year": 2015,
    "address_zip": "94105",
    "address_city": "San Francisco",
    "object": "card"
  }
}

Response

 {
      "id": "card_166H9rC8Y8JrMFgBh9GVsmNG",
      "object": "card",
      "status": null,
      "exp_month": 12,
      "exp_year": 2015,
      "last4": "0005",
      "country": "US",
      "type": null,
      "name": "VIAY KUMAR",
      "customer": "cus_6IrxhfwXNyD1Uw",
      "recipient": null,
      "address_line1": "140 2nd Street",
      "address_line2": "4th Floor",
      "address_zip": "94105",
      "address_city": "San Francisco",
      "address_state": "CA",
      "address_country": "USA",
      "address_zip_check": "pass",
      "address_line1_check": "pass",
      "cvc_check": "pass",
      "fingerprint": "TwjSA2KqPDhSMUvQ",
      "brand": "American Express",
      "funding": "credit"
    }

added same card again and got different card id but same finger print :-)

Request

{
  "source": {
    "number": "378282246310005",
    "cvc": "123",
    "address_line2": "4th Floor",
    "address_line1": "140 2nd Street",
    "address_country": "USA",
    "name": "VIAY KUMAR",
    "address_state": "CA",
    "exp_month": 12,
    "exp_year": 2015,
    "address_zip": "94105",
    "address_city": "San Francisco",
    "object": "card"
  }
}

Response

{
  "id": "card_166HKVC8Y8JrMFgBfvbHPgk2",
  "object": "card",
  "status": null,
  "exp_month": 12,
  "exp_year": 2015,
  "last4": "0005",
  "country": "US",
  "type": null,
  "name": "VIAY KUMAR",
  "customer": "cus_6IrxhfwXNyD1Uw",
  "recipient": null,
  "address_line1": "140 2nd Street",
  "address_line2": "4th Floor",
  "address_zip": "94105",
  "address_city": "San Francisco",
  "address_state": "CA",
  "address_country": "USA",
  "address_zip_check": "pass",
  "address_line1_check": "pass",
  "cvc_check": "pass",
  "fingerprint": "TwjSA2KqPDhSMUvQ",
  "brand": "American Express",
  "funding": "credit"
}
like image 184
Vijay Kumar Rajput Avatar answered Sep 30 '22 01:09

Vijay Kumar Rajput