-
Notifications
You must be signed in to change notification settings - Fork 100
added store module #22
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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): | ||
| 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) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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'), | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| } | ||
| 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) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use direct keyword arguments instead of dict-expansion. (As in line 17) |
||
There was a problem hiding this comment.
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)