May 14, 2019 Knowledge Center

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:

  1. The first and most straightforward is our plugins for WooCommerce, PrestaShop, and Magento platforms. They are user friendly and involve no programming skills.
  2. 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.
  3. 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 are unavailable. 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?

Monetha’s Payment GO SDK contains a collection of methods for interacting with smart contracts necessary to make cryptocurrency payments on the Ethereum blockchain. These contracts can be deployed by Monetha; or you can deploy your own set of smart contracts, creating a payment gateway that is self-standing and independent of our infrastructure.

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:

uml.png

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:

  1. The order is created on-chain with the addOrder() method by either the merchant or the customer.
  2. The customer executes the securePay() method, which transfers the amount defined in the order to the smart contract.
  3. The merchant ensures that the goods are in stock or that he will be able to provide the service.
  4. The merchant executes the processPayment() method to process funds and awaits for funds at the MerchantWallet contract.
  5. The merchant sends out the goods to the customer.

You can find detailed diagrams depicting usage scenarios here.

Examples

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 Ropsten network.

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.

 

 

Share