Skip to content

Commit

Permalink
Merge pull request #22 from Derfirm/steamapi-store
Browse files Browse the repository at this point in the history
Merged in initial support for the Steamworks in-game micro-transactions store by @Derfirm.
  • Loading branch information
smiley committed Nov 16, 2015
2 parents 6b5a131 + 0d8fa91 commit 2530bb7
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions steamapi/store.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
__author__ = 'andrew'

import uuid
from .core import APIConnection


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):
return APIConnection().call(self.interface, 'GetUserInfo', 'v1', steamid=steamid, appid=self.appid)

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': 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):
return APIConnection().call(self.interface, 'QueryTxn', 'v1', appid=self.appid, orderid=orderid)

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

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

0 comments on commit 2530bb7

Please sign in to comment.