The Internet is full of articles about what a wonderful future the blockchain has in store for us, how “stylish, fashionable and innovative” it is. However, there is very little information on how to practically take advantage of all this splendor. Let's try to partially fill this gap.
Let's look at the main milestones of the long journey using the example of integrating bitcoin as a method of accepting payments.
Suppose you are a developer, and your advanced and wealthy customer, having read about how cool it is to accept payments in cryptocurrency, came to you with a simple request - “Give us Bitcoin!”
First, I’ll try to discourage you from engaging in this thankless task.
Here is an incomplete list of problems that you will encounter:
-constantly changing exchange rate
-time for a transaction to pass through the network
-complete lack of control over the amount sent by the buyer
-lack of a clear and transparent mechanism that will allow you to simply organize payment tracking
But let’s imagine, purely theoretically, that the customer is ready to put up with all these and more dozens of other problems, and we couldn’t get out of it.
Then, first, let’s look at how, in fact, we will accept payments. As always, there are at least two ways. The first is relatively simple, not much different from integration with, for example, PayPal or Privat24. Use a ready-made service, for example - bitpay. There are many such services, many of them, in addition to bitcoin, allow you to accept several different cryptocurrencies. Everything is prosaic and quite simple; documentation and examples are most often available on the service website in sufficient quantities.
But we are not looking for easy ways, right? In addition, the amount charged to a persistent customer needs to be worked off (or pretended to have been worked off).
Therefore, let’s consider the second path, full of difficulties, problems and non-obvious solutions.
The advantage of it is that having mastered it once, you will master not only several levels of nautical curses, but also have a much deeper understanding of how cryptocurrencies are organized and what they allow you to implement.
In the usual case, when integrating a payment gateway spherical in a vacuum, the sequence of actions (with minor details) looks something like this.
The user has selected the goods he is interested in, added them to the cart and pressed the coveted button "buy". Filled out all the necessary fields, such as delivery address, phone number, email address, and finally got to the payment. This is where a little magic begins..
The software of the seller's website generates a special form, most often called SCI (Shopping Cart interface). After clicking on the “Pay” button, this form will redirect the buyer to the website of the payment system (for example PayPal), with pre-specified payment information. Obviously this will be at a minimum - the order number, the amount to be paid and, probably, some kind of note about the payment, for example “Invoice for tennis balls No. 00012”.
The user logs in with their credentials and confirms that they really want to make a payment. If he has enough funds, all data is entered correctly and there are no problems with transferring money, payment is made directly. In case of successful payment, the payment gateway sends a notification to the merchant's server, which includes the amount, time of payment and the invoice number that was paid. Additionally, arbitrary data can be transmitted, but for our example this is not so important. At the same time, the buyer himself is redirected back to the seller’s website, where he receives a solemn congratulation on successful payment and an oath promise to send the goods right now.
What is important to us in this sequence?
Three key points.
First, the payment amount is set by the seller.
Secondly, the payment occurs with a fairly accurate identification of which order.
And third, the notification that the seller’s server receives is almost impossible to fake.
Such a system was not formed immediately, but in a more or less similar form it is implemented in most payment gateways and electronic payment systems, such as Skrill or PayPal.
Now let's see what awaits us when we are going to integrate bitcoin as a means of payment.
Firstly, in bitcoin (and in all cryptocurrencies built on its basis) there is no direct way to transmit a payment identifier.
Secondly, you have virtually no control over how much the user will send (with small reservations).
In general, starting from the moment the user proceeds to pay, the further process will look something like this.
You receive a new bitcoin address and transfer it to the user, along with the calculated amount to be paid.. It is considered good form to indicate how long the payment details are valid (we remember, the cryptocurrency exchange rate is very unstable), usually 15 minutes. Next, you regularly check the status of this address to see whether the required amount has been received or not. If the amount has been received, the payment can be considered completed, and we can proceed to processing further orders (shipping goods, replenishing a mobile account, and so on).
Given the peculiarities of the functioning of cryptocurrencies, some pitfalls potentially await us.
If a user sent a transaction to the network, this does not mean that you received it. Until the first confirmation, your server may not even know that such a transaction took place. And from the moment of payment to the moment the transaction is included in the block, several hours can pass. This situation gives rise to a lot of unpleasant consequences.
Firstly, if the exchange rate at the time of receiving the transaction is significantly lower, or, as an option, if the commission indicated when paying is too low, you may receive a notification about the transaction, but the funds themselves may arrive after a few days. But the buyer will be sure that he paid for the order and demand its fulfillment.
In subsequent articles I will tell you how to implement the above in practice and what is needed for this.
You May Also Like
Students from prestigious US universities are en masse enrolling in cryptocurrency courses
Despite the fact that the price of Bitcoin has been falling since the beginning of the year, the excitement around cryptocurrency in large educational institutions in America has not subsided. Several major universities have started or will soon begin teaching courses on Bitcoin and the revolutionary blockchain technology.
Depth of Depth as an analysis tool
In their analytical articles, financial experts quite often operate with the concept of “Exchange Book” or “Dom of Deals”. These reviews often use terms such as “market depth”, “wall” or jargon such as “offers”, “prints”, “icebergs”. Those who are familiar with this stock exchange slang and actively apply it in practice can move on to our next news article. This publication is addressed to those who have come across these concepts, but still have not found t...
