[Script] Stripe Invoicing Script 12-23-2023, 07:40 AM
#1
Self created python script to send invoice with Stripe API Key
Script will Auto Rotate Keys for every Email.
Script Structure
Python Main Code : Main.py
Setting File : Settings.Json
Contacts File : Cust.csv
Cust.csv file contains Headers
PYTHON CODE
Settings.Json filr
JSON
DM @ Cybercrow_leaks
Script will Auto Rotate Keys for every Email.
Script Structure
Python Main Code : Main.py
Setting File : Settings.Json
Contacts File : Cust.csv
Cust.csv file contains Headers
Code:
CSV FORMAT Fullname EmailPYTHON CODE
Code:
import time
import datetime as DT
import json
import stripe
import csv
#SECRET_KEY ="SK_Live_#####################"
#SECRET_KEY ="SK_Live_#####################"
AMOUNT = 22999
CSV_FILE = "cust.csv"
#stripe.api_key = SECRET_KEY
settings = {}
def create_invoice(customer):
 Â
  desc = "Dear " + customer["name"] + """
[font=Courier New]#########YOUR MESSAGE################[/font]
  """
  try:
    invoice = stripe.Invoice.create(
      customer = customer["id"],
      collection_method = "send_invoice",
      days_until_due = 7,
      description = desc
    )
   Â
    #print(invoice)
   Â
    item = stripe.InvoiceItem.create(
      customer = customer["id"],
      invoice = invoice["id"],
      amount = AMOUNT,
      currency = "USD",
      description = "Geek Squad Advanced Protection (12 Months Subscription)"
    )
   Â
    return invoice
  except Exception as e:
    print(e)
 Â
  return None
def send_invoice(invoice):
 Â
  try:
    sent = stripe.Invoice.send_invoice(
      invoice["id"]
    )
   Â
    return sent
 Â
  except stripe.error.RateLimitError as rE:
    time.sleep(1)
    return send_invoice(invoice)
  except Exception as e:
    print(e)
 Â
  return None
def read_customers():
  custs = []
  with open (CSV_FILE) as file:
     reader = csv.DictReader(file)
     for row in reader:
       cust = {
         "name": row["Fullname"],
         "email": row["Email"]
       }
       custs.append(cust)
 Â
  return custs
def load_settings():
  global settings
 Â
  print("Loading settings...")
  with open('settings.json', 'r') as file:
    obj = json.load(file)
   Â
    try:
      print("Amount: " + str(obj["amount"]))
      print("Number Of Mails Per Account: " + str(obj["number_of_mails_per_account"]))
      print("Delay Between Account Switch: " + str(obj["delay_between_account_switch"]))
      print("Delay Between Each Invoice: " + str(obj["delay_between_each_invoice"]))
     Â
      accounts = obj["accounts"]
     Â
      if(len(accounts) == 0):
        print("No accounts found...")
        return False
      else:
        print("Accounts found: " + str(len(accounts)))
     Â
      for account in accounts:
        print("Account Name: " + str(account["name"]) + ", SKey: " + str(account["skey"]))
     Â
      settings = obj
      return True
    except:
      #print("Unable to read settings file. Make sure it's correct and complete")
      return False
def start_process():
  global AMOUNT
 Â
  if load_settings():
    print("Settings loaded...")
  else:
    print("Error reading settings file. Exiting...")
    return
 Â
  print("")
 Â
  AMOUNT = settings["amount"]
 Â
  accounts = settings["accounts"]
 Â
  print("Reading Customers...")
 Â
  customers = read_customers()
 Â
  if len(customers) == 0:
    print("Unable to fetch customers")
    return
 Â
  print("Total Customers: " + str(len(customers)))
  print("")
 Â
  print("Sending invoices...")
 Â
  account = 0
  countAccount = 0
  use_account(accounts[account])
 Â
  count = 0
  for customer in customers:
    count = count + 1
    print("")
    print("Customer " + str(count) + ": " + customer["name"] + " - Starting...")
   Â
    customer = stripe.Customer.create(
      name = customer["name"],
      email = customer["email"]
    )
   Â
    print("Customer registered...")
   Â
    invoice = create_invoice(customer)
   Â
    if invoice != None:
      print("Invoice created. Sending...")
      invoiceSent = send_invoice(invoice)
     Â
      if invoiceSent != None:
        print("Customer " + str(count) + ": " + customer["name"] + " - Invoice sent...")
   Â
    if settings["delay_between_each_invoice"] > 0:
      time.sleep(settings["delay_between_each_invoice"])
   Â
    countAccount = countAccount + 1
    if countAccount >= settings["number_of_mails_per_account"]:
      if settings["delay_between_account_switch"] > 0:
        print("\nWaiting between account change...")
        time.sleep(settings["delay_between_account_switch"])
      account = account + 1
      if account >= len(accounts):
        account = 0
     Â
      use_account(accounts[account])
      countAccount = 0
 Â
  print("All invoices sent. Task completed.")
def use_account(account):
  print("")
  print("Using account: " + account["name"])
  stripe.api_key = account["skey"]
start_process()Settings.Json filr
JSON
Code:
{
  "amount": 22999,
  "number_of_mails_per_account": 50,
  "delay_between_account_switch": 10,
  "delay_between_each_invoice": 0,
  "accounts" : [
    {
      "name": "stripe1",
      "skey": "SK_LIVE ###########################################"
    },
    {
      "name": "stripe2",
      "skey": "SK_LIVE ###########################################"
    }
  ]
}DM @ Cybercrow_leaks
(This post was last modified: 12-23-2023, 07:46 AM by anonymousgyps.)


![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)