Socket
Book a DemoInstallSign in
Socket

capacitor-3-apple-pay

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

capacitor-3-apple-pay

Capacitor 3 plugin to implement payment function via Apple Pay

1.0.8
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

Capacitor 3 plugin to implement payment function via Apple Pay

The plugin is under development!

Install

npm i capacitor-3-apple-pay

npx cap sync ios
import {ApplePay, PaymentRequest} from 'capacitor-3-apple-pay';

Can make payments

const { isPayment } = await ApplePay.canMakePayments();

// OR

const { isPayment } = await ApplePay.canMakePayments({
  usingNetworks: [ ... ];
  capabilities: [ ... ];
});

if (isPayment) {
    // ... Request payment
}

Make payment request

See docs: https://developer.apple.com/documentation/passkit/pkpaymentrequest

const paymentRequest: PaymentRequest = {
    // Requiered
    merchantIdentifier: "com.apple.testing",
    paymentSummaryItems: [
      {
        label: 'order #1001',
        amount: 120.57,
        // type: 'pending' // or default: final
      },
      // ...
    ],

    // Outher
    countryCode: 'US',
    currencyCode: 'USD',

    supportedNetworks: [
      'mastercard', 'visa', 'amex',
      'quicPay', 'chinaUnionPay', 'discover',
      'interac', 'privateLabel'
    ],

    merchantCapabilities: [
      'capability3DS', 'capabilityCredit',
      'capabilityDebit', 'capabilityEMV'
    ],

    requiredShippingContactFields: [
      'emailAddress', 'name', 'phoneNumber',
      'phoneticName', 'postalAddress'
    ],

    requiredBillingContactFields: [
      'emailAddress', 'name', 'phoneNumber',
      'phoneticName', 'postalAddress'
    ],
    
    // supportedCountries: [ ... ],
    // billingContact: PaymentContact,
    // shippingContact: PaymentContact,
};

try {
  // See: https://developer.apple.com/documentation/passkit/pkpaymenttoken
  const { token } = await ApplePay.makePaymentRequest(paymentRequest);

  try {
    // INFO: Check and completion of the payment by your processing center
    await MyPaymentProvider.authorize(token.paymentData);

    ApplePay.completeLastTransaction({ status: 'success' });
  } catch {
    ApplePay.completeLastTransaction({ status: 'error' });
  }
} catch (e) {
  if (e.message === 'canceled') {
    // Payment widget was closed by user
  }
}

Keywords

capacitor

FAQs

Package last updated on 02 Jun 2021

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.