Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
checkout-sdk-node
Advanced tools
[![build-status](https://github.com/checkout/checkout-sdk-node/workflows/build-master/badge.svg)](https://github.com/checkout/checkout-sdk-node/actions/workflows/build-master.yml) ![CI Tests](https://github.com/checkout/checkout-sdk-node/workflows/CI%20Te
npm install checkout-sdk-node
// ES6:
import { Checkout } from 'checkout-sdk-node';
// Common JS:
const { Checkout } = require('checkout-sdk-node');
If you don't have your API keys, you can sign up for a test account here.
Based on how your account was set up, you will either have a pair or API key or a set of access credentials. Here is how you can use the SDK in both scenarios:
// API Keys
const cko = new Checkout('sk_XXXXXXXXX', {
pk: 'pk_XXXXXXX'
});
// Access credentials
const cko = new Checkout('your api secret here', {
client: 'ack_XXXXXXXX',
scope: ['gateway'], // or whatever scope required
environment: 'sandbox', // or 'production'
});
If your account uses API Keys (pk_XXX + sk_XXX), you can set the following environment variables, and the SK will pick them up:
If you use access credentials (ack_XXXX), you can set the following environment variables, and the SK will pick them up:
Basides the authentication, you also have the option to configure some extra elements about the SDK
const cko = new Checkout('...', {
..., //other authentication config
host: "https://myProxyExample.com", // in case you need to use a custom host for tests
timeout: 60000, // HTTP request timout in ms
agent: new http.Agent({ keepAlive: true }), // custom HTTP agent
httpClient: 'axios' // specify axios httpClient, by default fetch. Optional
});
When using API Keys (pk_XXX + sk_XXX) the SDK will automatically figure out what environment you are using however, if you use access credentials (ack_XXXX), make sure you set the "environment" in the config, as shown above in the initialization.
The SDK is using promises, and you can handle errors similar to any other HTTP call.
try {
// some async request made with the SDK
const action = await cko.payments.request({...});
...
} catch (error) {
console.log(error.name, error.http_code, error.body)
switch (error.name) {
...
}
}
Here you have all the possible SDK specific errors:
error.name | error.http_code | error.body |
---|---|---|
AuthenticationError | 401 | undefined |
ActionNotAllowed | 403 | undefined |
UrlAlreadyRegistered | 409 | undefined |
NotFoundError | 404 | undefined |
BadGateway | 502 | undefined |
ValidationError | 422 | object |
TooManyRequestsError | 429 | object/undefined |
ValueError | 429 | string describing error |
You can see examples of how to use the SDK for every endpoint documented in our API Reference. All you have to do is to navigate to the endpoint you want to use, and select "Node" for the example on the right side.
NOTE: If you use access credentials (ack_XXXX) the link to the API reference relevant to you will be shared by your Solutions Engineers.
You can try the SDK here.
FAQs
[![build-status](https://github.com/checkout/checkout-sdk-node/workflows/build-master/badge.svg)](https://github.com/checkout/checkout-sdk-node/actions/workflows/build-master.yml) ![CI Tests](https://github.com/checkout/checkout-sdk-node/workflows/CI%20Te
The npm package checkout-sdk-node receives a total of 14,514 weekly downloads. As such, checkout-sdk-node popularity was classified as popular.
We found that checkout-sdk-node demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.