Socket
Socket
Sign inDemoInstall

apple-pay-js-stubs

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apple-pay-js-stubs - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

.travis.yml

5

package.json
{
"name": "apple-pay-js-stubs",
"version": "1.0.2",
"version": "1.0.3",
"description": "The Apple Pay JS Stubs provide a stubbed implementation of the ApplePay JS framework allowing you to acceptance test your Apple Pay for the Web code without requiring Safari, or an iPhone with iOS 10",
"main": "src/apple-pay-js-stubs.js",
"scripts": {
"test": "karma start"
"test": "node_modules/.bin/karma start test/karma.conf.js --single-run"
},

@@ -18,2 +18,3 @@ "author": "Indiegogo Inc.",

"karma-chrome-launcher": "^1.0.1",
"karma-firefox-launcher": "^1.0.0",
"karma-mocha": "^1.1.1",

@@ -20,0 +21,0 @@ "karma-sinon": "^1.0.5",

14

README.md
# apple-pay-js-stubs
The Apple Pay JS Stubs provide a stubbed implementation of the ApplePay JS framework allowing you to acceptance test your Apple Pay for the Web code without requiring Safari, or an iPhone with iOS 10
[![Build Status](https://travis-ci.org/indiegogo/apple-pay-js-stubs.svg?branch=master)](https://travis-ci.org/indiegogo/apple-pay-js-stubs)
This stubbed implementation substitutes the ApplePay JS API normally provided by the Safari browser on iOS 10, and macOS Sierra with a stubbed javascript implementation.

@@ -11,3 +13,7 @@

# Requirements
- ECMAScript 6 complient browser (tested in Chrome)
- ECMAScript 6 complient browser
- Tested in:
- Chrome 51.0.2704.103 (64-bit)
- Firefox 48.0
- Safari Version 9.1 (11601.5.17.1)

@@ -28,3 +34,3 @@ # Installation and Usage

In order for apple-pay-js-stubs.js to be available when your acceptance tests run, you'll need to load javascript file on the page in your website which normally interacts with the window.ApplePaySession object.
In order for apple-pay-js-stubs.js to be available when your acceptance tests run, you'll need to load the javascript file on the page in your website which normally interacts with the window.ApplePaySession object.

@@ -47,7 +53,7 @@ **Note: You should only do this when you're running your automated acceptance tests to avoid conflicting with Safari in your production environment**

Note: This approach will result in a delay in `window.ApplePaySession` which may not be the same as on the real device.
Note: This approach will result in a delay in `window.ApplePaySession` being available which may not be the same as on the real ApplePay supporting browser.
## Step 3: Configure the Stubs for your current test
For each specific test utilizing ApplePay and the apple-pay-js-stubs, before executing your tests you need to configure the ApplePaySessionStubs class(stored in window.ApplePaySession) so that it performs the appropriate call backs to simulate the users, and ApplePay JS's normal behaviour for a specific scenario.
Each test using ApplePay/apple-pay-js-stubs, will need to configure the ApplePaySessionStubs class (stored in window.ApplePaySession) before executing the test. This is how you configure the call backs to simulate the users, and ApplePay JS's normal behaviour for a specific scenario.

@@ -54,0 +60,0 @@ You can configure this by running the following javascript code on you page before each test:

@@ -1,3 +0,30 @@

class ApplePaySessionStub {
// Based on solution by naomik here http://stackoverflow.com/a/24216547
class Emitter {
constructor() {
var delegate = document.createDocumentFragment();
[
'addEventListener',
'dispatchEvent',
'removeEventListener'
].forEach(f =>
this[f] = (...xs) => delegate[f](...xs)
)
}
}
class ApplePayPaymentAuthorizedEvent extends Event {
constructor(payment) {
super("paymentauthorized");
this._payment = payment;
}
get payment() {
return this._payment;
}
}
window.ApplePayPaymentAuthorizedEvent = ApplePayPaymentAuthorizedEvent;
class ApplePaySessionStub extends Emitter {
constructor(version, paymentRequest) {
super();
this.version = version;

@@ -52,5 +79,9 @@ this.request = paymentRequest;

begin() {
this._onvalidatemerchant(
{validationURL: 'https://apple-pay-gateway-cert.apple.com/paymentservices/startSession'}
);
if (this._onvalidatemerchant) {
this._onvalidatemerchant(
{validationURL: 'https://apple-pay-gateway-cert.apple.com/paymentservices/startSession'}
);
} else {
this.completeMerchantValidation();
}
}

@@ -79,3 +110,2 @@

window.ApplePaySession = ApplePaySessionStub;
//export default ApplePaySessionStub;
window.ApplePaySession = ApplePaySessionStub;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc