Skip to main content

Apple Pay

A dependency free Cordova plugin to provide Apple Pay functionality.

https://github.com/samkelleher/cordova-plugin-applepay

Stuck on a Cordova issue?

Don't waste precious time on plugin issues.

If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic’s experts offer premium advisory services for both community plugins and premier plugins.

Installation#

$ npm install cordova-plugin-applepay $ npm install @ionic-native/apple-pay $ ionic cap sync

Supported Platforms#

  • iOS

Usage#

React#

Learn more about using Ionic Native components in React

Angular#

import { ApplePay } from '@ionic-native/apple-pay/ngx';

constructor(private applePay: ApplePay) { }
...async applePay() {  // This block is optional -- only if you need to update order items/shipping  // methods in response to shipping method selections  this.applePay.startListeningForShippingContactSelection()    .subscribe(async selection => {      try {        await this.applePay.updateItemsAndShippingMethods({          items: getFromSelection(selection),          shippingMethods: getFromSelection(selection),        });      }      catch {        // handle update items error      }    });
  try {    const applePayTransaction = await this.applePay.makePaymentRequest({      items,      shippingMethods,      merchantIdentifier,      currencyCode,      countryCode,      billingAddressRequirement: ['name', 'email', 'phone'],      shippingAddressRequirement: 'none',      shippingType: 'shipping'    });
    const transactionStatus = await completeTransactionWithMerchant(applePayTransaction);    await this.applePay.completeLastTransaction(transactionStatus);  } catch {    // handle payment request error    // Can also handle stop complete transaction but these should normally not occur  }
  // only if you started listening before  await this.applePay.stopListeningForShippingContactSelection();}