greenworks icon indicating copy to clipboard operation
greenworks copied to clipboard

Documentation lacks information about microtransactions

Open Josh1billion opened this issue 5 years ago • 23 comments

Are microtransactions supported?

Searching through the issues, it appears that they are: another issue references a PR that added support for handling an event related to them.

But the docs do not appear to mention microtransactions. Unless the API is the same as it is for DLC, anyway, but that doesn't seem to be the case unless I'm misunderstanding.

Josh1billion avatar Nov 26 '19 19:11 Josh1billion

It seems like greenworks doesn't support ISteamMicroTxn interface of Steamworks SDK. @Josh1billion did you find any hack solution to integrate microtransactions?

FacePlace avatar Feb 05 '20 17:02 FacePlace

I don't have experience on using the steam microtransactions. @MadSpyxFR since you contributed the micro-txn-authorization-response event before, it would be nice if you could share your experience here.

hokein avatar Feb 09 '20 11:02 hokein

Madspy stopped working on this for about 2 years now. Would be nice if someone else could look into it.

TheRealDannyyy avatar Feb 13 '20 16:02 TheRealDannyyy

It seems like greenworks doesn't support ISteamMicroTxn interface of Steamworks SDK. @Josh1billion did you find any hack solution to integrate microtransactions?

Nope, didn't find anything. But I didn't end up looking into it very deeply either.

Josh1billion avatar Mar 11 '20 05:03 Josh1billion

Has anyone implemented microtransactions? I wanted to just put into my web flow (game opens a browser now with stripe integration and redirects back to game) but their documentation is horrendous...

Is it easier to do that or implement something in the overlay? Any experience (electron) is GREATLY appreciated!

framerate avatar Mar 24 '20 00:03 framerate

There is a way to implement microtransactions into a game using just greenworks micro-txn-authorization-response. The solution is to create an available for everyone item store (such as in game "Grim Clicker") and then open it in a game using the steam overlay.

Example

I have not integrated it yet, but I think that this solution is the best until greenworks doesn't support mtx natively.

FacePlace avatar Mar 24 '20 18:03 FacePlace

@FacePlace this is awesome news. Steams documentation leaves a little to be desired (versus implementing something like Stripe).

What does the flow look like here?

  • [ ] Implement greenworks into your game
  • [ ] Have a button in the game that opens the Steam overlay with the store items
  • [ ] Person buys on Steam Overlay
  • [ ] Steam sends micro-txn-authorization-response back which is handled by greenworks
  • [ ] Unlock items

Although in my case I think I'd need micro-txn-authorization-response to be handled on my server for security purposes...

framerate avatar Mar 24 '20 18:03 framerate

@framerate Yes, I think that the flow would be as you described. Of course, this is a hacky solution, but at this time we don't have much of a choice.

FacePlace avatar Mar 24 '20 18:03 FacePlace

Ok here's my steps to implement this weekend if anyone has feedback/input. My game uses a browser for other transactions so I'm starting there. I'll send the itemId and pricing to my server (running nodejs) in the first steps. I'll update with progress too for transparency for the next person trying this.

REQUIRED

  • [ ] Integrate Greenworks into dt-client: https://github.com/greenheartgames/greenworks
  • [ ] Attempt ISteamFriends::ActivateGameOverlayToWebPage to handle all this in game (supported by greenworks re #41 )
  • [ ] (INVESTIGATE) Steam in dt-server (https://www.npmjs.com/package/steamworks_sdk) for ease
  • [ ] Use ISteamUser::GetSteamID to get SteamID
  • [ ] Refactor /link/{linkType} to /user/{id}/link and create POST /user/{id}/link/{linkType} to take results
  • [ ] POST to (new endpoint) /user/{id}/link/{linkType} to save Steam ID on launch
  • [ ] On POST /checkout/steam do ISteamMicroTxn/InitTxn.
  • [ ] Redirect user to Steam via URL returned above
  • [ ] After transaction we come to (new endpoint) /checkout/steam/finished which uses ISteamMicroTxn/QueryTxn to see transaction status, if approved, call ISteamMicroTxn/FinalizeTxn and grant item
  • [ ] (FUTURE v1.1) - ISteamMicroTxn/GetUserInfo to get currency info for localized pricing for UI

framerate avatar Mar 27 '20 19:03 framerate

FYI after 3 days I'm blocked by not being able to get the overlay to work (electron). I'm going to try and solve the problem but if anyone has answers, I'd like to clean up the documentation around here as I go (made a bug: https://github.com/greenheartgames/greenworks/issues/262) that way the next person has clear updated info and can hit the ground running faster.

framerate avatar Mar 29 '20 22:03 framerate

Overlay works only with Windows as far as I can tell. You must launch your application from steam and you need to use this command-line option for your application:

--in-process-gpu

Also, make sure you are updating the screen every frame.

MikalDev avatar Mar 30 '20 03:03 MikalDev

@MikalDev thank you, we're getting further in the investigations.

One of our biggest pitfalls is needing 3x build machines to build 3x platforms since it checks platform. When using prebuilt binaries, there has to be a way to let a single machine build all 3 don't you think? Any info on that would be great if you've gone down that rabbit hole!

framerate avatar Mar 30 '20 21:03 framerate

@framerate I use Electron Builder to build for both Windows and MacOS on a single Mac machine and then created a custom Node script that uses the SteamCMD tools to upload those builds to Steam in one command. For Example: electron-webpack && electron-builder --dir --win --mac && node ./steam/steamPackage.js

EDIT: For this specific issue, my experience is that the "micro-txn-authorization-response" event works fine once you get the Steam Overlay working on Windows. You'll just need to set up something server side to start the transaction

Rosslington avatar May 04 '20 09:05 Rosslington

I started using this but as the overlay is a true pain with the last version of electron, I just switched to Xsolla which handles many other things.

With my team we are working on a way to have "a better overlay" inclusion as there are a lot of issues because of "chrome" behind the scene and there is nothing you can do about it. If our solution works, then we already have all the payment API system ready to go on our servers (only the client overlay was missing).

So if we manage to get something easy to setup and "generic" we will share our solution, but for now xsolla does the job.

Inateno avatar Jun 23 '20 21:06 Inateno

We've recently got the overlay working on windows, it seems, in electron 8.2.5. However I don't think it works on all platforms (macOS and Linux) and users can still turn it off! So we're currently investigating a all server-side transaction flow as our default with the "fall back" being the overlay...

I'm merging the branch today so at least we've made some real progress here...

framerate avatar Jun 23 '20 21:06 framerate

You can't do a "all server side" transaction in any cases, the User have to select what he want to purchase and send that info.

With the steam API this goes through the steam overlay (and if you find any way to do it without the overlay I'm very curious about that).

For Xsolla what we did is:

  • The client create a purchase, this send a request to our server that returns a secure Xsolla generated URL and open an iframe on the client.
  • The process in the iframe is not our, so user finish the payment process (or not).
  • Then our server receive the hook confirmation from xsolla.
  • Once the user close the iframe (with or without success) we go check on the server if we have unconsumed stuff.

If we could do that with the steam API that would have been cool...

Inateno avatar Jun 23 '20 21:06 Inateno

@Inateno

I'm referring to this: https://partner.steamgames.com/doc/features/microtransactions/implementation under "Web Based Purchasing"

Clicking a link in the game opens a Browser which redirects to SteamWallet purchase page. Successful transaction goes back to your API which finalizes the transaction and sends an event to your client that the purchase was successful, thus "skipping" the overlay

So yeah, I think you CAN do it with just the Steam API, according to that doc, but I'm still confirming it.

framerate avatar Jun 23 '20 21:06 framerate

Oh indeed I completely ignored the "Web-based purchasing" section when I did it first ! So yes this should work more or less the same way we did with Xsolla, good to know !

Inateno avatar Jun 24 '20 07:06 Inateno

FYI - I'm live with the web-based purchasing for the past 2 months. So far so good!

I'm not using greenworks on my server, and I'm not sure I even SHOULD/WOULD. All the NPM modules for communicating with the web API seemed to fail me so I started making my own.

If having a simple webAPI interface for communicating with the awful steam API would be beneficial to you, let me know, and I can probably open source it.

framerate avatar Sep 16 '20 18:09 framerate

I'd be interested in seeing this - thanks for offering to share it.

MikalDev avatar Sep 16 '20 23:09 MikalDev

Cool @MikalDev I'll see what I can do this week. I should be revisiting some of that code.

it's not that much code right now, but its like 20+ hours of work trying to figure out why Steam API was rejecting my requests (like they don't tell if you a POST is a body payload or a query param very clearly...)

But I figure I could abstract it to a core function, a tiny datalayer and wrapper functions for the calls I use (related to microtransactions) with some error checking... then maybe people can PR some more functions in 👍

framerate avatar Sep 16 '20 23:09 framerate

I recently got my prototype up and running too, the real challenge was figuring out that you don't need to configure/pre-add anything to Steam - and the post-transaction auth flow could be kinda challenging for everyone's own unique environment, as you need to add an url to handle the transaction success callback, and manually approve it, then inform the user about the success etc.

kaansoral avatar Sep 16 '20 23:09 kaansoral

Nice Kaan!

It's really great to see people using JavaScript and crazy ways like me.

Makes me feel a little less alone!

framerate avatar Sep 16 '20 23:09 framerate