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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@saschwarz/ngx-paddle-wrapper

v1.1.2

Published

This is an Angular wrapper library for Paddle.js.

Downloads

11

Readme

Angular Paddle Wrapper

This is an Angular wrapper library for Paddle.js.

The author has no affiliation with Paddle.com Market Limited.

This project was generated with Angular CLI version 10.1.4 and updated to Angular v15.

How to use

Make sure you have an active Paddle account and have read the docs on paddle.com.

1a) Install with NPM

$ npm install ngx-paddle-wrapper

1b) Or Yarn

$ yarn add ngx-paddle-wrapper

2) Import the PaddleModule

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

import { PaddleModule } from 'ngx-paddle-wrapper';
import { environment } from '../environments/environment';

@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    // set the sandbox boolean to control which Paddle
    // environment you are using:
    PaddleModule.forRoot({ sandbox: !environment.production }),
  ],
  providers: [],
  bootstrap: [AppComponent],
})
export class AppModule {}

3a) The easy way, using the ngxPaddle Directive

<button
  ngxPaddle
  [vendor]="123456"
  [product]="654321"
  email="[email protected]"
  (onCheckoutEvent)="checkEvent($event)"
></button>

3b) The less easy way, using the Service directly

Since most of the functionality is through the service you can imlpement this yourself to customize to your needs further.

import { Component, AfterViewInit } from '@angular/core';

import {
  PaddleService,
  PaddleCheckoutOptions,
  PaddleEventCallbackData,
  PADDLE_EVENT_TYPE,
} from 'ngx-paddle-wrapper';

export class ComponentThatImplementsPaddle implements AfterViewInit {
  private paddleOptions: PaddleCheckoutOptions = {
    product: 654321,
    title: 'Test Title',
    message: 'Test Message',
    coupon: 'TEST',
    email: '[email protected]',
  };

  constructor(private paddleServ: PaddleService) {}

  // Create and open programmatically once the library is loaded.
  ngAfterViewInit() {
    this.paddleServ.create({
      vendor: 123456,
      eventCallback: this.checkEvent,
    });
  }

  onSubscribe() {
    this.paddleServ.open(this.paddleOptions);
  }

  checkEvent(data: PaddleEventCallbackData) {
    // Handle Event
    if (data.event === PADDLE_EVENT_TYPE.CheckoutComplete) {
      console.log('User has completed checkout!');
    } else {
      console.log(data.event);
    }
  }
}

3c) Use Available Options (see official docs for more)

For Directive: | Attribute/prop | input/output | optional/required | Type |Description | | --------------- | ------------ | ----------------- | -------- | -------------------------- | | vendor | input | required | number | Your vendor id | | product | input | required | number | Your product id | | title | input | optional | string | See docs | | message | input | optional | string | See docs | | coupon | input | optional | string | See docs | | email | input | optional | string | See docs | | onCheckoutEvent | output | optional | string | See docs |

For Service: all other options

4) Get Price

import { Component, AfterViewInit } from '@angular/core';

import {
  PaddleProductPrice,
  PaddleService,
  PaddleCheckoutOptions,
  PaddleEventCallbackData,
  PADDLE_EVENT_TYPE,
} from 'ngx-paddle-wrapper';

export class ComponentThatImplementsPaddle implements AfterViewInit {
  private paddleOptions: PaddleCheckoutOptions = {
    product: 654321,
    title: 'Test Title',
    message: 'Test Message',
    coupon: 'TEST',
    email: '[email protected]',
  };
  price: PaddleProductPrice;

  constructor(private paddleServ: PaddleService) {}

  // Create and open programatically once the library is loaded.
  ngAfterViewInit() {
    this.paddleServ.create({
      vendor: 123456,
      eventCallback: this.checkEvent,
    });
    // GET YOUR PRODUCTS PRICE:
    const numberOfProductsToPrice = 2;
    this.price = await this.paddleServ.getPrice(this.paddleOptions.product, numberOfProductsToPrice);
    // OR (quantity defaults to 1):
    this.price = await this.paddleServ.getPrice(this.paddleOptions.product);
  }
  [...]
}

How to contribute

Want to contribute to this project? Awesome! There are many ways you can contribute, see below.

Opening issues

Open an issue to report bugs or to propose new features. If you have a general usage question please note that this is just a wrapper and most questions should be directed to the actual library in Stack Overflow etc.

Proposing pull requests

Pull requests are more than welcome. Note that if you are going to propose drastic changes or new features, be sure to open an issue for discussion first, to make sure that your PR will be accepted before you spend effort coding it.

Todo

Tests!

Building ngx-paddle-wrapper

In the root directory of the repo:

ng build paddle --configuration production

Publishing

npm login
cd dist/paddle
npm publish --access public

Installing for local development

cd dist/paddle
npm pack

In destination project

npm install ../../../ngx-paddle/wrapper/dist/paddle/saschwarz-ngx-paddle-wrapper-1.0.0.tgz