Skip to content

monetha/payment-example-go

Repository files navigation

Intro

This repository contains example of using Monetha Payment Go SDK. Examples show main capabilities of SDK in order to achieve a decentralized payment via Monetha Payment Gateway

Build & Run

Prerequisites

  1. Make sure you have Git installed.
  2. Install Go 1.12
  3. Setup $GOPATH environment variable as described here.
  4. Clone the repository:
    mkdir -p $GOPATH/src/github.com/monetha
    cd $GOPATH/src/github.com/monetha
    git clone [email protected]:monetha/payment-example.git
    cd payment-example

Note: You can skip steps 2-3 on Linux and use the official docker image for Go after step 4 to build the project:

docker run -it --rm \
  -v "$PWD":/go/src/github.com/monetha/payment-example \
  -w /go/src/github.com/monetha/payment-example \
  golang:1.12 \
  /bin/bash

Build

Install dependencies:

make dependencies

After dependencies are installed you can start the examples

Running examples

All examples are run with Test Customer and Merchant addresses. We've provided private keys to those address for simplicity of onboarding and showing how SDK works. We call everyone who are executing examples not to withdraw Ether funds from those addresses.

Name Ropsten Address
PaymentProcessor Contract Address 0x35D6708FD36DCb902adce5D9d6ABeB4838318554
Merchant Address 0x8c77F5BA864718f098F83114efEC7180649afB85
Customer Address 0xdF8c3E2c8506F67705acB0a4dCa28Cf44934B511

We are using Infura.io JSON RPC in the provided examples in order to execute transaction on a chain. Feel free to change backendURL variable to any JSON RPC node you want.

backendURL := "https://ropsten.infura.io/v3/7c0fc2888a824c62a3651fd446c8f989"

Note: Currently all PaymentProcessor contract instances are provided by Monetha. Contact [email protected] in case if you would like to have your own instance deployed.

Example flow where Customer initiates the purchase

go run order_initiated_by_customer/main.go

Step by step instructions on what is being achieved in the example

  • Customer initiates the order
  • Customer pays for the Order
  • Merchant verifies if Order was paid
  • Merchant processes the payment after service was provided
  • Merchant withdraws funds from MerchantWallet to his Address

Example flow where Merchant initiates the purchase

go run order_initiated_by_merchant/main.go

Step by step instructions on what is being achieved in the example

  • Merchant initiates the order and provides Customer with information to pay
  • Customer pays for the Order
  • Merchant verifies if Order was paid
  • Merchant processes the payment after service was provided
  • Merchant withdraws funds from MerchantWallet to his Address

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published