npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@one-payments/angular

v1.4.1

Published

Angular wrapper for One Payments SDK

Readme

@one-payments/angular

Angular wrapper component for One Payments SDK. Use this package to integrate One Payments into your Angular applications with a native Angular component API.

Features

  • Native Angular standalone component wrapping One Payments web component
  • Full TypeScript support with type definitions
  • Angular Input/Output decorators
  • Zone-aware change detection
  • Works with Angular 16+ standalone components

Installation

npm install @one-payments/angular @one-payments/adapters-web
# or
yarn add @one-payments/angular @one-payments/adapters-web
# or
pnpm add @one-payments/angular @one-payments/adapters-web

Usage

Basic Example

import { Component } from '@angular/core';
import { OnePaymentComponent } from '@one-payments/angular';
import { PaymentConfig } from '@one-payments/core';
import { createWebAdapters } from '@one-payments/adapters-web';
import type {
  PaymentSucceededPayload,
  PaymentFailedPayload,
  Adapters
} from '@one-payments/angular';

@Component({
  selector: 'app-checkout',
  standalone: true,
  imports: [OnePaymentComponent],
  template: `
    <div class="checkout">
      <h1>Complete Your Payment</h1>
      <one-payment
        [config]="config"
        [adapters]="adapters"
        [amount]="5000"
        currency="SGD"
        [orderId]="orderId"
        firstName="John"
        lastName="Doe"
        email="[email protected]"
        (paymentSuccess)="handleSuccess($event)"
        (paymentError)="handleError($event)"
      />
    </div>
  `,
  styles: [`
    .checkout {
      max-width: 600px;
      margin: 0 auto;
      padding: 24px;
    }
  `]
})
export class CheckoutComponent {
  // Create config using PaymentConfig class (recommended for type safety and validation)
  config = new PaymentConfig({
    apiKey: 'your-api-key',
    secretKey: 'your-secret-key',
    environment: 'demo'
  });

  adapters: Adapters = createWebAdapters();
  orderId = `order-${Date.now()}`;

  handleSuccess(payload: PaymentSucceededPayload) {
    console.log('Payment successful!', payload);
    // Navigate to success page or show confirmation
  }

  handleError(payload: PaymentFailedPayload) {
    console.error('Payment failed:', payload);
    // Show error message to user
  }
}

Note: You can also pass a plain config object instead of using PaymentConfig, but PaymentConfig is recommended as it provides validation and better TypeScript support.

With State Management

import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { OnePaymentComponent } from '@one-payments/angular';
import { createWebAdapters } from '@one-payments/adapters-web';
import type {
  SDKConfig,
  PaymentSucceededPayload,
  PaymentFailedPayload,
  StateChangedPayload,
  Adapters
} from '@one-payments/angular';

type PaymentStatus = 'idle' | 'processing' | 'success' | 'error';

@Component({
  selector: 'app-checkout',
  standalone: true,
  imports: [CommonModule, OnePaymentComponent],
  template: `
    <div class="checkout">
      <div *ngIf="paymentStatus === 'success'" class="success">
        Payment successful! Thank you for your order.
      </div>

      <div *ngIf="paymentStatus !== 'success'">
        <div *ngIf="paymentStatus === 'error'" class="error">
          {{ errorMessage }}
        </div>

        <div *ngIf="paymentStatus === 'processing'" class="processing">
          Processing your payment...
        </div>

        <one-payment
          [config]="config"
          [adapters]="adapters"
          [amount]="amount"
          [currency]="currency"
          [orderId]="orderId"
          [metadata]="metadata"
          (paymentSuccess)="handleSuccess($event)"
          (paymentError)="handleError($event)"
          (stateChange)="handleStateChange($event)"
        />
      </div>
    </div>
  `,
  styles: [`
    .error {
      padding: 16px;
      background-color: #fee;
      border: 1px solid #fcc;
      border-radius: 4px;
      color: #c00;
      margin-bottom: 16px;
    }

    .processing {
      padding: 16px;
      background-color: #fef3cd;
      border: 1px solid #ffeaa7;
      border-radius: 4px;
      color: #856404;
      margin-bottom: 16px;
    }

    .success {
      padding: 16px;
      background-color: #d4edda;
      border: 1px solid #c3e6cb;
      border-radius: 4px;
      color: #155724;
    }
  `]
})
export class CheckoutComponent {
  paymentStatus: PaymentStatus = 'idle';
  errorMessage = '';

  config: SDKConfig = {
    apiKey: 'your-api-key',
    secretKey: 'your-secret-key',
    environment: 'prod'
  };

  adapters: Adapters = createWebAdapters();
  amount = 5000;
  currency = 'SGD';
  orderId = `order-${Date.now()}`;
  metadata = {
    userId: '12345',
    productId: 'product-abc'
  };

  handleSuccess(payload: PaymentSucceededPayload) {
    this.paymentStatus = 'success';
    console.log('Payment Intent ID:', payload.paymentIntentId);
  }

  handleError(payload: PaymentFailedPayload) {
    this.paymentStatus = 'error';
    this.errorMessage = payload.message;
  }

  handleStateChange(payload: StateChangedPayload) {
    console.log('Payment state:', payload.status);
    if (payload.status === 'processing') {
      this.paymentStatus = 'processing';
    }
  }
}

With Angular Router

import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { OnePaymentComponent } from '@one-payments/angular';
import { createWebAdapters } from '@one-payments/adapters-web';
import type {
  SDKConfig,
  PaymentSucceededPayload,
  PaymentFailedPayload
} from '@one-payments/angular';

@Component({
  selector: 'app-checkout',
  standalone: true,
  imports: [OnePaymentComponent],
  template: `
    <one-payment
      [config]="config"
      [adapters]="adapters"
      [amount]="5000"
      currency="SGD"
      [orderId]="orderId"
      (paymentSuccess)="handleSuccess($event)"
      (paymentError)="handleError($event)"
    />
  `
})
export class CheckoutComponent {
  config: SDKConfig = {
    apiKey: 'your-api-key',
    secretKey: 'your-secret-key',
    environment: 'prod'
  };

  adapters = createWebAdapters();
  orderId = `order-${Date.now()}`;

  constructor(private router: Router) {}

  handleSuccess(payload: PaymentSucceededPayload) {
    this.router.navigate(['/success'], {
      queryParams: { paymentId: payload.paymentIntentId }
    });
  }

  handleError(payload: PaymentFailedPayload) {
    this.router.navigate(['/error'], {
      queryParams: { error: payload.message }
    });
  }
}

Using Environment Variables

// environment.ts
export const environment = {
  production: false,
  onePayments: {
    apiKey: 'your-dev-api-key',
    secretKey: 'your-dev-secret-key',
    environment: 'dev' as const
  }
};

// checkout.component.ts
import { Component } from '@angular/core';
import { OnePaymentComponent } from '@one-payments/angular';
import { createWebAdapters } from '@one-payments/adapters-web';
import { environment } from '../environments/environment';

@Component({
  selector: 'app-checkout',
  standalone: true,
  imports: [OnePaymentComponent],
  template: `
    <one-payment
      [config]="config"
      [adapters]="adapters"
      [amount]="5000"
      currency="SGD"
      [orderId]="orderId"
      (paymentSuccess)="handleSuccess($event)"
      (paymentError)="handleError($event)"
    />
  `
})
export class CheckoutComponent {
  config = environment.onePayments;
  adapters = createWebAdapters();
  orderId = `order-${Date.now()}`;

  handleSuccess(payload: any) {
    console.log('Success:', payload);
  }

  handleError(payload: any) {
    console.error('Error:', payload);
  }
}

Module-based Applications

If you're not using standalone components, you can still use the component by importing it in your module:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { OnePaymentComponent } from '@one-payments/angular';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    OnePaymentComponent  // Import the standalone component
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {}

API Reference

OnePaymentComponent Inputs

| Input | Type | Required | Description | |-------|------|----------|-------------| | config | SDKConfig \| PaymentConfig | Yes | SDK configuration - use new PaymentConfig({...}) (recommended) or plain object | | adapters | Adapters | Yes | Platform adapters (use createWebAdapters() for web) | | amount | number | Yes | Payment amount in smallest currency unit (e.g., cents for USD, SGD) | | currency | string | Yes | ISO 4217 currency code (e.g., "USD", "EUR", "SGD") | | orderId | string | Yes | Unique order identifier from your system | | firstName | string | Yes | Customer's first name (required for all payments) | | lastName | string | Yes | Customer's last name (required for all payments) | | email | string | Yes | Customer's email address (required for all payments) | | excludePaymentMethods | PaymentMethodId[] | No | Array of payment method IDs to exclude from display | | width | string | No | Custom width (e.g., "100%", "500px") | | maxWidth | string | No | Maximum width constraint (e.g., "600px") |

OnePaymentComponent Outputs

| Output | Payload | Description | |--------|---------|-------------| | paymentSuccess | PaymentSucceededPayload | Emitted when payment succeeds | | paymentError | PaymentFailedPayload | Emitted when payment fails | | stateChange | StateChangedPayload | Emitted when payment state changes |

Types

interface SDKConfig {
  apiKey: string;
  secretKey: string;
  environment: 'dev' | 'staging' | 'prod';
}

interface PaymentSucceededPayload {
  paymentIntentId: string;
  amount: number;
  currency: string;
  status: 'succeeded';
  metadata?: Record<string, unknown>;
}

interface PaymentFailedPayload {
  code: string;
  message: string;
  details?: Record<string, unknown>;
}

interface StateChangedPayload {
  status: 'idle' | 'initializing' | 'ready' | 'processing' | 'requires_action' | 'succeeded' | 'failed';
  [key: string]: unknown;
}

Requirements

  • Angular >= 16.0.0 (standalone components)
  • TypeScript >= 5.0.0
  • RxJS >= 7.0.0

For Angular < 16, you can still use this package but may need to adjust the import pattern.

Related Packages

License

MIT