This guide introduces how to get started with using the Cobo Payments JavaScript SDK, which allows you to integrate the Cobo payments service into your existing application using the JavaScript programming language.
To learn more about the initial setup steps necessary for utilizing the Payments API, see Send your first request.
You can go to GitHub to access the source code of the SDK.
Prerequisites
- Install Node.js and NPM.
- Follow the instructions in Preparation for development environment to set up your Cobo account and create your organization. If an organization has already been set up, ask your organization admin to invite you to join the organization.
- Follow the instructions in Send your first request to generate an API key and an API secret, and register the API key on Cobo Portal.
Create a project and install the SDK
- Create a project directory and initialize NPM:
- Install the SDK:
The directory structure after installation is as follows:
If your project already has package.json and package-lock.json, you can directly copy them to the root directory and run npm install to pull dependencies.
- Create a file
index.js in the root directory and paste the following code into it.
The directory structure after installation is as follows:
If your project already has package.json and package-lock.json, you can directly copy them to the root directory and run npm install to pull dependencies.
- Set the API secret.
- Select which environment you want to use.
Code sample
For operation-specific documentation and sample code, see the docs folder in the Payments GitHub repository.