Instructions for integrating T-Chain Payment SDK into Flutter project

Tram Ho

1. Introducing T-Chain Payment

Although cryptocurrency has been in the bear market for quite some time, the potential of blockchain is undisputed. Cryptocurrency is more and more accepted by organizations and regions ( reference ). Regarding electronic payments, many parties have used stable coins for payment. In this article, I guide the integration of T-Chain Payment SDK , a package of Tokoin, to help integrate payments with cryptocurrency quickly.

2. Goals

Currently, there are many projects that integrate E-Wallet payments, and may also want to integrate crypto payments. So, I created a shopping app in advance with basic features: view, select products, add products to cart and pay with momo. Because it’s a demo app, I don’t register app information with the payment method provider, but also use the information in the example of that package. The T-Chain Payment SDK will then be integrated, to see if the integration is quick and easy.

CollectionDetailsCart

 

To test on the testnet, you must download the My T-Wallet app. You can go to Tokoin homepage to get download link, or here ios , android .

After you have installed the app, you need to transfer the app to the sandbox environment so that it can be tested on the testnet. To change the environment, you click repeatedly on the Tokoin logo until a message appears, then restart the application, you will see as shown below.

3. Steps to integrate T-Chain Payment

To get started, I need to register information on the dev page . Fill out the form and wait for them to send relevant information. And if you just want to try like me, get the apiKey information in the package’s example for quick

Configure the scheme according to the instructions so that My T-Wallet can callback separately for each platform

Android: Need to edit AndroidManifest.xml file as follows

iOS: Need to edit Info.plist file as follows

 

That’s it, the configuration for iOS and Android is complete. To integrate the SDK you need to pay attention to the env environment variable, chain. To pre-test on app published on store, you must use env as prod , and isTestnet as false to test on testnet.

After selecting the product, go to the payment step, use the deposit(…) function to make the payment. Just like other payment methods, I need to call the API to create an order on the merchant server to be able to manage and control it later. In the example, I only use the id generated from Datetime.

After calling the deposit, and making the payment on the app wallet, and the merchant app will receive a callback with the payment result, and then the result is also sent to the webhook that we registered at first. The result received from the callback, is only the result on the testnet / mainnet network. To make sure the payment is recorded on the merchant’s server side, we should wait for the signal from the merchant’s server.

deposit

If you need to refer to the project’s code, I will put it in this repository .

4. Conclusion

I find the integration does not take too long. You can try and give Tokoin team feedback to improve the product. This T-Chain Payment SDK package has also just been posted, so there will definitely be more updates coming soon.

Hope you find the package useful, as well as being able to integrate cryptocurrency payments into your existing project.

Share the news now

Source : Viblo