5.0.0 • Published 12 months ago
@openutility/acceptjs-angular-wrapper v5.0.0
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.
// 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 { }
// 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
// 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 { }
5.0.0
12 months ago
4.2.0
1 year ago
4.1.0
2 years ago
4.0.1
2 years ago
4.0.0
2 years ago
4.0.2
2 years ago
3.2.0
3 years ago
3.0.2
3 years ago
3.1.0
3 years ago
3.0.1
3 years ago
3.0.0
3 years ago
11.0.0
3 years ago
2.1.3
4 years ago
2.1.2
4 years ago
2.1.1
4 years ago
2.1.0
5 years ago
8.0.0
5 years ago
2.0.0
5 years ago
1.0.2
6 years ago
1.0.1
6 years ago