From fb4d2640c13de24d42a9ea0612c75f469052c52f Mon Sep 17 00:00:00 2001 From: Sultan Date: Sun, 14 Oct 2018 14:30:25 +0300 Subject: [PATCH] docs(apple-wallet): update example (#2755) * Add AppleWallet class interface * Update index.ts * Update index.ts * update readme --- .../plugins/apple-wallet/index.ts | 44 +++++++++++++++---- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/src/@ionic-native/plugins/apple-wallet/index.ts b/src/@ionic-native/plugins/apple-wallet/index.ts index 15b333975..466f0db9a 100644 --- a/src/@ionic-native/plugins/apple-wallet/index.ts +++ b/src/@ionic-native/plugins/apple-wallet/index.ts @@ -11,7 +11,7 @@ export interface CardData { cardholderName: string; primaryAccountNumberSuffix: string; localizedDescription?: string; - paymentNetwork: string; + paymentNetwork?: string; } /** @@ -26,20 +26,28 @@ export interface CardData { * * constructor(private appleWallet: AppleWallet) { } * + * * ... * * + * // Simple call to check whether the app can add cards to Apple Pay. * this.appleWallet.available() * .then((res) => { - * // res is a boolean value, either true or false - * console.log("Is Apple Wallet available? ", res); + * // Apple Wallet is enabled and a supported card is setup. Expect: + * // boolean value, true or false * }) * .catch((message) => { - * console.error("ERROR AVAILBLE>> ", message); + * // Error message while trying to know if device is able to add to wallet * }); * + * * ... * + * + * // 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. + * * let data: cardData = { * cardholderName: 'Test User', * primaryAccountNumberSuffix: '1234', @@ -49,14 +57,32 @@ export interface CardData { * * this.appleWallet.startAddPaymentPass(data: cardData) * .then((res) => { - * console.log("startAddPaymentPass success response ", res); + * // User proceed and successfully asked to add card to his wallet + * // Use the callback response JSON payload to complete addition process * }) * .catch((err) => { - * console.error("startAddPaymentPass ERROR response", 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 + * + * * ... * + * * let data: encryptedCardData = { * activationData: 'encoded Base64 activationData from your server', * encryptedPassData: 'encoded Base64 encryptedPassData from your server', @@ -65,10 +91,12 @@ export interface CardData { * * this.appleWallet.encryptedCardData(data: encryptedCardData) * .then((res) => { - * console.log("completeAddCardToAppleWallet success response ", res); + * // callback success response means card has been added successfully, + * // PKAddPaymentPassViewController will be dismissed * }) * .catch((err) => { - * console.error("completeAddCardToAppleWallet ERROR response", err); + * // Error and can not add the card, or something wrong happend + * // PKAddPaymentPassViewController will be dismissed * }); * * ```