GithubHelp home page GithubHelp logo

leon-volq / bitcoin-payments Goto Github PK

View Code? Open in Web Editor NEW

This project forked from psypersky/bitcoin-payments

0.0 0.0 0.0 65 KB

Create your own Bitcoin Payment Processor System

License: The Unlicense

Dockerfile 3.66% Go 10.33% JavaScript 86.01%

bitcoin-payments's Introduction

Bitcoin Payments API (BPA)

Microservice to accept bitcoin payments

One Address per payment

Buying process

Description

  1. Registered User enters Store.com
  2. User resquest to make a payment
  3. Store request a new "Charge" to the Bitcoin Payments API and asociates the Address with the user
  4. User makes the payment to the wallet
  5. The BPA waits for x confirmations then transfer 2% of original ammount + transfer free to BPACA and transfer the remaining ammount to SA
  6. Store calls the BPA for information about this address and receives that a new payment was done for X bitcoins
  7. Store creates a virtual credit for the user

Definitions

Charge: When a user request to make a payment a "Charge" is created, for this a bitcoin Address is created and monitored, charges are temporal and should only live for X ammount of minutes.

Store Address (SA): One address that its owned by the store

BPA Comissions Address (BPACA): One address owned by the BPA system

Details

When the Charge time expires the address is sent to an "expired" storage, along with its public and private keys, this address will stop being monitored and never be used again.

POSTMAN

https://www.getpostman.com/collections/f38dfedff96c54656b93

Proposed Endpoints

Creating a charge

Request

curl -X POST https://bpa.io/api/v1/charge

Response

{
  "address": "12AaMuRnzw6vW6s2KPRAGeX53meTf8JbZS",
  "expires": "2019-10-11T02:34:27.769Z"
}
Getting a charge

Request

curl https://bpa.io/api/v1/charge/12AaMuRnzw6vW6s2KPRAGeX53meTf8JbZS

Response

{
  "address": "12AaMuRnzw6vW6s2KPRAGeX53meTf8JbZS",
  "expires": "2019-10-11T02:34:27.769Z",
  "payment_status": "completed",
  "original_amount": 0.3,
  "final_amount:": 0.2892636
}

Payment statuses:

new: Charge has been created

pending: A transaction has been received and waiting for confirmation or payment has been sent to SA address and waiting for confirmations.

completed: Payment has been sent to Store Address and has X confirmations

Payment process

Payments are a way to the system to pay accounts

Payments Definitions

Store: The Store using the BPA by API

Payment process definition

  1. The store request to make a payment to one or several addressess with an amount for each one of them, payment is valid for 60 minutes
  2. The BPA Returns an ammount of bitcoin necessary to make the payments including fees for transactions and 2% extra for BPA commission and an expiration date for the payment
  3. The store sends the ammount and the id of the payment to BPA
  4. The BPA sends all the transactions and the 2% to the designated comissions address

Create a payment

Request

curl -X POST https://bpa.io/api/v1/payment \
-d \
{
  "addresses": [
    {
      "address": "12AaMuRnzw6vW6s2KPRAGeX53meTf8JbZS",
      "amount": 0.2
    },
    {
      "address": "12AaMuRnzw6vW6s2KPRAGeX53meTf8JbZS",
      "amount": 0.3
    },
  ]
}

Response

ammount calculation is sum of addresses amount + 2% (sum of ADM) + transaction fees (n addresses + 1)

{
  "payment_id": "on3lnj34l2n42l3n4l2",
  "ammount": 0.54,
  "expires": "2019-10-11T02:34:27.769Z"
}

Implementation

The system will be implemented using the OpenBazaar gPRC API to connect to the bitcoin network

OpenBazaar have its own lite sql database created by default where all the keychain is stored, this will be replaced by our own sql datatabase without editing the core functionality of the SPV wallet, just change the storage to an external database.

All the new funtionality will be created as an API level, we don't want to fork SPV wallet to avoid unecesary maintance, in the same SQL database all the expiration dates could be saved.

Inspired by

https://github.com/OpenBazaar/spvwallet

https://commerce.coinbase.com/docs/

https://www.blockchain.com/api/blockchain_wallet_api

https://bitpay.com/docs/create-invoice

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.