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

nativescript-stripe-sdk

v1.2.0

Published

NativeScript implementation of Stripe's iOS SDK - 11.3.0

Downloads

10

Readme

NativeScript Stripe-SDK

This repo is based on @Osei Fortune's nativescript-stripe. Perfect job, Sir!

IMPORTANT: Highly recomend using @Osei Fortune's nativescript-stripe

The purpose of this plugin is to add some specific functionalities required by the app I work on. I have also wanted to use official nativescript-plugin-seed

Implemented for iOS only - this plugin uses 11.3 Stripe's SDK.

Installation

tns plugin add nativescript-stripe-sdk

Usage in Android

Set API key

Add this to the main *.module.ts file (app.module.ts)

import * as application from 'tns-core-modules/application';
import * as platform from 'tns-core-modules/platform';

const stripeSdk = require('nativescript-stripe-sdk');

application.on(application.launchEvent, () => {
  if (platform.isIOS) {
    stripeSdk.StripeSdk.setApiKey('yourAPIKey');
  }
});

Usage in UI

<StripePaymentCardTextField
  (paymentCardTextFieldDidChange)="onPaymentCardTextFieldDidChange($event)">
</StripePaymentCardTextField>

Example paymentCardTextFieldDidChange handler

import { StripeSdk } from 'nativescript-stripe-sdk';

...

onPaymentCardTextFieldDidChange(payload) {
  const isValid = StripeSdk.validateCard(payload.cardParams);

  if (isValid) {
    StripeSdk
      .createToken(payload.cardParams)
      .then(token => {
        console.log('Created token: ', token.toString());
      })
      .catch((error: Error) => {
        console.error('Create token error: ', error);
      });
  }
}

Usage in vanilla NS

IMPORTANT: SDK API key needs to be set on app startup

import { StripeSdk } from 'nativescript-stripe-sdk';

application.on(application.launchEvent, () => {
    if (platform.isIOS) {
        StripeSdk.setApiKey('pk_test_u6EwgR7lHu8YKOqO5AOynNVj');
    }
});

Usage in UI

<ui:StripePaymentCardTextField
  expDate="{{ date }}"
  number="{{ number }}"
  cvc="{{ cvc }}"/>
 <ui:StripePaymentCardTextField
  paymentCardTextFieldDidChange="{{ callbackFn }}"/>

Check if given CC is valid (card of STPCardParams type)

import { StripeSdk } from 'nativescript-stripe-sdk';

const isValid = StripeSdk.validateCard(card);

Generate stripe token

IMPORTANT: valid stripe API key needs to be set on app startup

import { StripeSdk } from 'nativescript-stripe-sdk';

StripeSdk
   .createToken(card.cardParams)
   .then(token => { console.log(token); })
   .catch(error => { console.error(error); });

API

In XML: | Property | Default | Description | | --- | --- | --- | | expDate | not set | CC expiration date - typeof Date | | number | not set | CC number - typeof string | | cvc | not set | CC expiration date - typeof string |

Running the demo app

git clone [email protected]:piotrilski/nativescript-stripe-sdk.git
cd src/
npm run setup
npm run demo.ios

Running angular demo

git clone [email protected]:piotrilski/nativescript-stripe-sdk.git
cd src/
npm run setup
npm run demo.angular.ios

License

Apache License Version 2.0, January 2004