Build a decentralized payment gateway: Monetha’s Payment SDK for Golang
This article is technical: it assumes some programming and blockchain knowledge.
Read more about the SDK and find its source code on our Github repository.
Monetha’s payment gateway gives e-commerce merchants a way to conveniently and securely accept cryptocurrency payments. You can integrate it using a number of methods:
- The first and most straightforward is our plugins for WooCommerce, PrestaShop, and Magento platforms. They are
user friendlyand involve no programming skills.
- The second is the “Buy Now” button. It’s free from platform constraints and can be embedded almost anywhere to sell singular items or services.
- The third is our Payment Gateway PHP SDK. It’s a do-it-yourself version of our plugins and is best applied when the former
areunavailable. This method requires some knowledge of programming.
However, no matter which option you choose, each is married to our underlying on and off-chain infrastructure and carries the Monetha branding back, front, and center. Integration comes with things like user accounts, a feature-packed back office, portable reputation, and so on. But what if you only want the decentralized bits—and nothing more?
Well, that’s exactly what our Payment GO SDK is for. Read on, and I’ll run you through its inner workings and how you can employ the SDK for your benefit.
What is it?
How does it work?
The SDK initiates and communicates with our MerchantWallet and PaymentProcessor contracts. They are responsible for things like order creation, processing, cancellation, refunds, and money allocation to the right addresses.
The full list of methods available in the contracts is depicted below:
What is the payment flow?
In the context of e-commerce, order creation can be initiated both by the customer and the merchant—it’s up to you to decide which approach to use. The flow consists of five steps, which generally apply regardless of the chosen method:
- The order is created on-chain with the addOrder() method by either the merchant or the customer.
- The customer executes the securePay() method, which transfers the amount defined in the order to the smart contract.
- The merchant ensures that the goods are in stock or that he will be able to provide the service.
- The merchant executes the processPayment() method to process funds and awaits for funds at the MerchantWallet contract.
- The merchant sends out the goods to the customer.
You can find detailed diagrams depicting usage scenarios here.
We’ve prepared a usage example of our Payment Golang SDK. It provides an easy way to try out decentralized payments and the capabilities of our SDK on Ethereum’s
The Github repository has everything you need to make a payment, including dummy customer and merchant addresses. Feel free to play around with it!
That’s the end of our short overview of Monetha’s Payment GO SDK. We welcome any suggestions or improvements. If you have any questions, shoot us an email at [email protected].
Thank you for reading!
If you would like to learn more about the SDK or access its source code, have a look at our Github repository.
The SDK is part of Monetha’s Decentralized Reputation Framework. You can read about it here.