From ed66fcf6f94e2cf5a363ce9b2ceef7094ef857a9 Mon Sep 17 00:00:00 2001 From: Andrew Grinevich Date: Mon, 16 Nov 2015 14:09:20 +0300 Subject: [PATCH 1/2] added store module --- steamapi/store.py | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 steamapi/store.py diff --git a/steamapi/store.py b/steamapi/store.py new file mode 100644 index 0000000..d0a626b --- /dev/null +++ b/steamapi/store.py @@ -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) + + 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'), + } + 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) + + def refund_txh(self, orderid): + params = { + 'appid': self.appid, + 'orderid': orderid + } + return APIConnection().call(self.interface, 'RefundTxn', 'v1', method='POST', **params) + + def finalize_txh(self, orderid): + params = { + 'appid': self.appid, + 'orderid': orderid + } + return APIConnection().call(self.interface, 'FinalizeTxn', 'v1', method='POST', **params) From 0d8fa91629c6ae534cc4449d44cbc9d0c794893d Mon Sep 17 00:00:00 2001 From: Andrew Grinevich Date: Mon, 16 Nov 2015 15:40:06 +0300 Subject: [PATCH 2/2] fix notes said in pool-request --- steamapi/store.py | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/steamapi/store.py b/steamapi/store.py index d0a626b..06e4078 100644 --- a/steamapi/store.py +++ b/steamapi/store.py @@ -4,50 +4,34 @@ from .core import APIConnection -class SteamStore(object): +class SteamIngameStore(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) + return APIConnection().call(self.interface, 'GetUserInfo', 'v1', steamid=steamid, appid=self.appid) - def init_purchase(self, steamid, itemid, amount, **kwargs): + def init_purchase(self, steamid, itemid, amount, itemcount=1, language='en', currency='USD', qty=1, description='Some description'): 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'), + 'itemcount': itemcount, + 'language': language, + 'currency': currency, + 'qty[0]': qty, + 'description[0]': description, } 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) + def query_txh(self, orderid): + return APIConnection().call(self.interface, 'QueryTxn', 'v1', appid=self.appid, orderid=orderid) def refund_txh(self, orderid): - params = { - 'appid': self.appid, - 'orderid': orderid - } - return APIConnection().call(self.interface, 'RefundTxn', 'v1', method='POST', **params) + return APIConnection().call(self.interface, 'RefundTxn', 'v1', method='POST', appid=self.appid, orderid=orderid) def finalize_txh(self, orderid): - params = { - 'appid': self.appid, - 'orderid': orderid - } - return APIConnection().call(self.interface, 'FinalizeTxn', 'v1', method='POST', **params) + return APIConnection().call(self.interface, 'FinalizeTxn', 'v1', method='POST', appid=self.appid, orderid=orderid)