Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@paciolan/cybersource-sdk

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@paciolan/cybersource-sdk

CyberSource REST API Typescript SDK

  • 0.3.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
132
decreased by-33.67%
Maintainers
1
Weekly downloads
 
Created
Source

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

DependencyVariable Name
cybersource-rest-clientcybersource_rest_client_version
Swagger code-gen binaryswagger_codegen_version
Swagger code-gen templateswagger_codegen_templates_version

Then, simply refer to Generating the SDK to rebuild.

Keywords

FAQs

Package last updated on 16 May 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc