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

cordova-plugin-dynamic-applepay-stripe

v1.0.5

Published

A Cordova plugin to provide Apple Pay functionality with Stripe integration. Allowing dynamic configurable use of merchant id and Stripe publishable key.

Downloads

4

Readme

Cordova Apple Pay Plugin

A dependency free Cordova plugin to provide Apple Pay functionality integrated with Stripe Framework.

Updated to provide additional data access to the plugin, test calls, and compatibility with newer versions of Cordova. Uses a Promise based interface in JavaScript.

Specifically created this version to provide methods to dynamically change the merchant id or stripe publishable key.

This plugin is integrated to Stripe, if you want an integrated-less plugin you can use cordova-plugin-applepay

Installation

$ cordova plugin add --save cordova-plugin-dynamic-applepay-stripe

Install the plugin using Cordova 6 and above, which is based on npm. The plugin exposes the window.ApplePay global in the browser.

Compatibility

  • iOS 9 (using newer iOS9 only APIs)
  • iOS 8 (using initial Apple Pay APIs from iOS8 that are deprecated in iOS9)
  • iOS 7 and older (no Apple Pay, but doesn't affect code)
  • Requires Cordova 6 running at least iOS Platform 4.1.1

Methods

The methods available all return promises, or accept success and error callbacks.

  • ApplePay.setMerchantId
  • ApplePay.setPublishableKey
  • ApplePay.canMakePayments
  • ApplePay.makePaymentRequest
  • ApplePay.completeLastTransaction

ApplePay.setMerchantId

Pass in as a string the desired merchantId for use in plugin. Will return a promise when function completes.

ApplePay.setPublishableKey

Pass in your Stripe publishable api key for use in plugin. Will return a promise when function completes.

ApplePay.canMakePayments

Detects if the current device supports Apple Pay and has any capable cards registered.

ApplePay.canMakePayments()
    .then((message) => {
        // Apple Pay is enabled and a supported card is setup. Expect:
        // 'This device can make payments and has a supported card'
    })
    .catch((message) => {
        // There is an issue, examine the message to see the details, will be:
        // 'This device cannot make payments.''
        // 'This device can make payments but has no supported cards'
    });

If in your catch you get the message This device can make payments but has no supported cards - you can decide if you want to handle this by showing the 'Setup Apple Pay' buttons instead of the normal 'Pay with Apple Bay' buttons as per the Apple Guidelines.

ApplePay.makePaymentRequest

Request a payment with Apple Pay, returns a Promise that once resolved, has the payment token. In your order, you will set parameters like the merchant ID, country, address requirements, order information etc. See a full example of an order at the end of this document.

ApplePay.makePaymentRequest(order)
    .then((paymentResponse) => {
        // User approved payment, token generated.
    })
    .catch((message) => {
        // Error or user cancelled.
    });

Example Response

The paymentResponse is an object with the keys that contain the token itself, this is what you'll need to pass along to your payment processor. Also, if you requested billing or shipping addresses, this information is also included.

{
    "shippingAddressState": "London",
    "shippingCountry": "United Kingdom",
    "shippingISOCountryCode": "gb",
    "billingAddressCity": "London",
    "billingISOCountryCode": "gb",
    "shippingNameLast": "Name",
    "paymentData": "<BASE64 ENCODED TOKEN WILL APPEAR HERE>",
    "stripeToken": "<STRIPE TOKEN>",
    "shippingNameFirst": "First",
    "billingAddressState": "London",
    "billingAddressStreet": "Street 1\n",
    "billingNameFirst": "First",
    "billingPostalCode": "POST CODE",
    "shippingPostalCode": "POST CODE",
    "shippingAddressStreet": "Street Line 1\nStreet Line 2",
    "billingNameLast": "NAME",
    "billingSupplementarySubLocality": "",
    "billingCountry": "United Kingdom",
    "shippingAddressCity": "London",
    "shippingSupplementarySubLocality": "",
    "transactionIdentifier": "Simulated Identifier"
}

ApplePay.completeLastTransaction

Once the makePaymentRequest has been resolved successfully, the device will be waiting for a completion event. This means, that the application must proceed with the token authorisation and return a success, failure, or other validation error. Once this has been passed back, the Apple Pay sheet will be dismissed via an animation.

License

This project is licensed under GNU General Public License v3.0.

It is based on the work of Sam Kelleher. It is an alteration of an older project originally started by @jbeuckm and followed by David Avellaneda @davsket https://github.com/monoku/cordova-plugin-applepay-stripe/commits?author=davsket