npm.io
3.0.0 • Published 2 weeks ago

@magensa/te-connect-ng

Licence
MIT
Version
3.0.0
Deps
1
Size
142 kB
Vulns
0
Weekly
0

@magensa/te-connect-ng

npm version

Angular components used to interact with TEConnect.

This release is an Angular 21 upgrade and modernization of the previous Angular 19 build. The components are standalone, signal-based, OnPush, and zoneless-safe — they render correctly under both zone-based and zoneless host applications. The public component selectors and input names are unchanged, so existing templates continue to work; the major version reflects the tightened public TypeScript types.

Installation

npm install @magensa/te-connect @magensa/te-connect-ng

Peer dependencies

Package Version
@angular/core ^21.0.0
@angular/common ^21.0.0

@magensa/te-connect is required at runtime — you create a TEConnect instance with it and pass that instance into each component's teConnect input. It is intentionally not a declared dependency of this package.

Quick start

Import the standalone component(s) you need directly — there is no NgModule.

import { Component } from '@angular/core';
import { createTEConnect } from '@magensa/te-connect';
import { TeConnectNgComponent } from '@magensa/te-connect-ng';
import type { CreatePaymentResponse } from '@magensa/te-connect-ng';

@Component({
  selector: 'app-checkout',
  imports: [TeConnectNgComponent],
  template: `
    <lib-te-connect-ng
      [teConnect]="teConnect"
      [stylesConfig]="styles"
      (teResponse)="onResponse($event)"
    ></lib-te-connect-ng>
    <button type="button" (click)="frame.createPayment()">Create Payment</button>
  `,
})
export class CheckoutComponent {
  teConnect = createTEConnect('__your_public_key_here__');
  styles = { base: { backgroundColor: '#fff' } };

  onResponse(resp: CreatePaymentResponse) {
    console.log(resp);
  }
}

To invoke createPayment() programmatically, grab the component via a template reference or viewChild() and call createPayment(billingZip?), which resolves to a CreatePaymentResponse and also emits teResponse.

Components

Selector Component Purpose
lib-te-connect-ng TeConnectNgComponent Secure card-entry iframe + createPayment.
lib-tec-threeds TecThreedsComponent 3DS card-entry iframe + createPayment, with a threeDsStatus listener.
lib-tec-payment-request TecPaymentRequestComponent Apple Pay / Google Pay payment-request buttons.

Full integration documentation (styles, Payment Request, and 3DS) is maintained at github.com/Magensa/TEConnect.

Build outputs

ng build te-connect-ng produces an Angular Package Format distribution in dist/te-connect-ng:

Output Purpose
fesm2022/magensa-te-connect-ng.mjs Flat ESM bundle (+ source map)
types/magensa-te-connect-ng.d.ts Generated TypeScript declarations
package.json Publish manifest (peer deps, exports, sideEffects: false)

Development

npm install
npm run build          # ng build te-connect-ng (ng-packagr / APF)
npm test               # Vitest unit tests (jsdom, zoneless)
npm run test:watch     # Watch mode
npm run test:coverage  # Coverage (v8)

License

MIT