npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@paciolan/cybersource-sdk

v0.4.0

Published

CyberSource REST API Typescript SDK

Downloads

23

Readme

Cybersource SDK for NodeJS

A modern fork of Cybersource's official Node SDK — generated from Cybersource's own API source code

Motivation

Tl;dr — This is Cybersource's official SDK, generated using a newer (Typescript compatible) version of Swagger Codegen.

Cybersource's official NodeJS SDK is automatically generated using Swagger Codegen v2.3.0. Cybersource feeds the code generator a swagger 2.0 specification file generated from their API's source code and a customized code-gen template.

Unfortunately v2.3 of Swagger Codegen does not support Typescript, and takes a lot of inspiration from the Java code generator, resulting in an unintuitive and clunky user experience. This project feeds the same swagger 2.0 specification file into a newer Typescript-compatible version of Swagger Codegen (v3).

This results in a strongly typed SDK which reflects the types generated by Cybersource's official API source code; much less room for human error.

Differences

The overall functionality of the new SDK should remain similar to the old SDK since they are both generated using the same OpenAPI specification file.

  • Uses Typescript

  • Doesn't require logging settings to be set up.

  • Only supports Cybersource's HTTP authentication method for now.

  • HTTP library has been switched from superagent to Axios.

  • Endpoints now return Promises instead of error-first callbacks.

Usage

While Cybersource's official examples likely won't work as-is, the method names should remain the same and the added types should provide the necessary information to determine which parameters methods should be called with and what data the methods return. We encourage you to still view Cybersource's official documentation for SDK usage, but know that the method signatures may have changed slightly.

Example usage can be found in the payment-ms's CybersourceClientApiWrapper.

Installation

$ npm install @paciolan/cybersource-sdk

Example Payment

import { PaymentsApi, V2PaymentsBody } from '@paciolan/cybersource-sdk';
const requestBody: V2PaymentsBody = {
  paymentInformation: {
    card: {
      number: '4242424242424242',
      expirationMonth: '09',
      expirationYear: '24',
    },
  },
  orderInformation: {
    amountDetails: {
      currency: 'USD',
      totalAmount: '123.45',
    },
  },
};
const apiResponse = await PaymentsApi.createPayment(
  requestBody,
  merchantConfig,
);

Globally Exported Members

  • BASE_PATH (Previously new require('cybersource-rest-client').ApiClient().basePath)

Contributing

This repository is meant to maintain 2 minimal patch sets, one for the custom authentication code from Cybersource, and one for the customized code-gen template to add support for the authentication code.

If, for example, you're looking to add support for another authentication scheme, you would likely want to start in the /src folder to add support there first, and then add any necessary hooks in to the /template to call your custom code.

Generating the SDK

To regenerate the SDK with your changes, simply run ./scripts/develop.sh

Trying your updates locally

Now that you've got the SDK generated, you can try using it locally by using NPM's link command in whatever project you want the consume the SDK with.

Updating base versions

To update the base version of our dependencies, simply change the tag specified in /scripts/lib/variables.sh

| Dependency | Variable Name | | ------------------------- | ----------------------------------- | | cybersource-rest-client | cybersource_rest_client_version | | Swagger code-gen binary | swagger_codegen_version | | Swagger code-gen template | swagger_codegen_templates_version |

Then, simply refer to Generating the SDK to rebuild.