Skip to content

Repository files navigation

@biggora/makecommerce

npm versionUnit TestsLicense: MIT

TypeScript SDK and NestJS adapter for the MakeCommerce REST API.

Targets Node.js 20+. Ships dual ESM/CommonJS builds and a first-class NestJS subpath export.

Install

npm install @biggora/makecommerce

NestJS apps also need peer deps:

npm install @nestjs/common @nestjs/core reflect-metadata rxjs

Quick Start: Checkout

Create a transaction with return, cancel, and notification URLs. Redirect the buyer to the returned payment URL, then confirm the transaction status from a server-side notification before fulfilling the order.

import{createMakeCommerceClient}from'@biggora/makecommerce';constmakeCommerce=createMakeCommerceClient({shopId: process.env.MAKECOMMERCE_SHOP_ID!,secretKey: process.env.MAKECOMMERCE_SECRET_KEY!,environment: 'test',});consttransaction=awaitmakeCommerce.transactions.create({transaction: {amount: '10.00',currency: 'EUR',reference: 'order-123',transaction_url: {return_url: {url: 'https://shop.example/checkout/return',method: 'GET',},cancel_url: {url: 'https://shop.example/checkout/cancel',method: 'GET',},notification_url: {url: 'https://shop.example/webhooks/makecommerce',method: 'POST',},},},customer: {ip: '203.0.113.10',email: 'buyer@example.com',country: 'EE',locale: 'et',},});constredirectUrl=transaction.payment_methods?.other?.find((method)=>method.name==='redirect')?.url;console.log(redirectUrl);

environment defaults to test. Use environment: 'live' for https://api.maksekeskus.ee, or pass baseUrl for custom routing.

Webhook Notifications

MakeCommerce sends transaction updates to the notification_url configured on the transaction. Parse the incoming body, then read the transaction from MakeCommerce before changing local order state.

exportasyncfunctionhandleMakeCommerceNotification(body: {transaction?: string;id?: string;reference?: string}){consttransactionId=body.transaction??body.id;if(!transactionId){thrownewError('Missing MakeCommerce transaction id');}consttransaction=awaitmakeCommerce.transactions.get(transactionId);if(transaction.status==='COMPLETED'){// Mark body.reference as paid in your order system.}return'OK';}

Resources

awaitmakeCommerce.shop.getConfiguration();awaitmakeCommerce.shop.getPaymentMethods({amount: '10.00',currency: 'EUR',country: 'EE'});awaitmakeCommerce.shop.getAccountStatement({since: '2026-01-01'});awaitmakeCommerce.shop.getAccountStatementXml({since: '2026-01-01'});awaitmakeCommerce.shop.getAccountStatementCamt053({since: '2026-01-01'});awaitmakeCommerce.shop.getFees({since: '2026-01-01'});awaitmakeCommerce.transactions.list({status: ['COMPLETED','REFUNDED']});awaitmakeCommerce.transactions.get('transaction-id');awaitmakeCommerce.transactions.getStatement('transaction-id');awaitmakeCommerce.transactions.addMerchantData('transaction-id',{merchant_data: 'order-123'});awaitmakeCommerce.transactions.createPayment('transaction-id',{token: 'token-id'});awaitmakeCommerce.refunds.create('transaction-id',{amount: '1.00',comment: 'Partial refund'});awaitmakeCommerce.refunds.get('refund-id');awaitmakeCommerce.refunds.list({status: 'SETTLED'});

NestJS

import{Module}from'@nestjs/common';import{MakeCommerceModule}from'@biggora/makecommerce/nestjs';
@Module({imports: [MakeCommerceModule.forRoot({shopId: process.env.MAKECOMMERCE_SHOP_ID!,secretKey: process.env.MAKECOMMERCE_SECRET_KEY!,environment: 'test',}),],})exportclassAppModule{}
import{Injectable}from'@nestjs/common';import{InjectMakeCommerceClient}from'@biggora/makecommerce/nestjs';importtype{MakeCommerceClient}from'@biggora/makecommerce';
@Injectable()exportclassPaymentsService{constructor(
@InjectMakeCommerceClient()privatereadonlymakeCommerce: MakeCommerceClient,){}}

Async configuration:

MakeCommerceModule.forRootAsync({inject: [ConfigService],useFactory: (config: ConfigService)=>({shopId: config.getOrThrow('MAKECOMMERCE_SHOP_ID'),secretKey: config.getOrThrow('MAKECOMMERCE_SECRET_KEY'),environment: config.get('MAKECOMMERCE_ENVIRONMENT')??'test',}),});

Inject the SDK client in controllers that receive notification_url callbacks and reuse the same transaction confirmation flow there.

Errors

Failed API responses and request failures throw MakeCommerceApiError.

try{awaitmakeCommerce.transactions.get('missing-id');}catch(error){if(errorinstanceofMakeCommerceApiError){console.log(error.status,error.code,error.requestId);}}

About

TypeScript SDK and NestJS adapter for MakeCommerce API.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages