Advertisement
Guest User

Cc check

a guest
Mar 29th, 2023
4,569
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 1 0
  1. import stripe
  2. import time
  3.  
  4. # set up Stripe API key
  5. stripe.api_key = "sk_live_5MagleOb5fGSB5PB329tGggO00atK5bXZk"
  6.  
  7. # define function to check credit card
  8. def check_cc(cc):
  9. try:
  10. # create a token using the credit card details
  11. token = stripe.Token.create(
  12. card={
  13. "number": cc["number"],
  14. "exp_month": cc["exp_month"],
  15. "exp_year": cc["exp_year"],
  16. "cvc": cc["cvc"],
  17. },
  18. )
  19. # create a charge using the token
  20. charge = stripe.Charge.create(
  21. amount=1000, # charge $10.00 (USD)
  22. currency="usd",
  23. source=token["id"],
  24. description="Test Charge",
  25. )
  26. # return success response
  27. return {"status": "success", "response": charge}
  28. except stripe.error.RateLimitError as e:
  29. # if rate limit error, retry request after 1 second
  30. time.sleep(1)
  31. return check_cc(cc)
  32. except stripe.error.CardError as e:
  33. # return card error response
  34. return {"status": "card_error", "response": e}
  35. except stripe.error.InvalidRequestError as e:
  36. # return invalid request error response
  37. return {"status": "invalid_request_error", "response": e}
  38. except stripe.error.AuthenticationError as e:
  39. # return authentication error response
  40. return {"status": "authentication_error", "response": e}
  41. except stripe.error.APIConnectionError as e:
  42. # return API connection error response
  43. return {"status": "api_connection_error", "response": e}
  44. except stripe.error.StripeError as e:
  45. # return generic Stripe error response
  46. return {"status": "stripe_error", "response": e}
  47.  
  48. # read credit card details from file
  49. with open("cc.txt", "r") as f:
  50. cc_list = f.readlines()
  51.  
  52. # remove whitespace characters like \n at the end of each line
  53. cc_list = [x.strip() for x in cc_list]
  54.  
  55. # loop through credit cards and check each one
  56. for cc_str in cc_list:
  57. # split the credit card details into components
  58. cc = cc_str.split("|")
  59. cc_dict = {
  60. "number": cc[0],
  61. "exp_month": cc[1],
  62. "exp_year": cc[2],
  63. "cvc": cc[3],
  64. }
  65. # check the credit card and print the response
  66. result = check_cc(cc_dict)
  67. print(f"Card {cc_dict['number']} - Status: {result['status']}, Response: {result['response']}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement