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

react-native-inzori-applepay

v0.1.9

Published

React Native module to handle PassKit.

Downloads

25

Readme

react-native-inzori-applepay

React Native module to handle PassKit.

Installation

1. Install library from npm

npm install --save react-native-inzori-applepay

2. Link native code

You can link native code in the way you prefer:

If you received error jest-haste-map: Haste module naming collision: Duplicate module name: react-native, add lines below to your Podfile and reinstall pods.

target 'YourProjectTarget' do

+   rn_path = '../node_modules/react-native'
+   pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec"
+   pod 'React', path: rn_path

  pod 'react-native-inzori-applepay', path: '../node_modules/react-native-inzori-applepay'

end

+ post_install do |installer|
+   installer.pods_project.targets.each do |target|
+     if target.name == "React"
+       target.remove_from_project
+     end
+   end
+ end

react-native link

Run command below:

react-native link react-native-inzori-applepay

Usage

import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
import PassKit, { AddPassButton } from 'react-native-inzori-applepay'

type Props = {};
export default class App extends Component<Props> {
  constructor(props) {
    super(props);
    const self = this;
    self.state = {
      isLoading: true,
      canAdd: false,
      error: false
    };    

  }

  componentDidMount() {
    // Add event listener
    PassKit.addEventListener('addPassesViewControllerDidFinish', this.onAddPassesViewControllerDidFinish)
    PassKit.addEventListener('addingPassSucceeded', this.onAddingPassSucceeded)
    PassKit.addEventListener('addingPassFailed', this.onAddingPassFailed)
    PassKit.addEventListener('addToWalletViewHidden', this.onAddToWalletViewHidden)

    setTimeout( () => {
      PassKit.isAvailable()
      .then((result)=>{
        console.log('is available: ' + result);
        if (!result) {
          throw new Error('PassKit payments not available');        
        }
        PassKit.canAddCard('3543')
      })
      .then((result) => {
        console.log('can add: ' + result);
        if(!result) {
          throw new Error('PassKit payments can not add cards'); 
        }
        this.setState({
          isLoading: false, 
          canAdd: result
        });
      })
      .catch((error) => {
        console.log('error');
        console.log(error);
        this.setState({
          isLoading: false, 
          canAdd: false,
          error: error.message
        });
      });
    },2000);
  }

  // To keep the context of 'this'
  onAddPassesViewControllerDidFinish = this.onAddPassesViewControllerDidFinish.bind(this)
  onAddingPassSucceeded = this.onAddingPassSucceeded.bind(this)
  onAddingPassFailed = this.onAddingPassFailed.bind(this)
  onAddToWalletViewHidden = this.onAddToWalletViewHidden.bind(this)

  componentWillUnmount() {
    // Remove event listener
    PassKit.removeEventListener('addPassesViewControllerDidFinish', this.onAddPassesViewControllerDidFinish)
    PassKit.removeEventListener('addingPassSucceeded', this.onAddingPassSucceeded)
    PassKit.removeEventListener('addingPassFailed', this.onAddingPassFailed)
    PassKit.removeEventListener('addToWalletViewHidden', this.onAddToWalletViewHidden)


  }

  onAddPassesViewControllerDidFinish() {
    console.log('App - onAddPassesViewControllerDidFinish')
  }
  onAddingPassSucceeded() {
    console.log('App - onAddingPassSucceeded')
  }
  onAddingPassFailed(obj) {
    console.log('App - onAddingPassFailed')
    console.log(obj)
  }
  onAddToWalletViewHidden() {
    console.log('App - onAddToWalletViewHidden')
  }      

  render() {
    const { isLoading, canAdd, error } = this.state;
    
    if (isLoading) {
      console.log('isLoading: ' + isLoading);
      return <Text style={styles.headline}>Loading...</Text>;
    } else if (!canAdd) {
      return <Text style={styles.headline}>{error}</Text>;
    }
      
    return <AddPassButton
      style={styles.button}
      addPassButtonStyle={PassKit.AddPassButtonStyle.black}       
      onPress={() => { 
        PassKit.presentAddPaymentPassViewController({
          apiEndpoint: 'http://app-dev.akimbocard.com:3000/api/v2/card/wallet/passdata',
          cardholderName: 'fabian martinez',
          localizedDescription:'Something here',
          paymentNetwork: 2,
          primaryAccountSuffix: '3543',
          primaryAccountIdentifier:'',
          authorization:'Bearer AiZlAPCLRMOhNE299bKzdg',
          userName: null
        }).then((result) => {console.log('done');});
      }}
    />;



    
    
  }
}

const styles = StyleSheet.create({
  button:{
    width: PassKit.AddPassButtonWidth,
    height: PassKit.AddPassButtonHeight,
    marginTop: 200
  },
  headline: {
    textAlign: 'center', // <-- the magic
    fontWeight: 'bold',
    fontSize: 18,
    marginTop: 220
  }
});

Constants

  • PassKit.AddPassButtonStyle - The appearance of the add-pass button
    • black - A black button with white lettering
    • blackOutline - A black button with a light outline
  • PassKit.AddPassButtonWidth - Default add-pass button width
  • PassKit.AddPassButtonHeight - Default add-pass button height