Skip to content

Commit

Permalink
API - Check if user has enough credit/wallet balance to subscribe
Browse files Browse the repository at this point in the history
Will return error_details object if failed.
  • Loading branch information
UltimaHoarder committed Jun 19, 2021
1 parent c22783c commit d0372b0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions apis/onlyfans/classes/create_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(
self.isPerformer = user.isPerformer
self.chatMessagesCount = user.chatMessagesCount
self.subscribesCount = user.subscribesCount
self.creditBalance = user.creditBalance
self.lists = {}
self.links = content_types()
self.subscriptions: list[create_user] = []
Expand Down
7 changes: 5 additions & 2 deletions apis/onlyfans/classes/create_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,11 @@ async def buy_subscription(self):
"token": "",
"unavailablePaymentGates": [],
}
link = endpoint_links().pay
result = await self.session_manager.json_request(link, method="POST", payload=x)
if self.subscriber.creditBalance >= subscription_price:
link = endpoint_links().pay
result = await self.session_manager.json_request(link, method="POST", payload=x)
else:
result = error_details({"code":2011,"message":"Insufficient Credit Balance"})
return result

def set_scraped(self, name, scraped):
Expand Down
2 changes: 1 addition & 1 deletion apis/onlyfans/classes/extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def __init__(
# Lol?
class error_details:
def __init__(self, result) -> None:
error = result["error"]
error = result["error"] if "error" in result else result
self.code = error["code"]
self.message = error["message"]

Expand Down
3 changes: 3 additions & 0 deletions datascraper/main_datascraper.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from apis.onlyfans.classes.create_user import create_user
from apis.onlyfans.classes.extras import error_details
import os
import timeit
from typing import Optional
Expand Down Expand Up @@ -88,6 +90,7 @@ async def start_datascraper(
auth_count += 1
subscription_array += subscriptions
await main_helper.process_webhooks(api, "auth_webhook", "succeeded")
# Do stuff with authed user
subscription_list = module.format_options(
subscription_array, "usernames", api.auths
)
Expand Down

0 comments on commit d0372b0

Please sign in to comment.