cppapi
TypeScript icon, indicating that this package has built-in type declarations

1.1.7 • Public • Published

CPP API Node.js Library

This SDK helps you to communicate with the CPP APIs more conveniently without the need to implement HTTP requests or authorization/authentication processes.

Documentation

Note: You will require access to read the documents.

https://docs.ccamatil.com/display/CAW/CPP+-+Node+Js+SDK

Requirements

  • Node 8, 9 or higher

Getting Started

Installation

Install the package:

npm install cppapi

First step

You need to pass your merchant id and the secret to instantiate the cpp.

  • Enable the test environment by passing config {test: true}.
const Cpp = require('cppapi');
const cpp = Cpp('merchantId', 'secret', {test: true});

Validate a customer

API Spec: Validate a customer API

Please refer to the API Spec for request and response properties.

var cust = await cpp.customers.validate({
        customerId: "a689c527-c448-a74b-c458-db78b0e2e2a8"
});

Create a customer

API Spec: Create a customer API

Please refer to the API Spec for request and response properties.

var cust = await cpp.customers.create({
        name: "Firstname Lastname",
        emailAddress: "first.last@test.com"
});

Create a session (Save for later payment or make a payment now with new payment method details)

API Spec: Create a session API

Please refer to the API Spec for request and response properties.

var session = await cpp.sessions.create({
    txnType: "purchase",
    totalAmount: "10.50",
    currencyCode: "AUD",
    clientRef: "202111021",
    tokenize: true,
    customerId: "a689c527-c448-a74b-c458-db78b0e2e2a8",
    paymentTypes: ["card"]
});

Query a session

API Spec: Query a session API

Please refer to the API Spec for request and response properties.

var session = await cpp.sessions.query({
    sessionId: "576648f7-975c-0842-10d8-1e52094700c3"
});

Get customer's payment method(s)

API Spec: Get customer payment method(s) API

Please refer to the API Spec for request and response properties.

var paymentMethod = await cpp.paymentMethods.query({
    customerId: "a689c527-c448-a74b-c458-db78b0e2e2a1",
    paymentTypes: ["card"]
});

Delete customer's payment method

API Spec: Delete customer payment method API

Please refer to the API Spec for request and response properties.

var paymentMethod = await cpp.paymentMethods.del({
    customerId: "a689c527-c448-a74b-c458-db78b0e2e2a1",
    token: "a2ac9037-65fd-03ab-2b2f-1ca23dc8a822"
});

Make payment via token (Make a payment using existing payment method details)

API Spec: Payment token API

Please refer to the API Spec for request and response properties.

var payment = await cpp.payments.create({
    txnType: "purchase",
    totalAmount: "10.50",
    currencyCode: "AUD",
    clientRef: "202111022",
    customerId: "a689c527-c448-a74b-c458-db78b0e2e2a1",
    token: "a2ac9037-65fd-03ab-2b2f-1ca23dc8a824"
});

Status Codes and Errors

  • 200 OK (All APIs return this status code as a successful response)

  • 400 Bad Request

{
    "reasonText": "One or more parameter values were invalid"
}
  • 500 Internal Server Error
{
    "statusCode": 500,
    "error": "Internal Server Error",
    "message": "Error from the Cpp API"
}

Package Sidebar

Install

npm i cppapi

Weekly Downloads

1

Version

1.1.7

License

UNLICENSED

Unpacked Size

133 kB

Total Files

34

Last publish

Collaborators

  • rbychiang