Git Product home page Git Product logo

cordova-plugin-applepay's Introduction

cordova-plugin-applepay

This plugin is a basic implementation of Stripe and Apple Pay with the purpose of returning a useable stripe token.

Installation

  1. Follow the steps on https://stripe.com/docs/mobile/apple-pay to get your certs generated
  2. In your Xcode project, go to Capabilities and enable Apple Pay
  3. Install the plugin
cordova plugin add https://github.com/arzynik/cordova-plugin-applepay  \
	--variable STRIPE_PUBLISHABLE_KEY="pk_test_stripekey" \
	--variable APPLE_PAY_MERCHANT="merchant.apple.test"

Supported Platforms

  • iOS

Methods

  • ApplePay.getAllowsApplePay
  • ApplePay.setMerchantId
  • ApplePay.getStripeToken

ApplePay.getAllowsApplePay

Returns successfully if the device is setup for Apple Pay (correct software version, correct hardware & has card added).

ApplePay.getAllowsApplePay(successCallback, errorCallback);

ApplePay.setMerchantId

Set your Apple-given merchant ID. This overrides the value obtained from ApplePayMerchant in Info.plist.

ApplePay.setMerchantId(successCallback, errorCallback, 'merchant.apple.test');

ApplePay.getStripeToken

Request a stripe token for an Apple Pay card.

  • amount (string)
  • description (string)
  • currency (uppercase string)
ApplePay.getStripeToken(successCallback, errorCallback, amount, description, currency);
Response
{
	"token": "sometoken",
	"card": {
		"id": "cardid",
		"brand": "Visa",
		"last4": "1234",
		"exp_month": "01",
		"exp_year": "2050"
	}
}

Example

ApplePay.setMerchantId('merchant.apple.test');

ApplePay.getAllowsApplePay(function() {

	ApplePay.getStripeToken(function(token) {
		alert('Your token is: ' + token.id);
	}, function() {
		alert('Error getting payment info');
	}, '10.00', 'Delicious Cake', 'USD');

}, function() {
	alert('User does not have apple pay available');
});

cordova-plugin-applepay's People

Contributors

jackread avatar joelauge avatar spacedevin avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.