Coder Social home page Coder Social logo

bitcoin-payments's Introduction

Bitcoin Payments API (BPA)

Microservice to accept bitcoin payments

One Address per payment

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

Buying process

  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

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.

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_ammount": 0.3,
  "final_ammount:": 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

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

bitcoin-payments's People

Contributors

psypersky avatar

Watchers

 avatar

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.