import stripe import time # set up Stripe API key stripe.api_key = "sk_live_5MagleOb5fGSB5PB329tGggO00atK5bXZk" # define function to check credit card def check_cc(cc): try: # create a token using the credit card details token = stripe.Token.create( card={ "number": cc["number"], "exp_month": cc["exp_month"], "exp_year": cc["exp_year"], "cvc": cc["cvc"], }, ) # create a charge using the token charge = stripe.Charge.create( amount=1000, # charge $10.00 (USD) currency="usd", source=token["id"], description="Test Charge", ) # return success response return {"status": "success", "response": charge} except stripe.error.RateLimitError as e: # if rate limit error, retry request after 1 second time.sleep(1) return check_cc(cc) except stripe.error.CardError as e: # return card error response return {"status": "card_error", "response": e} except stripe.error.InvalidRequestError as e: # return invalid request error response return {"status": "invalid_request_error", "response": e} except stripe.error.AuthenticationError as e: # return authentication error response return {"status": "authentication_error", "response": e} except stripe.error.APIConnectionError as e: # return API connection error response return {"status": "api_connection_error", "response": e} except stripe.error.StripeError as e: # return generic Stripe error response return {"status": "stripe_error", "response": e} # read credit card details from file with open("cc.txt", "r") as f: cc_list = f.readlines() # remove whitespace characters like \n at the end of each line cc_list = [x.strip() for x in cc_list] # loop through credit cards and check each one for cc_str in cc_list: # split the credit card details into components cc = cc_str.split("|") cc_dict = { "number": cc[0], "exp_month": cc[1], "exp_year": cc[2], "cvc": cc[3], } # check the credit card and print the response result = check_cc(cc_dict) print(f"Card {cc_dict['number']} - Status: {result['status']}, Response: {result['response']}")