Collector Checkout
A Node.js module for Collector Checkout API integration.
Getting Started
Read the Collector Checkout API documentation and contact merchant@collectorbank.se to obtain a username, store ID, and access key.
This module is still under development.
Installing
npm install collector-checkout
Examples
Require the module:
let Collector = ;
Initialize the module with your username, access key, and store ID:
let collectorCheckout = countryCode: "SE" username: 'your-username' accessKey: 'your-access-key' storeId: 123 ;
To target the test environment:
let collectorCheckout = countryCode: "SE" username: 'your-username' accessKey: 'your-access-key' storeId: 123 test: true ;
Functions
initCheckout
Initialize a Checkout
let checkoutData = redirectPageUri: 'https://your-redirect-url.com' merchantTermsUri: 'https://your-terms-url.com' notificationUri: 'https://your-notifications-url.com' reference: '123' cart: items: id: '111' description: 'Product 1' unitPrice: 100 vat: 25 quantity: 2 ; // Old school Promise method collectorCheckout; // New ES8 method try let result = await collectorCheckout; // Handle result catcherror // Handle error
updateCart
Update the cart
let privateId; // Id acquired from initCheckout let updatedCart = items: id: '111' description: 'Product 2' unitPrice: 100 vat: 25 quantity: 1 ; // Old school Promise method collectorCheckout; // New ES8 method try let result = await collectorCheckout; // Handle result catcherror // Handle error
updateFees
Update the fees
let privateId; // Id acquired from initCheckout let updatedFees = shipping: id: 'shipping-cost' description: 'Shipping fee' unitPrice: 10 var: 25 // Old school Promise method collectorCheckout; // New ES8 method try let result = await collectorCheckout; // Handle result catcherror // Handle error
updateReference
Update the reference
let privateId; // Id acquired from initCheckout // Old school Promise method collectorCheckout; // New ES8 method try let result = await collectorCheckout; // Handle result catcherror // Handle error
getScriptTag
Used to get the client script tag with the correct attributes
let publicToken; // Public token acquired from initCheckout let data = publicToken: publicToken padding: false // Optional id: 'checkout-iframe' // Optional actionColor: '#004500' // Optional let scriptTagHtml = collectorCheckout; // Put scriptTagHtml in the client HTML where you want the checkout iframe to be rendered
Authors
- Emil Isaksson - Creator - emilisaksson
License
This project is licensed under the GNU General Public License - see the LICENSE.md file for details