cordova-apple-wallet-ng
v1.3.1
Published
This plugin allows you to add passes and credit/debit cards to Apple Wallet
Downloads
68
Maintainers
Readme
cordova-apple-wallet-ng
This plugin provides support for adding your credit/debit cards to Apple Wallet
Changelog
- v1.3.1: Added err handling for nil graph response
- v1.3.0: Adds graphRequest
- v1.2.0: Adds checkPairedDevicesBySuffix
- v1.1.1: Update complete handler
- v1.1.0: Changed wrapped to ephemeralPublicKey
- v1.0.3: Chore: fix name.
- v1.0.2: Chore: fix name.
- v1.0.1: Feature: adds ECC_V2 encryption scheme.
Important
Adding payment passes requires a special entitlement issued by Apple. Your app must include this entitlement before you can use this class. For more information on requesting this entitlement, see the Card Issuers section at developer.apple.com/apple-pay/.
Installation
cordova plugin add cordova-apple-wallet-ng --save
Supported Platforms
- iOS
Usage
Ionic 3 and above
In order to use it with Ionic 3, please follow this instructions
Cordova
In order to use it with normal cordova based project, please define a global variable, so that you can use it without lint errors
var AppleWallet;
Example
Availability
Simple call to check whether the app can add cards to Apple Pay.
AppleWallet.available()
.then((res) => {
// Apple Wallet is enabled and a supported card is setup. Expect:
// boolean value, true or false
})
.catch((message) => {
console.error("ERROR AVAILBLE>> ", message);
});
Start Adding card
Simple call with the configuration data needed to instantiate a new PKAddPaymentPassViewController object.
The encryption scheme, cardholder name, and primary account suffix are required for configuration. The configuration information is used for setup and display only. It should not contain any sensitive information.
In order to get testing data check this Apple Sandbox
let data = {
cardholderName: 'Test User',
primaryAccountNumberSuffix: '1234',
localizedDescription: 'Description of payment card',
paymentNetwork: 'VISA'
}
AppleWallet.startAddPaymentPass(data)
.then((res) => {
// User proceed and successfully asked to add card to his wallet
// Use the callback response JSON payload to complete addition process
})
.catch((err) => {
// Error or user cancelled.
});
You should expect the callback success response to be as follow
{
data: {
"certificateSubCA":"Base64 string represents certificateSubCA",
"certificateLeaf":"Base64 string represents certificateLeaf"
"nonce":"Base64 string represents nonce",
"nonceSignature":"Base64 string represents nonceSignature",
}
}
This method provides the data needed to create an add payment request. Pass the certificate chain to the issuer server. The server returns an encrypted JSON file containing the card data. After you receive the encrypted data, pass it to completeAddPaymentPass
method
For more information, please check Apple docs from here
Complete adding card
Simple call contains the card data needed to add a card to Apple Pay.
activationData
: The request’s activation data.encryptedPassData
: An encrypted JSON file containing the sensitive information needed to add a card to Apple Pay.ephemeralPublicKey
The ephemeral public key used by elliptic curve cryptography (ECC). orwrappedKey
if you are using RSA
let encryptedData = {
activationData: "encoded Base64 activationData from your server",
encryptedPassData: "encoded Base64 encryptedPassData from your server",
wrappedKey: "encoded Base64 wrappedKey from your server"
}
AppleWallet.completeAddPaymentPass(encryptedData)
.then((res) => {
// callback success response means card has been added successfully,
// PKAddPaymentPassViewController will be dismissed
})
.catch((err) => {
// Error and can not add the card, or something wrong happend
// PKAddPaymentPassViewController will be dismissed
});
Contribute
Please support us by giving advice on how to apply best practice to Objective-C native code.
License
MIT
Credits
Made with ❤️ by Hatem. Follow me on Twitter to get the latest news first! I will be happy to receive your feedback via Email ! We're always happy to hear your feedback. Enjoy!
░░░░░░░░░░░░░▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
░░░░░░░░░░█░░░░░░▀█▄▀▄▀██████░░░▀█▄▀▄▀██████
░░░░░░░░ ░░░░░░░░░░▀█▄█▄███▀░░░░░░▀█▄█▄███▀░
All copyrights reserved © 2018 | TOmas™ Inc.