Skip to content
Sample code to demonstrate using the CyberSource REST APIs with the Python client library.
Python Shell
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
data Fixing spelling typo Dec 18, 2018
lib/sampleapiclient Bringing lane up to date May 14, 2019
resources Adding client Oct 21, 2018
.travis.yml Marking Python 3.4 as allowed failure for string interpolation Oct 9, 2019
LICENSE Initial commit Jul 24, 2018
sampleCodeIgnoreList.txt Bringing lane up to date May 14, 2019

Python Sample Code for the CyberSource SDK

Travis CI Status

This repository contains working code samples which demonstrate python integration with the CyberSource REST APIs through the CyberSource Python SDK.

Using the Sample Code

The samples are all completely independent and self-contained. You can analyze them to get an understanding of how a particular method works, or you can use the snippets as a starting point for your own project. The samples are organized into categories and common usage examples, similar to the CyberSource API Reference.

You can run each sample directly from the command line.


Running the Samples From the Command Line

  • Clone this repository:
    $ git clone
  • Install the CyberSource Python SDK:
    $ pip install cybersource-rest-client-python
  • Install the Sample Codes (required for running Authentication samples only)
	$ pip install -e .
  • Run the individual samples by name. For example:
    $ python [DirectoryPath]\[CodeSampleName]


    $ python samples\payments\coreservices\

Setting your own API credentials for an API Request

Configure the following information in data/ file:

  • Http Signature
        self.authentication_type = "http_signature"
        self.merchantid = "Your Merchant ID"
        self.merchant_keyid = "your key id"
        self.merchant_secretkey = "your secret key"
  • Jwt
        self.authentication_type = "jwt"
        self.merchantid = "Your Merchant ID"
        self.key_alias = "your key alias"
        self.key_pass = "your key password"
        self.key_file_name = "your key filename"
        self.keys_directory = os.getcwd()+"\\resources\\"

Switching between the sandbox environment and the production environment

CyberSource maintains a complete sandbox environment for testing and development purposes. This sandbox environment is an exact duplicate of our production environment with the transaction authorization and settlement process simulated. By default, this SDK is configured to communicate with the sandbox environment. To switch to the production environment, set the appropriate environment constant in data/ file. For example:

   For TESTING use
    self.run_environment = "CyberSource.Environment.SANDBOX"
   #For PRODUCTION use
   #self.run_environment = "CyberSource.Environment.PRODUCTION"

API Reference

The API Reference Guide provides examples of what information is needed for a particular request and how that information would be formatted. Using those examples, you can easily determine what methods would be necessary to include that information in a request using this SDK.

You can’t perform that action at this time.