Disclaimer: This article contains AI translations and should only be used as reference. Contact Cobo’s support team through help@cobo.com if you have any questions.
Sample project
Cobo provides a sample project that demonstrates the basic integration process of the SDK. This sample project contains a minimal implementation of parameter passing and authentication, and you can add your own business logic based on this sample code.Product features
Checkout SDK interface display (mobile example):
- Full terminal adaptation: Native support for mobile, desktop, and tablet devices, with built-in bilingual switching between Chinese and English.
- Multi-chain and multi-token support: Covers mainstream stablecoins such as USDT and USDC, and supports mainstream blockchains such as Ethereum, Arbitrum, Base, Solana, BSC, and Polygon.
- One-click payment: Supports QR code payment and one-click address copying, with real-time exchange rate display.
- Complete transaction monitoring: Provides complete on-chain data tracking such as transaction hash, address information, and block confirmation count.
- Smart error handling: Covers exception situations such as payment failure, order expiration, and insufficient amount, and provides clear solutions.
- Security isolation: Embedded in your page through iFrame with an independent domain name to ensure the security and stability of the payment environment.
- Bidirectional communication: Based on the postMessage mechanism, real-time and reliable bidirectional data transmission is achieved between iFrame and parent page.
- Continuous maintenance: iFrame is maintained and updated by the Cobo team, and you do not need to pay attention to underlying API changes. Only when API parameters undergo major changes (such as adding or deleting parameters) do you need to adjust the integration code accordingly.
Prerequisites
Before integrating the SDK, please complete all the steps mentioned in Preparation. During the preparation process, please ensure that you have:- Obtained the API key and API secret
- Completed merchant registration and obtained the merchant ID
- Configured a webhook endpoint to receive payment status notifications
Integration steps
Get Access Token
You need to complete SDK OAuth authentication through Access Token. The authentication process is as follows:- Your application server calls Get Access Token to obtain Access Token and Refresh Token.
- The application frontend obtains the Access Token from the backend and passes it into the iFrame to complete authentication.
- The Access Token is valid for 1 hour. Before the Access Token expires, the server needs to call Refresh Access Token and pass in the Refresh Token obtained in the above steps to obtain a new Access Token and Refresh Token. If the Token expires, the iFrame will send a
TOKEN_EXPIRED
event to the parent page.
Integrate iFrame
The following steps are explained using the sample project as an example. You can refer to this sample project and integrate it according to your own business logic.- Create an iframe container. When the page loads, the browser will obtain and display the payment interface from the specified URL.
You need to allow the iFrame to access the clipboard through
allow="clipboard-write"
to support the one-click copy function for receiving addresses.
- Initialize the iFrame in
src/views/CheckoutDemo.vue
and pass in order information such as merchant ID, amount, and currency. For specific field explanations, refer to the Create Pay-in Order API documentation.
- Implement the bidirectional communication process between your page and the iFrame in
src/services/checkoutIframeService.ts
. You need to listen to events from the iFrame on your page and handle them according to the event type.
- After the iFrame completes initialization, it will send a
LOADED
event to your page.
LOADED
event, it needs to call the backend service to obtain the Access Token, then send a GET_TOKEN
event to the iFrame, and pass the Access Token as data into the iFrame. At this point, the iFrame initialization process is complete.
Feel free to share your feedback to improve our documentation!