API Wrapper for ScrathonPayments
Project description
Scrathon
Scrathon is a Python package designed to interact with the Scrathon platform to allow for purchases in your projects.
Installation
You can install Scrathon via pip: pip install scrathon-payments
Usage with Scratchattach
To use Scrathon, you need to instantiate the Scrathon
class with a valid username. This username will be used to authenticate and perform transactions on the Scrathon platform.
import scratchattach as scratch3
from ScrathonPayments import Scrathon #pip install scrathon-payments
session = scratch3.login("USERNAME_OF_ANY_ACCOUNT_(ACCOUNT_CAN_BE_NEW_SCRATCHER)", "PASSWORD")
conn = session.connect_cloud("YOUR_PROJECT_ID")
ScrathonPayments = Scrathon("USERNAME_OF_ACCOUNT_TO_RECEIVE_FUNDS")
client = scratch3.CloudRequests(conn)
@client.request
def purchase(username, Price):
Purchase = ScrathonPayments.purchase(Price, username)
result = "None"
if Purchase == "You have been banned from selling items in your projects!":
result = "Fail!"
#In scratch, tell the user the transaction failed
elif Purchase == "User does not have enough money to buy the item!":
result = "Not enough coins!"
#In scratch, tell the user they do not have enough coins to make the purchase
elif Purchase == "Transaction has been added to pending transactions, transaction will go through once the user has confirmed!":
#In scratch, tell your users to look at the comments of the Scrathon project and find their verification comment in the project's comments, reply to it with 'yes' and the transaction will go through!
result = "Success!"
return result
@client.request
def purchasecheck(username, Price): #Check if the player bought the item so you can give them the promised item (If you don't give the item to the player you will get banned from selling items)
PurchaseCheck = ScrathonPayments.purchasecheck(Price, username)
return PurchaseCheck
client.run()
Methods
purchase()
Initiates a purchase transaction.
Parameter | Type | Description |
---|---|---|
Price |
int |
Required. Price the buyer is paying |
User |
str |
Required. User paying for your item |
Returns:
Status of the transaction, e.g:
"Transaction has been added to pending transactions, transaction will go through once the user has confirmed!"
"User does not have enough money to buy the item!""
and "You have been banned from selling items in your projects!"
purchasecheck()
Checks the status of a purchase transaction.
Parameter | Type | Description |
---|---|---|
Price |
int |
Required. Price the buyer had paid |
User |
str |
Required. User who paid for your item |
Returns:
True: The transaction went through (give their item)
False: The transaction did not go through!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for scrathon_payments-0.1.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f5a8de82956648bcf4335fc13b6eabb3de801f3370835a23d81c5391e9935c8 |
|
MD5 | af94a4ba71c608bac8b75c970c43eb02 |
|
BLAKE2b-256 | 7929d1265ba8eb40241ab2b8d2c9797300a574ea5aa42803ad0e550fac713926 |