Socket
Socket
Sign inDemoInstall

apple-pay

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    apple-pay

Wrapper for working with Apple Pay payments


Version published
Weekly downloads
43
increased by86.96%
Maintainers
1
Install size
10.1 kB
Created
Weekly downloads
 

Readme

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

Last updated on 27 Jan 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc