Skip to content
This repository was archived by the owner on Aug 23, 2025. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions steamapi/store.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
__author__ = 'andrew'

import uuid
from .core import APIConnection


class SteamStore(object):

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is used for the in-game item stores, rename this to something more specific, like SteamIngameStore. (I plan to add an API for the main store someday)

def __init__(self, appid, debug=False):
self.appid = appid
self.interface = 'ISteamMicroTxnSandbox' if debug else 'ISteamMicroTxn'

def get_user_microtxh_info(self, steamid):
params = {
'steamid': steamid,
'appid': self.appid
}
return APIConnection().call(self.interface, 'GetUserInfo', 'v1', **params)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer directly specifying keyword parameters if they're simple enough, like here. (Where you don't use any defaults)


def init_purchase(self, steamid, itemid, amount, **kwargs):
params = {
'steamid': steamid,
'itemid[0]': itemid,
'amount[0]': amount,
'appid': self.appid,
'orderid': uuid.uuid1().int >> 64,
'itemcount': kwargs.get('itemcount', 1),
'language': kwargs.get('language', 'en'),
'currency': kwargs.get('currency', 'USD'),
'qty[0]': kwargs.get('qty', 1),
'description[0]': kwargs.get('description', 'Some description'),

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use function defaults instead of this implementation. (This helps users who try out steamapi with a console, or use an IDE like PyCharm)

}
return APIConnection().call(self.interface, 'InitTxn', 'v3', method='POST', **params)

def query_txh(self, orderid, transid=None):
params = {
'appid': self.appid,
'orderid': orderid,
}
return APIConnection().call(self.interface, 'QueryTxn', 'v1', **params)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use direct keyword arguments instead of dict-expansion. (As in line 17)


def refund_txh(self, orderid):
params = {
'appid': self.appid,
'orderid': orderid
}
return APIConnection().call(self.interface, 'RefundTxn', 'v1', method='POST', **params)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use direct keyword arguments instead of dict-expansion. (As in line 17)


def finalize_txh(self, orderid):
params = {
'appid': self.appid,
'orderid': orderid
}
return APIConnection().call(self.interface, 'FinalizeTxn', 'v1', method='POST', **params)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use direct keyword arguments instead of dict-expansion. (As in line 17)