#pvpb0t_code

1 messages ¡ Page 1 of 1 (latest)

rancid barnBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1288962567883980871

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

worldly hemlock
#
@v1vendor.route("/create-stripe-account", methods=["POST"])
@Sessions.protect(look_for="vendor")
def create_stripe_account():
    user = Sessions.get_object("vendors", request.cookies.get("vendor"))
    if not user:
        return Reply(error="User not authenticated"), 401

    try:
        account = stripe.Account.create(
          controller={
            "fees": {
              "payer": "application"
            },
          },
        )

        # Save the Stripe account ID in the database
        Database.get_database("users").vendors.update_one(
            {'_id': user['_id']},
            {'$set': {'stripeAccountId': account.id}}
        )

        return Reply(account=account.id), 200
    except stripe.error.StripeError as e:
        return Reply(error=str(e)), 400
    
@v1vendor.route("/stripe-connect", methods=["POST"])
@Sessions.protect(look_for="vendor")
def initiate_stripe_connect():
    user = Sessions.get_object("vendors", request.cookies.get("vendor"))
    if not user:
        return Reply(error="Vendor not found or Stripe account not created"), 404

    try:
        account_link = stripe.AccountLink.create(
            account=user['stripeAccountId'],
            refresh_url=url_for('vendor.stripe_connect_refresh', _external=True),
            return_url=url_for('vendor.stripe_connect_return', _external=True),
            type="account_onboarding",
        )
        return Reply(url=account_link.url), 200
    except stripe.error.StripeError as e:
        return Reply(error=str(e)), 400

@v1vendor.route("/stripe-connect/refresh", methods=["GET"])
@Sessions.protect(look_for="vendor")
def stripe_connect_refresh():
    # Handle the case when the user needs to be redirected back to the Stripe onboarding process
    return redirect(url_for('vendor.initiate_stripe_connect'))


#
@v1vendor.route("/stripe-connect/return", methods=["GET"])
@Sessions.protect(look_for="vendor")
def stripe_connect_return():
    user = Sessions.get_object("vendors", request.cookies.get("vendor"))
    if not user:
        return Reply(error="User not authenticated"), 401

    try:
        account = stripe.Account.retrieve(user['stripeAccountId'])
        if account.details_submitted:
            Database.get_database("users").vendors.update_one(
                {'_id': user['_id']},
                {'$set': {'stripeConnected': True}}
            )
            return Reply(message="Stripe account connected successfully"), 200
        else:
            # If the account is not fully set up, create a new account link
            account_link = stripe.AccountLink.create(
                account=user['stripeAccountId'],
                refresh_url=url_for('vendor.stripe_connect_refresh', _external=True),
                return_url=url_for('vendor.stripe_connect_return', _external=True),
                type="account_onboarding",
            )
            return Reply(url=account_link.url), 200
    except stripe.error.StripeError as e:
        return Reply(error=str(e)), 400

@v1vendor.route("/stripe-status", methods=["GET"])
@Sessions.protect(look_for="vendor")
def check_stripe_status():
    user = Sessions.get_object("vendors", request.cookies.get("vendor"))
    if not user:
        return Reply(error="User not authenticated"), 401
    
    vendor = Database.get_database("users").vendors.find_one({'_id': user['_id']})

    return Reply(
        connected=vendor['stripeConnected'],
        accountId=vendor['stripeAccountId']
    ), 200
#

where they clearly create an account with the "payer": "application"

rancid barnBOT
night basin
worldly hemlock
#

i saw on the site a mention of a testing verification code "000-000" however this does not work