Summary
Hello hello hello,
Today, we're going to talk about my latest little adventure: enabling a 142-year-old company to accept cryptocurrencies.
I've been working with Les Frères Marchand, for over a year now, at first we made a website together (it was Ludo Dev CMS's second instance), then we got the urge to create an online cheese shop together, which has been online since September 2021.
On this cheese shop, everything is automated to simplify life for customers and for Frères Marchand.When I say everything is automated, I mean that invoice creation is too... and given that today we're talking about new means of payment... it's important.
Being a big tech fan myself (well, you're on a site called developpeur-freelance.io, so you guessed it). I know the world of cryptocurrencies and I follow it assiduously.
While doing my due diligence I realized that it was possible for Les Frères Marchand to accept cryptocurrencies, so I asked them, "Do you want to accept crypto? ". And the answer was "yes", a company of 142, very open to the future....
A company is a little more complicated than managing these personal accounts. There are accounts to keep, tax documents to create (invoices), and I couldn't ask the Frères Marchand accounting department to keep one account per "type of crypto", given that we accept several.
Generally speaking, as Bitcoin is not a state currency, it's not possible for a company to invoice in Bitcoin; you have to invoice in euros.
It is possible for a company to hold cryptocurrency, but then it's called an "asset."
Everything must remain automated as it was before the addition of cryptocurrencies, in the report sent to the cellars, only orders for which payment is certain to be received are sent to preparation.With credit card payment, for example, the info is passed on to the cellars when what we call the "loan" on the card is validated, basically when the bank has authorized us to "block" the funds on the customer's credit card even if the transfer hasn't actually been made yet.
It was imperative that existing customers who pay by bank card, Google Pay and Apple Pay were not lost. Allow them to continue to use the online cheese shop seamlessly as they always have.
Finally, I didn't want to treat customers wishing to order with cryptocurrency as "second-class" customers, for me it was clear that their experience must be as seamless as those who pay by card, Apple Pay or Google Pay.
The great thing about the Frères Marchand online cheese shop is that it's built with "Ludo Dev E-Shop", itself built on "Symfony" and "Sylius Framework". Do you know what that means? It means I have total freedom to add the payment gateways I want, without depending on anyone else. And that's very important for the future.
First of all, I inevitably came across Coinbase Commerce, as Coinbase is the leader in the cryptocurrency world... They're also present in e-commerce, so I tested their solutions a little, but I didn't choose it, here's why:
Moue, no, not convinced by coinçasse commerce, at least not for this project.
Being part of the Elrond ecosystem myself (my hero: @ludodev), I was naturally interested in Elrond's latest acquisition, UTRUST.
So I started "playing customer" and testing the customer experience on the dev net.
On blockchain projects, there are often several networks:
I liked the experiment, it looks like "Stripe", but for crypto, it's not bad.
The tests were conclusive, so it was time for implementation.
I read the documentation, and it's pretty similar to what Stripe can do, with one difference.
Even though Stripe uses webhooks, they can be quite optional for a normal payment "flow", they're useful for repayment especially (and it's true in some cases to completely validate the imprint on a card).
On a cryptocurrency transaction, payment is completely asynchronous and this is perfectly normal. Some networks, like Elrond, are very quick to process a transaction, while others are more congested (Ethereum, by chance?).
As a result, when the customer exits the payment interface, there is in fact only one validation of the transaction on the network (the blockchain), at which point he is redirected to the "success" page, but the network has not completely validated the transaction.
Therefore, don't take this redirection as a success, but wait for the webhook with the event "ORDER.PAYMENT.RECEIVED" event arrives, but be sure to check that the accompanying state is set to "completed", as during a pre-check the event may trigger not "complete", but "received".
I'll leave it to you to read the UTRUST doc for this, the thing to know is that prices must be sent as a string and name as an int or float.
The email and first name must be present when the order is created, otherwise the UTRUST API will refuse to create the "order".
Finally, it is absolutely necessary to send three URLs,
It all depends on the SDK used, but for PHP, for example, the SDK allows you to check the array sent to UTRUST before sending the request.think about using it to avoid sending requests to the API for nothing?.
Once you've configured the webhook, you'll receive a POST request to the URL you've entered. Of course, the data is signed, so ! If you don't, anyone can say "The blockchain has confirmed that payment 651 has been validated".
And as I said earlier, the event you're most interested in is "ORDER.PAYMENT.RECEIVED" with the state "complete", at which point you can be sure that the entire network has validated the transaction (on Elrond, this takes 40 seconds).
Below you can see the video of the world premiere of the crypto cheese purchase.
For this project, thanks go to the following people/groups:
The idea of this article is not to rewrite the UTRUST doc, because it's well done, but to give you the little info you need to know if you ever want to integrate cryptocurrency payments into your e-commerce platform.
Have a great week!