My thoughts on Cryptocurrency Commerce Payments Platforms
Pay globally with region restrictionless using privacy ledger infrastructure. Asset transfer anytime anywhere and the fund ownership without a third party are the two key factors that attract people who are in the digital payment space. As a developer works on cryptocurrency space a few years, it's time to document my thinking regarding payment stuff. All opinions are my own, Just for sharing.
0x00 What is cryptocurrency payment
A purely peer-to-peer version of electronic cash would allow online payments to be sent directly from one party to another without going through a financial institution.
Quote from Bitcoin Write Paper illustrates the usage scenario and the advantage of Bitcoin network from the original vision of Satoshi Nakamoto. So far, many thousands of digital tokens are issued in the crypto market for different claims of value. From a payment experience perspective, Bitcoin Lightnight network and other blockchains are outperforming then Bitcoin native network, such as Ethereum, and Solana network, which have fast Txn confirmation speed and domination of the Defi ecosystem. For a payment platform, it would be a tradeoff between security and efficient settlement, and this balance would be the standard metric when building.
Moreover, as BTC price goes up and down in the bull/bear market and more listed companies hold BTC, TSLA held almost $2 billion worth of Bitcoin (BTCUSD) on its balance sheet at the end of 2021. A store of value(aka digital gold) financial characteristic makes cash function less sense, especially in the micro-payment scenarios(the reward for an article or automatic charge for a digital service subscription) when using onchain crypto payment platform, stable coins(USDC/USDT) issued in Ethereum/Solona are preferred tokens, since a high transaction fee, slow settlement in the Bitcoin layer one network and token price aggressive volatility.
With the above-mentioned domain knowledge, the platform we build would fit the market demand, resolve the borderless payment in the real world and improve the value transferring efficiency via permissionless blockchain privacy-protected ledger.
0x01 Functions provided in Crypto Business Payment platform
In this part, I will go through features, which are most cryptocurrency PAY product delivery by the industry firms. Here are some Crypto PAY platforms I found for a while: , Crypto.com PAY, Bitpay Business and even Stripe, which is a traditional web2 payment gateway solution provider, digging into crypto related service(Build your crypto business with Stripe) as well.
Basic concept: Roles, Currencies/Decimal place, Quotation and Hedging
In a cryptocurrency payment gateway, there are three roles getting involved, Merchants, Customers, and Payment service processors. For merchant side, by integrating gateway's API and pay button SDK, customers can choose different payment methods when checkout, e.g. WechatPAY/Credit Card. A crypto payment processor would offer off-chain/on-chain methods for customers. Off-chain payments are made via cryptocurrency custodial wallets, transactions don't happen on the blockchain network, and this pay channel(custodial wallet) is implemented by platform itself, like https://crypto.com/app in Crypto.com PAY ecosystem. The most important pay channel is onchain pay, in which transactions are made by non-custodia wallet(NCW) or defi swap, and there are many brilliant crypto wallets so far, imToken, trust-wallet, etc... which do help cryptocurrency pay adoption also.
There are several currency-related terms in the payment gateway platforms. It's necessary to clarify these terms before going next.
- Pricing Currency: Would be a kind of fiat currency or cryptocurrency. e.g. 100USD /per hoodie or 1ETH/per cryptopunk NFT Card
- Paid Currency: Customer paid currency, should be cryptocurrency.
- Credit Currency: The currency is settled to the merchant by the platform when received customer funds. which is determined by merchants' payment settings on the platform. It reflects on the merchant's specific wallet balance changes.
- Debit Currency: Determined by the merchant when requesting a refund. If the merchant doesn't select a specific wallet to deduct, the refund's payment's credit currency would be chosen by default.
- Refund/Rebound Currency: Customer received cryptocurrency for refund/rebound.
- Payout Currency: Crypto or fiat currency. There would be many-to-one relation between payout account and merchants' per wallet. e.g. Merchant's USD balance, If the platform fits the legal requirement, it would allow merchant binding USD bank account to the platform, which can transfer fiat. Also merchant can create TUSD/USDT payout account. Different kinds of payout account creation eligibility depends on Merchants' KYC information.
Given that there are different currencies in payment platforms, we should align the amount decimal place and amount fractional when ceiling and rounding or diplaying. Also, it's necessary to have the ability to adjust cryptocurrency decimal places in the administrator operation panel, which is dynamic to fit the aggressive volatility crypto market. Cryptocurrency luna hit zero($0.0001 roughly) from $100 above as UST falls further from dollar peg on May 12th, 2022. In this scenario, the platforms should have the ability to adjust the minimum amount flexibly when don't pause the Luna coin service. This function is crucial for all digital asset services.
There are three scenarios getting involved quotation and hedging
- Merchant prices product item with crypto or fiat, the customer pay with crypto via offchain/onchain.
- When platforms recived customers' fund, then credit to merchants' wallets base on payment settings
- Merchant requests to refund, then credit crypto to customers' wallet, fianlly deduct balance from merchant's debit wallet.
On payment creation phase. Batch quotations are created before generating payment QR code, which are used for determining how many tokens(crypto amount) customer should be paid, would be expired within a time window(10 minutes commonly).
On payment settlement phase, Once platform received customer's fund, pricing currency and credit currency(determine by merchant's payment setting) are key factors in merchant balance credit stage.
When the pricing currency is the same as credit currency, the specific quotation generated in payment creation stage and used for customer payment would be treated as a credit quotation and do hedging perform directly. Otherwise, create a new credit quotation bases on credit currency, received crypto currency, and a received amount with sell direction(sell received crypto in the market to buy back credit token for the merchant), then perform hedging.
Notes: For most commerce companies, since the cryptocurrency market's aggressive volatility, I propose that platforms can provide a settings option for merchants to price products with non-stable coins that should be credited to the merchant's corresponding wallet only; while customers request refunds, should debit from the merchant's wallet, which is the same as pricing cryptocurrency as well.
Offchain payments' refund would be refunded to custodial wallet directly between server sides API call. Onchain payment would be claimed via custodial or onchain wallets, while merchant requests to refund on Merchant Dashboard, balance is deducted from the selected merchant's wallet, and a claim email with a claim link is sent to the customers' inbox. Given payment platforms make sure customers would get back the same amount worth of pricing currency when refunded, so when pricing with fiat currency, they would be refunded with the equivalent worth of fiat amount but the number of cryptos would be different with they paid, it depends on quotation at requesting refunds; while pricing with crypto, customers would be received the same crypto amount what they paid.
Also, Refund gets involved in quotation and hedging.
- Checking merchant's specific wallet's balance is sufficient or not when a merchant requests a refund via Dashboard or refund open API call. This phase creates a debit checking quotation(don't perform this quotation hedging future), which would be determined by debit amount/currency(deducting balance from which merchant's wallet)
2. Transferring crypto to customers' wallet phase - two kinds of quotations are created for conversion between pricing payment, refunding crypto and debit wallet, and the last quotation would be performed hedging.
Rebound
There are many kinds of mismatched inbound fund scenarios when making on-chain payments in a payment settlement platform. The most important one is high-risk wallet address audit, which is must to have when crypto payment platforms gonna fit legal compliance restrictions and the security inbound fund monitoring. I personally recommend integrating with chainalysis to audit incoming transactions and senders' wallet addresses. Once the on-chain fund is detected as high risk, the inbound fund for payment is paused and marked as high_risk then involved CS team to resolve manually. The rest of the mismatched cases would trigger rebound workflow automatically, which are wrong_currency, under_paid and over_paid. The payment and inbound funds association is many to one, but only one inbound fund would be settled finally, and the rest of the inbound funds excluding high_risk would be sent back to the customers.
Development Integration
This part gets involved SDK PAY button & Restful API & Webhook events and E-commerce platforms plugin(woocommerce, shopify etc.) integration.
Developer-friendly and simplified API & Webhook event notifications workflow design help for business merchants acquisition and onboarding, which is one of the most important factors contributing to a payment gateway's success. More merchants, more transaction volume. Highlight Crypto.com PAY, it's the most outsdanding one in crypto pay processing domain so far I think. I sincerely suggest someone who gonna design crypto pay product to go through the. Besides, here are Crypto.com PAY integration document and Bitpay Doc.
0x10 Building a modern payment platform
"your key, your crypto" is the core philosophy in blockchain space. Introducing blockchain smart contract to tranditional digital commerce industry would be game changing. Imagine different stakeholders' aggrements are documented transparently and auditablely to a permissionless public ledger and execute in world-wide computer machine. There is no middleman and contracts are running automatically bases on coding, it's efficient and reliable once commerce aggrements are made.
Wallet based authentication and authorization
NCW is the most important entry and fundamental tool for cryptoism. So it's critical to integrate these basic infrastructure protocol to decrease users' onboarding workflow when designing blockchain products. For instance: Metamask browser extension interacting sample, and wallet connect, which is the web3 standard to connect blockchain wallets to dapps, can be integrated as users' wallets sign-in and permission approval solution.
Peer-to-peer payment settlement without middleman
Binding merchant HD wallet into platform then distribute funding address for each payment via HD wallet deriving mechanism - BIP44 distribute wallet address, which outcome is customers pay to merchants' wallets directly. Due to merchants controlling their own wallets, the platform can integrate cross-chain bridge or token swap protocol for balance conversion between different crypto wallets, which are bound to the platform. And the one-click feature for merchants to collect funds to payout wallet from distributing each on-chain payment funding address. Merchants pay the on-chain transaction fee for payout wallets balance conversion and payment funds collection.
Smart contract
This is one of the most attractive and full of imagination parts to maximize the power of blockchain - DeFi service for Merchants and Customers. At the same time, Once the protocol is deployed into the ledger, means that the contract is set into stone and public to the outside world as well. Blockchain transparent privilege becomes a disadvantage if there is any potential security vulnerability in the smart contract, which would lead to the platform being hacked. Writing contracts code must be careful then testing again and again in testnet. Before going live to mainnet, it must be reviewed and audited by domain experts.
Recommending solanapay and opennode, which are presented more like morden crypto payment platfors.
In short, designing and applying real world problem-resolving protocol into crypto payment platform would stand out from competitors --- With a mindset to maximize blockchain DEFI feature.