Indie square has developed a Unity SDK backed by BTCPay server. It allows Unity game developers to create an IAP(In-App-Purchase) or an IGS(In-Game Shop) function with lightning network payment. No intermediary, Instant Payment, (almost) zero fee.

What is BTCPay server?

Long story short. It’s an open-sourced web service wrapping around a bitcoin daemon and lightning network daemon (and many more), and it provides the REST API and also several Web UIs for game developers as merchants, for example, an invoice management. So, you, the developer owns your own payment processor server, not depending on the 3rd party like Bitpay. There are just you, and the game players enjoying your games, as far as the payment is concerned. Much preferable for a self-sovereign developer like you, right?

Here is the architecture of this system. BTCpay server is a container of bitcoind and lnd, and it exposes the interface via REST API. Your game (say, a desktop game)is connected to BTCPay API via the SDK.

When a paywall appears as QR code in the game, the player can scan it by lightning-enabled wallet. Once the player approved it and payment is completed via Lightning network, it is notified to Game via SDK. The game grants a new item or something to the game player, and the s/he enjoys it.

Cons with BTCPay server:

You have to manage your server infrastructure.(So, you might need some linux commands for a troubleshooting or ask someone for help.) You have to pay the server cost. It’s open-sourced. All source codes are exposed.

Pros with BTCPay server:

You will not be rejected on-boarding by 3rd party payment processor You don’t get charged the processing fee by 3rd party payment processor You have the total control on the payment processing Invoice UI for multiple Stores/Games within one server It’s open-sourced. You can ask/add features and source codes are reviewed by many developers.

Deploy and Set up BTCPay

Now, do you want to play with BTCPay server? Great.

To deploy the BTCPay server to cloud, there are several options.

Please check the document links above and I recommend you to deploy & un-deploy & deploy several times to get familiar and comfortable with it.

If you want to go with Google cloud, here is 5 mins tutorial video to deploy BTCpay server.

https://youtu.be/LXwEuvHK9Aw

Create a temporary paring code

From here, I assume your BTCpay server is running on testnet and you have registered as an admin. (I encourage to run it in testnet mode instead of mainnet if it is your first time for BTCPay.)

By the way, Many merchants are using BTCpay already for their e-commerce sites in production. And, If you encounter any issues, you can reach the BTCPay slack. (Don’t forget the detail like screenshots and research it by yourself a bit before asking.) They are helpful and they have helped me a lot.

First in first, you have to login to BTCPay server as an admin and create temporary pairing code for SDK to connect to your BTCPay. This code will be invalidated once paired or it passed 24 hours.

Start to create an Access Token

There are 2 types of pairing, the server initiated pairing and the client initiated pairing. We use server initiated one. Select “pos” facade (not “merchant”)because you don’t want to game hacker access to your BTCpay server as a merchant which has more privileges.

server initiated token

You’ve got a server-initiated pairing code. Now Let’s go to Unity side. And you can generate as many paring codes as you want.