jasielmacedo / steam-microtransaction-api

An intermediate api to handle steam microtransactions using steam web services. Ready to use with Unity, Unreal, Godot and so on
https://jasielmacedo.github.io/steam-microtransaction-api/
MIT License
46 stars 24 forks source link

Does this code works with a Python (Pygame) game ? #9

Closed ThomasBonnelye closed 2 years ago

ThomasBonnelye commented 2 years ago

Hello,

We have seen in your repository an example of link with api in Unity. We want to use the same service but for a game created in Python in order to set up micro transactions.

(Documentation link : https://partner.steamgames.com/doc/features/microtransactions/implementation)

Could you show us an example of how this works?

Thank you in advance.

jasielmacedo commented 2 years ago

Hello @ThomasBonnelye.

Its totally possible to make this code works with python games.

the only difference is the way you call the http requests:

You have to make something like this:

import requests
import json

url = "https://(your-api-url)/InitPurchase"

payload = json.dumps({
    "appId": "480",
     "orderId": "1",
     "currency": 199, 
     "itemId": 11222,
     "itemDescription": "abcd",
     "category": "gold",
     "steamID": steamUserid
})

headers = {
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

initPurchase doc

But you have to make sure you are using steamworks SDK to listen the events in your game.