
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
tco-node-api
Advanced tools
$ npm install
Require the dependency.
var tco = require('twocheckout');
Setup your credentials:
tco.config(SELLER_ID, PRIVATE_KEY, BOOL(SANDBOX)); // pass true as third argument to use the sandbox
var params = {
amount: 1.00,
merchant_order_id: '123',
auth_only: true,
customer: {
phone: '555-555-5556',
currency: 'USD',
lang: 'en',
email: 'nobody@example.com',
payment_method: {
credit_card: {
number: '4111111111111111',
exp_month: 12,
exp_year: 2019,
cvv: '123'
},
address: {
name: 'Testing Tester',
address_1: '123 Test St',
address_2: 'the attic',
city: 'Columbus',
state: 'OH',
country_code: 'US',
postal_code: '43123'
}
}
}
};
tco.sales.create(params, function (error, sale) {
console.log(sale.id); //sale_id
console.log(sale.invoices[0].id); //invoice_id
});
tco.sales.find(SALE_ID, function (error, sale) {
console.log(sale.id); //sale_id
console.log(sale.invoices[0].id); //invoice_id
});
params = {page: 1, page_size: 5}
tco.sales.list(params, function (error, data) {
console.log(data.sales[0].id); // first sale_id
console.log(data.pagenation.next); // next page
});
tco.invoices.find(INVOICE_ID, function (error, invoice) {
console.log(invoice.id); // invoice_id
});
params = {page: 1, page_size: 5}
tco.invoices.list(null, function (error, data) {
console.log(data.invoices[0]);
});
tco.sales.capture(INVOICE_ID, function (error, invoice) {
console.log(invoice.id); // invoice_id
console.log(invoice.needs_captured); // false
});
invoice = twocheckout.Invoice.find(INVOICE_ID) # twocheckout.invoice.Invoice
params = {
amount: 1.00,
currency_type: "vendor",
comment: "Refund Issued"
}
tco.invoices.refund(sale.invoices[0].id, params,function (error, invoice) {
console.log(invoice.id); // invoice_id
console.log(invoice.refunds[0].id); // refund_id
});
params = {
phone: '555-555-5556',
currency: 'USD',
lang: 'en',
email: 'nobody@example.com',
payment_method: {
credit_card: {
number: '4111111111111111',
exp_month: 12,
exp_year: 2019,
cvv: '123'
},
address: {
name: 'Testing Tester',
address_1: '123 Test St',
address_2: 'the attic',
city: 'Columbus',
state: 'OH',
country_code: 'US',
postal_code: '43123'
}
}
};
tco.customers.create(params, function (error, customer) {
console.log(customer.id); // customer_id
console.log(customer.payment_methods[0].id); // payment_method_id
});
tco.customers.find(CUSTOMER_ID, function (error, customer) {
console.log(customer.id); // customer_id
console.log(customer.payment_methods[0].id); // payment_method_id
});
params = {page: 1, page_size: 5}
tco.customers.list(params, function (error, data) {
console.log(data.customers[0].id); // first customer_id
});
tco.customers.update(CUSTOMER_ID, {email: "test@2co.com"},function (error, customer) {
console.log(customer.id); // customer_id
});
tco.customers.delete(CUSTOMER_ID,function (error, result) {
console.log(result.code); // OK
});
params = {
credit_card: {
number: '4111111111111111',
exp_month: 12,
exp_year: 2019,
cvv: '123'
},
address: {
name: 'Testing Tester',
address_1: '123 Test St',
address_2: 'the attic',
city: 'Columbus',
state: 'OH',
country_code: 'US',
postal_code: '43123'
}
}
tco.payment_methods.create(CUSTOMER_ID, params, function (error, payment_method) {
console.log(payment_method.id); // payment_method_id
console.log(payment_method.brand); // VS
});
tco.payment_methods.find(CUSTOMER_ID, PAYMENT_METHOD_ID, function (error, payment_method) {
console.log(payment_method.id); // payment_method_id
console.log(payment_method.brand); // VS
});
tco.payment_methods.list(CUSTOMER_ID, null, function (error, data) {
console.log(data.payment_methods[0].id); //first payment_method_id
});
tco.payment_methods.default(CUSTOMER_ID, PAYMENT_METHOD_ID, function (error, payment_method) {
console.log(payment_method.default); //true
});
tco.payment_methods.delete(CUSTOMER_ID, PAYMENT_METHOD_ID, function (error, result) {
console.log(result.code); // OK
});
Subscriptions (recurring items) can be created when creating a sale by passing a recurrence and optionally a duration.
tco.subscriptions.stop(SUBSCRIPTION_ID, function (error, subscription) {
console.log(subscription.id); // subscription_id
console.log(subscription.active) // false
});
Errors will be thrown if the request is not successful. You should always check the error object in your callback so that you can cleanly handle exceptions.
tco.sales.create(params, function (error, sale) {
if(data === undefined) {
console.log(error.message)
} else {
console.log(data)
}
});
$ mocha --timeout 10000
FAQs
A node.js wrapper for the 2Checkout API V2.
We found that tco-node-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.