# @openutility/acceptjs-angular-wrapper

Latest version **5.0.0** (published 2023-05-29) · (ISC OR GPL-3.0) license · 0 weekly downloads

## Install

```sh
npm install @openutility/acceptjs-angular-wrapper
pnpm add @openutility/acceptjs-angular-wrapper
yarn add @openutility/acceptjs-angular-wrapper
bun add @openutility/acceptjs-angular-wrapper
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2023-05-29 |
| First published | 2018-09-14 |
| Weekly downloads | 0 |
| License | (ISC OR GPL-3.0) |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 33.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Maintainers | andrewjrvs, barrettotte |

## Links

- npm: https://www.npmjs.com/package/@openutility/acceptjs-angular-wrapper
- Repository: https://github.com/openUtility/acceptjs-angular-wrapper
- Homepage: https://github.com/openUtility/acceptjs-angular-wrapper#readme
- Issues: https://github.com/openUtility/acceptjs-angular-wrapper/issues
- npm.io page: https://npm.io/package/@openutility/acceptjs-angular-wrapper

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.3.0

## Recent versions

- 5.0.0 (latest) — 2023-05-29
- 4.2.0 — 2022-11-25
- 4.1.0 — 2022-07-02
- 4.0.2 — 2022-03-08
- 4.0.1 — 2022-03-08
- 4.0.0 — 2022-02-27
- 3.2.0 — 2021-10-21
- 3.1.0 — 2021-05-14
- 3.0.2 — 2021-05-13
- 2.1.3 — 2019-11-26
- 2.1.2 — 2019-11-26
- 2.1.1 — 2019-11-26
- 2.1.0 — 2019-08-29
- 8.0.0 — 2019-06-29
- 2.0.0 — 2019-02-10
- … 2 more at https://npm.io/package/@openutility/acceptjs-angular-wrapper/versions

## README

# acceptjs-angular-wrapper

exposing the Authorize.net Accept.js Host your own script from an Angular service.

This service exposed one method ```generatePaymentNonce``` which will return a string promise of the nonce.
any script errors, or api errors should be returned in the promise rejection.

```ts
// file app.module.ts
import { NgModule } from '@angular/core';
import { TK_CONFIG, Config, AcceptJSService } from '@openutility/acceptjs-angular-wrapper';

/*
  Build the configuration file passing in the AcceptJS
  URL (testing or prod)
  and your apiLoginID and client key
//*/
const AcceptJSConfig: Config = {
  acceptjsUrl: 'mockAcceptjs.js'
  , apiLoginID: '123'
  , clientKey: '456'
};

@NgModule({
  providers: [
    {
      provide: TK_CONFIG,
      useValue: AcceptJSConfig
    },
    AcceptJSService
  ]
})
export class AppModule { }
```

```ts
// file app.component.ts
import { Component, OnInit  } from '@angular/core';
import { TK_CONFIG, Config, AcceptJSService } from '@openutility/acceptjs-angular-wrapper';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html'
})
export class AppComponent {
    constructor(private _acceptJSSrv: AcceptJSService) { }

    async onSubmit(cc: CreditCard): void {
      try {
        const nonce = await this._acceptJSSrv.generatePaymentNonce(cc);
        // submit nonce to your server with payment amount
      } catch (ex) {
        console.error(ex);
      }
    }
}
```

## Dynamic Config

```ts
// file app.module.ts
import { NgModule } from '@angular/core';
import { TK_CONFIG, Config, AcceptJSService } from '@openutility/acceptjs-angular-wrapper';
import { of } from 'rxjs';

const AcceptJSConfig: Config = {
  acceptjsUrl: 'mockAcceptjs.js'
  , apiLoginID: '123'
  , clientKey: '456'
};

@NgModule({
  providers: [
    {
      provide: TK_CONFIG,
      useFactory: () => of(AcceptJSConfig)  // note: you wouldn't code it this way, but just to show how it could work... :)
    },
    AcceptJSService
  ]
})
export class AppModule { }
```

---
_Source: https://npm.io/package/@openutility/acceptjs-angular-wrapper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
