1.0.0 • Published 4 years ago

cardsuite-api v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

Cardsuite API

A nodejs library to communicate with the Cardsuite API.

Installation

npm i --save cardsuite-api

Example Usage

const cardsuiteApi = require("cardsuite-api");

const config = {
  url: "https://www.cardsuite.io/api",
  apiKey: "my-api-key",
  apiVersion: "1.0"
};

const cs = new cardsuiteApi(config);
const response = await cs.createPayment({});

Payments

Creating a payment

const response = await cs.createPayments(params);

Parameters

The object parameters for creating a payment are

keytypedescriptionrequired?
currencystringThree character currency code, either BTC, USD, CAD, EURyes
amountnumberAmount of invoice in specified currency in centsyes
reference_idstringCustom reference id associated with the paymentno
callback_urlstringA callback url to receive notifications when a payment is successfulno
redirect_urlstringA redirect url to re-direct the user after a successful payment has been madeno
btc_addressstringA destination BTC address where the BTC purchased will be sent after a successful paymentyes
notify_onlybooleanA flag if true will only notify of a successful payment but NOT broadcast BTC onto the networkno

Response

keydescription
idUnique id of payment
statusPayment status, "open", "cc_failed", "cc_paid", "cc_refunded", "btc_failed", "btc_paid", "complete", "cc_chargeback"
source_currencyThree character currency code, either BTC, USD, CAD, or EUR
source_rateThe exchange rate of the source currency to BTC
amount_btcThe converted amount of BTC in BTC purchased from the payment
amount_satoshiThe converted amount of BTC in satoshi purchased from the payment
reference_idCustom reference id associated with invoice provided on creation
expired_atThe timestamp when the payment is no longer valid
quoted_atThe timestamp when the payment and exchange rate was originally quoted
process_fee_typeThe type of process fee for the payment, can be: "percentage", "fixed", "fixed_percentage"
completed_atThe timestamp when the payment was completed
callback_urlA callback url to receive notifications when a payment is successful
redirect_urlA redirect url to re-direct the user after a successful payment has been made
btc_addressA destination BTC address where the BTC purchased will be sent after a successful payment
btc_hashThe Bitcoin transaction hash of the transaction where the BTC was sent to the destination address
process_fee_amountThe total processing fee associated to the payment in base units
cc_fee_amountThe total credit card processing fee amount related to the payment in base units
cc_fee_typeThe type of credit card fee for the payment, can be: "percentage", "fixed", "fixed_percentage"
callback_ackThe last payment status of a successful callback awknowledgement made from the callback_url: "open", "cc_failed", "cc_paid", "cc_refunded", "btc_failed", "btc_paid", "complete", "cc_chargeback"
source_amountThe total amount charged on the credit card for the payment in base units
tx_fee_satoshiThe total miner fee charged for broadcasting the Bitcoin transcation onto the Bitcoin network in satoshi
notify_onlyA flag if true will only notify of a successful payment but NOT broadcast BTC onto the network
process_fee_percentageThe processing fee percentage charged in a decimal percentage (IE. 5% = 0.05)
cc_fee_percentageThe credit card fee percentage charged in decimal percentage

Reading information from an existing payment

const response = await cs.readPayment(id);

Parameters

The id passed in is the uuid of an existing invoice.

Response

keydescription
idUnique id of payment
statusPayment status, "open", "cc_failed", "cc_paid", "cc_refunded", "btc_failed", "btc_paid", "complete", "cc_chargeback"
source_currencyThree character currency code, either BTC, USD, CAD, or EUR
source_rateThe exchange rate of the source currency to BTC
amount_btcThe converted amount of BTC in BTC purchased from the payment
amount_satoshiThe converted amount of BTC in satoshi purchased from the payment
reference_idCustom reference id associated with invoice provided on creation
expired_atThe timestamp when the payment is no longer valid
quoted_atThe timestamp when the payment and exchange rate was originally quoted
process_fee_typeThe type of process fee for the payment, can be: "percentage", "fixed", "fixed_percentage"
completed_atThe timestamp when the payment was completed
callback_urlA callback url to receive notifications when a payment is successful
redirect_urlA redirect url to re-direct the user after a successful payment has been made
btc_addressA destination BTC address where the BTC purchased will be sent after a successful payment
btc_hashThe Bitcoin transaction hash of the transaction where the BTC was sent to the destination address
process_fee_amountThe total processing fee associated to the payment in base units
cc_fee_amountThe total credit card processing fee amount related to the payment in base units
cc_fee_typeThe type of credit card fee for the payment, can be: "percentage", "fixed", "fixed_percentage"
callback_ackThe last payment status of a successful callback awknowledgement made from the callback_url: "open", "cc_failed", "cc_paid", "cc_refunded", "btc_failed", "btc_paid", "complete", "cc_chargeback"
source_amountThe total amount charged on the credit card for the payment in base units
tx_fee_satoshiThe total miner fee charged for broadcasting the Bitcoin transcation onto the Bitcoin network in satoshi
notify_onlyA flag if true will only notify of a successful payment but NOT broadcast BTC onto the network
process_fee_percentageThe processing fee percentage charged in a decimal percentage (IE. 5% = 0.05)
cc_fee_percentageThe credit card fee percentage charged in decimal percentage

Process payment

const response = await cs.processPayment(params);

Parameters

The object parameters for processing a payment are

keytypedescriptionrequired?
payment_idstringUnique id of paymentyes
ip_addressstringIP address of the purchaseryes
credit_cardstringCredit card number used to make the purchaseyes
ccvnumberCCV number of the credit card used to make the purchaseyes
cc_expiry_datestringCredit card expiry date in MM/YY formartyes
address_1stringAddress line 1 of the credit card purchaseryes
address_2stringAddress line 2 of the credit card purchaseryes
citystringCity of the credit card purchaseryes
statestringState of the credit card purchaserno
countrystringCountry of the credit card purchaseryes
zipstringZip code of the credit card purchaserno
first_namestringFirst name of the credit card purchaseryes
last_namestringLast name of the credit card purchaserno
phonestringPhone number of the credit card purchaseryes
emailstringEmail of the credit card purchaserno

Response

keydescription
idUnique id of payment
statusPayment status, "open", "cc_failed", "cc_paid", "cc_refunded", "btc_failed", "btc_paid", "complete", "cc_chargeback"
source_amountThe total amount charged on the credit card for the payment in base units
source_currencyThree character currency code, either BTC, USD, CAD, or EUR
source_rateThe exchange rate of the source currency to BTC
amount_btcThe converted amount of BTC in BTC purchased from the payment
amount_satoshiThe converted amount of BTC in satoshi purchased from the payment
reference_idCustom reference id associated with invoice provided on creation
expired_atThe timestamp when the payment is no longer valid
quoted_atThe timestamp when the payment and exchange rate was originally quoted
process_fee_typeThe type of process fee for the payment, can be: "percentage", "fixed", "fixed_percentage"
completed_atThe timestamp when the payment was completed
callback_urlA callback url to receive notifications when a payment is successful
redirect_urlA redirect url to re-direct the user after a successful payment has been made
btc_addressA destination BTC address where the BTC purchased will be sent after a successful payment
btc_hashThe Bitcoin transaction hash of the transaction where the BTC was sent to the destination address
process_fee_amountThe total processing fee associated to the payment in base units
cc_fee_amountThe total credit card processing fee amount related to the payment in base units
cc_fee_typeThe type of credit card fee for the payment, can be: "percentage", "fixed", "fixed_percentage"
callback_ackThe last payment status of a successful callback awknowledgement made from the callback_url: "open", "cc_failed", "cc_paid", "cc_refunded", "btc_failed", "btc_paid", "complete", "cc_chargeback"
tx_fee_satoshiThe total miner fee charged for broadcasting the Bitcoin transcation onto the Bitcoin network in satoshi
notify_onlyA flag if true will only notify of a successful payment but NOT broadcast BTC onto the network
process_fee_percentageThe processing fee percentage charged in a decimal percentage (IE. 5% = 0.05)
cc_fee_percentageThe credit card fee percentage charged in decimal percentage

Refunds

Refund payment

const response = await cs.refundPayment(params);

Parameters

The object parameters for refunding a payment are

keytypedescriptionrequired?
payment_idstringUnique id of paymentyes
reasonstringReason for the refundyes

Response

keydescription
payment_idUnique id of payment
source_currencyThree character currency code, either BTC, USD, CAD, or EUR
source_amountThe total amount refunded on the credit card for the payment in base units
statusRefund status, "open", "complete"
reasonReason for the refund

Chargebacks

Chargeback a payment

const response = await cs.chargebackPayment(params);

Parameters

The object parameters for refunding a payment are

keytypedescriptionrequired?
payment_idstringUnique id of paymentyes
reasonstringReason for the chargebacyes

Response

keydescription
payment_idUnique id of payment
source_currencyThree character currency code, either BTC, USD, CAD, or EUR
source_amountThe total amount chargebacked on the credit card for the payment in base units
statusRefund status, "open", "complete"
reasonReason for the chargeback

Payment Tokens

Creating a payment token

const response = await cs.createPaymentToken();

Response

keydescription
expiredWhether or not the payment token is expired or not: true or false
expiry_dateTimestamp of when the payment token will be expired
created_atTimestamp of when the payment token was created
idThe payment token to be used in the hosted URL payment page