///
This page provides practical examples demonstrating how to interact with the SumUp API using the Node.js SDK. These examples highlight common use cases and demonstrate the recommended way to initializ
764 views
~764 views from guests
Guest views are estimated from total page views. These include anonymous visitors and users who weren't logged in when they viewed the page.
This page provides practical examples demonstrating how to interact with the SumUp API using the Node.js SDK. These examples highlight common use cases and demonstrate the recommended way to initialize the client and make API calls. For details on installation and basic setup, refer to the [Getting Started] page. For a comprehensive overview of the SumUp client and its available resources, see the [SumUp Client API Reference].
All examples rely on environment variables for sensitive information like API keys and merchant codes.
Before running these examples, ensure you have:
@sumup/sdk installed (e.g., npm install @sumup/sdk).You'll need to set the following environment variables:
SUMUP_API_KEY: Your SumUp secret API key (e.g., sup_sk_MvxmLOl0...).SUMUP_MERCHANT_CODE: Your SumUp merchant code (e.g., S0M3M3RCH4NT).You can set these variables in your shell before running the script:
This example demonstrates how to create a new checkout, retrieve merchant information, and then simulate processing the checkout with card details. It showcases interactions with the merchant and checkouts API resources.
process.env.SUMUP_API_KEY, ensuring your API key is not hardcoded.GET request. It also shows how to get the raw Response object using .withResponse().checkout_reference. The merchant_code is essential here, also fetched from environment variables.examples/checkout/index.ts)Save the code above as checkout-example.ts in your project's root directory.
Make sure SUMUP_API_KEY and SUMUP_MERCHANT_CODE are set in your environment.
Then, run it using tsx (which you might need to install globally via npm install -g tsx if not already available, or use npx tsx):
This example demonstrates how to interact with SumUp card readers to create a checkout. It involves listing available readers and initiating a checkout specific to a reader.
SUMUP_MERCHANT_CODE environment variable is set.examples/card-reader-checkout/index.ts)Save the code above as card-reader-example.ts in your project's root directory.
Make sure SUMUP_API_KEY and SUMUP_MERCHANT_CODE are set in your environment, and you have at least one card reader paired with your SumUp merchant account.
Then, run it using tsx: