Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apple-pay

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apple-pay

Wrapper for working with Apple Pay payments

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
54
increased by1.89%
Maintainers
1
Weekly downloads
 
Created
Source

ApplePay

Wrapper for working with Apple Pay payments

nodenpm version

npm downloadsnpm

Why ?

Simplifies interaction with native ApplePay API. Support:

  • Auto detect supportsVersion
  • Filters unsupported supportedNetworks version based
  • Static getter method isPaymentAvailable

Install

npm i -S apple-pay

Note: This project is compatible with node v14+

Usage

import ApplePay, { STATUS_SUCCESS, STATUS_FAILURE } from 'apple-pay';

if (ApplePay.isPaymentAvailable) {
  const paymentRequest = {
    total: {
      label: 'Merchant name',
      amount: '10.0'
    },
    countryCode: 'US',
    currencyCode: 'USD',
    supportedCountries: ['US'],
    merchantCapabilities: ['supports3DS'],
    supportedNetworks: ['amex', 'discover']
  }

  const session = new ApplePay({
    onValidateMerchant,
    onPaymentAuthorized,
    paymentRequest
  });

  async function onValidateMerchant(event) {
    const body = JSON.stringify({
      validationURL: event.validationURL
    });

    const response = await fetch('you/validate/merchant/url', { body });
    const json = await response.json();

    session.completeMerchantValidation(json);
  }

  async function onPaymentAuthorized(event) {
    const body = JSON.stringify({
      paymentToken: event.payment.token
    });

    const response = await fetch('you/payment/authorized/url', { body });
    const status = response.ok ? STATUS_SUCCESS : STATUS_FAILURE;

    session.completePayment(status);
  }
}

Keywords

FAQs

Package last updated on 27 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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