Microservice to accept bitcoin payments
- Registered User enters Store.com
- User resquest to make a payment
- Store request a new "Charge" to the Bitcoin Payments API and asociates the Address with the user
- User makes the payment to the wallet
- The BPA waits for x confirmations then transfer 2% of original ammount + transfer free to BPACA and transfer the remaining ammount to SA
- Store calls the BPA for information about this address and receives that a new payment was done for X bitcoins
- Store creates a virtual credit for the user
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
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.
https://www.getpostman.com/collections/f38dfedff96c54656b93
Request
curl -X POST https://bpa.io/api/v1/charge
Response
{
"address": "12AaMuRnzw6vW6s2KPRAGeX53meTf8JbZS",
"expires": "2019-10-11T02:34:27.769Z"
}
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
Payments are a way to the system to pay accounts
Store: The Store using the BPA by API
- 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
- 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
- The store sends the ammount and the id of the payment to BPA
- The BPA sends all the transactions and the 2% to the designated comissions address
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"
}
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.
https://github.com/OpenBazaar/spvwallet
https://commerce.coinbase.com/docs/