Privacy API is an NPM Package for for communicating with the privacy.com API
Use the package manager npm to install privacy-api
.
$ npm install privacy-api
Responses are returned as standard axios responses
Constructor: privacy(API_KEY, sandbox = true, version = 1)
API_KEY
: Your developer environment API Keysandbox
: Whether you want to use the sandbox API or the production APIversion
: The API version to use (currently only supports version 1)
const privacy = require('privacy-api');
let privacy_api = new privacy(<API-KEY>); // Initialize the privacy object with your API key
let response = await privacy_api.list_cards(); // Async functions
console.log(response.data);
- Lists all available cards for the authenticated user
- Documentation available at: https://developer.privacy.com/docs#endpoints-list-cards
let response = await list_cards(page, page_size, begin, end, card_token);
- Lists all transactions for the given
approval_status
- Documentation available at: https://developer.privacy.com/docs#endpoints-list-transactions
let response = await list_transactions(approval_status, page, page_size, begin, end, card_token, transaction_token);
- Creates a new card for the authenticated user of the given
type
- Documentation available at: https://developer.privacy.com/docs#endpoints-create-card
let response = await create_card(type, memo, spend_limit, spend_limit_duration);
- Updates an existing card (given the
card_token
) for the authenticated user - Documentation available at: https://developer.privacy.com/docs#endpoints-update-card
let response = await update_card(card_token, state, memo, spend_limit, spend_limit_duration);
- Simulates an authorization transaction as if it came from a Merchant
- The transaction is immediately marked as pending
- The
pan
field is the 16-digit card number - Documentation available at: https://developer.privacy.com/docs#endpoints-simulate-authorization
let response = await simulate_authorization(descriptor, pan, amount);
- Simulates a void transaction on a pending transaction
- The
token
field is the transaction token - Documentation available at: https://developer.privacy.com/docs#endpoints-simulate-void
let response = await simulate_void(token, amount);
- Simulates clearing (or authorizing) a pending transaction
- The transaction is marked as authorized
- The
token
field is the transaction token - Documentation available at: https://developer.privacy.com/docs#endpoints-simulate-clearing
let response = await simulate_clearing(token, amount);
- Simulates a return (or refund) transaction
- The transaction is immediately marked as authorized
- The
pan
field is the 16-digit card number - Documentation available at: https://developer.privacy.com/docs#endpoints-simulate-return
let response = await simulate_return(descriptor, pan, amount);
- Provides an
iframe
body (with an option for custom CSS) - Allows the card provider (privacy.com) to directly show card details to the user
- The
card_uuid
field is cardtoken
provided by the API - The
css_url
field is the location of theCSS
file (example: https://example.com/default.css) - Generates the embed request as well as a PCI Compliant HMAC for you
- Documentation available at: https://developer.privacy.com/docs#hosted-card-ui
let response = await hosted_card_ui(api_key, card_uuid, css_url);
Returns an HTML string of the form:
<div id="card">
<div id="pan">{PAN}</div>
<div id="expiry">
<span id="month">{expMonth}</span>
<span id="separator">/</span>
<span id="year">{expYear}</span>
</div>
<div id="cvv">{CVV}</div>
</div>
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.