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

@globy-app/zettle

v0.0.2

Published

Adds capabilities to use Zettle card readers and process payments with them.

Downloads

152

Readme

@globy-app/zettle

Adds capabilities to use Zettle card readers and process payments with them.

Inspiration attribution

This plugin took great inspiration from orestis-z/capacitor-zettle.

Install

npm install @globy-app/zettle
npx cap sync

Setup the SDK

IOS

Install the ZettleSDK pod by following the official Zettle guide.

Also make sure the you follow the steps on configuring permissions and plist.

Android

To install the Zettle SDK for android in the project, one must provide a github token so the SDK can be downloaded. How you do that is up to you. As this is a secret token, a secret manager is recommended to prevent the need of comitting a Github token to your repository.

For this to work, you need to paste the following snippet in the build.gradle file (located at android/app/build.gradle, so in your capacitor android app source files):

repositories {
    ...
    maven {
        url = uri("https://maven.pkg.github.com/iZettle/sdk-android")
        credentials(HttpHeaderCredentials) {
            name "Authorization"
            value "Bearer xxx" // More about auth tokens https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line
        }
        authentication {
            header(HttpHeaderAuthentication)
        }
    }
    ...
}

allprojects {
    repositories {
        ...
        maven {
            url = uri("https://maven.pkg.github.com/iZettle/sdk-android")
            credentials(HttpHeaderCredentials) {
                name "Authorization"
                value "Bearer xxx" // More about auth tokens https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line
            }
            authentication {
                header(HttpHeaderAuthentication)
            }
        }
        ...
    }
}

You also need to add the OAuthActivity to your app's manifest. See the Zettle SDK documentation for the exact steps. Make sure the redirect url is correct and matches your configuration.

Configuring the plugin

Zettle needs to know a few things about your application to work properly. If you have received a Zettle developer account, you can also add a client. This should provide you with all the credentials for a SDK application.

In your capacitor capacitor make sure to add the following configuration:

{
  "plugins": {
    "Zettle": {
      "clientID": "your-client-id",
      "scheme": "your-scheme",
      "host": "your-host"
    }
  }
}

API

initialize(...)

initialize({ developermode, }: { developermode: boolean | undefined; }) => Promise<void>

Initializes the Zettle SDK. Make sure to call this method before calling any other methods. Calling this method a second time has no effect.

| Param | Type | Description | | --------- | ---------------------------------------- | ---------------------- | | __0 | { developermode: boolean; } | Enables developer mode |


logout()

logout() => Promise<void>

Logs out the current user. The next time the user tries to make a payment they will have to login again.


openSettings()

openSettings() => Promise<void>

Opens the Zettle settings screen. Allowing the user to login and use in app pairing to connect to a card reader.


chargeAmount(...)

chargeAmount({ amount, reference, }: { amount: number; reference: string; }) => Promise<ZettlePaymentInfo | { success: false; }>

Starts a payment. This will open the Zettle payment screen. It will start a payment for the specified amount.

| Param | Type | Description | | --------- | --------------------------------------------------- | --------------------------------- | | __0 | { amount: number; reference: string; } | The amount to charge the customer |

Returns: Promise<ZettlePaymentInfo | { success: false; }>


Interfaces

ZettlePaymentInfo

| Prop | Type | | -------------------------- | ------------------- | | success | true | | amount | number | | gratuityAmount | number | | referenceNumber | string | | entryMode | string | | obfuscatedPan | string | | panHash | string | | transactionId | string | | cardBrand | string | | authorizationCode | string | | AID | string | | TSI | string | | TVR | string | | applicationName | string | | numberOfInstallments | number | | installmentAmount | number |