@types/applepayjs
Advanced tools
Comparing version 1.0.4 to 3.0.0
@@ -1,14 +0,14 @@ | ||
// Type definitions for Apple Pay JS 1.0 | ||
// Type definitions for Apple Pay JS 3.0 | ||
// Project: https://developer.apple.com/reference/applepayjs | ||
// Definitions by: Martin Costello <https://martincostello.com/> | ||
// Definitions by: Martin Costello <https://github.com/martincostello> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
/** | ||
* A session object for managing the payment process on the web. | ||
* ApplePaySession is the entry point for Apple Pay on the web. | ||
*/ | ||
declare class ApplePaySession extends EventTarget { | ||
/** | ||
* Creates a new instance of the ApplePaySession class. | ||
* @param version - The version of the ApplePay JS API you are using. | ||
* @param paymentRequest - An ApplePayPaymentRequest object that contains the information that is displayed on the Apple Pay payment sheet. | ||
* The entry point for Apple Pay on the web. | ||
* @param version - The version number of the ApplePay JS API you are using. The current API version number is 3. | ||
* @param paymentRequest - An ApplePayPaymentRequest object that contains the information to be displayed on the Apple Pay payment sheet. | ||
*/ | ||
@@ -18,3 +18,3 @@ constructor(version: number, paymentRequest: ApplePayJS.ApplePayPaymentRequest); | ||
/** | ||
* A callback function that is automatically called when the payment UI is dismissed with an error. | ||
* A callback function that is automatically called when the payment UI is dismissed. | ||
*/ | ||
@@ -24,3 +24,3 @@ oncancel: (event: ApplePayJS.Event) => void; | ||
/** | ||
* A callback function that is automatically called when the user has authorized the Apple Pay payment, typically via TouchID. | ||
* A callback function that is automatically called when the user has authorized the Apple Pay payment with Touch ID, Face ID, or passcode. | ||
*/ | ||
@@ -50,3 +50,3 @@ onpaymentauthorized: (event: ApplePayJS.ApplePayPaymentAuthorizedEvent) => void; | ||
/** | ||
* Indicates whether or not the device supports Apple Pay. | ||
* Indicates whether the device supports Apple Pay. | ||
* @returns true if the device supports making payments with Apple Pay; otherwise, false. | ||
@@ -57,5 +57,5 @@ */ | ||
/** | ||
* Indicates whether or not the device supports Apple Pay and if the user has an active card in Wallet. | ||
* @param merchantIdentifier - The merchant ID received when the merchant enrolled in Apple Pay. | ||
* @returns true if the device supports Apple Pay and there is at least one active card in Wallet; otherwise, false. | ||
* Indicates whether the device supports Apple Pay and whether the user has an active card in Wallet. | ||
* @param merchantIdentifier - The merchant ID created when the merchant enrolled in Apple Pay. | ||
* @returns true if the device supports Apple Pay and there is at least one active card in Wallet that is qualified for payments on the web; otherwise, false. | ||
*/ | ||
@@ -66,3 +66,3 @@ static canMakePaymentsWithActiveCard(merchantIdentifier: string): Promise<boolean>; | ||
* Displays the Set up Apple Pay button. | ||
* @param merchantIdentifier - The merchant ID received when the merchant enrolled in Apple Pay. | ||
* @param merchantIdentifier - The merchant ID created when the merchant enrolled in Apple Pay. | ||
* @returns A boolean value indicating whether setup was successful. | ||
@@ -73,4 +73,4 @@ */ | ||
/** | ||
* Verifies if a web browser supports a given Apple Pay JS API version. | ||
* @param version - A number representing the Apple Pay JS API version being checked. The initial version is 1. | ||
* Verifies whether a web browser supports a given Apple Pay JS API version. | ||
* @param version - A number representing the Apple Pay JS API version being checked. The initial version is 1. The latest version is 3. | ||
* @returns A boolean value indicating whether the web browser supports the given API version. Returns false if the web browser does not support the specified version. | ||
@@ -91,3 +91,3 @@ */ | ||
/** | ||
* Call after the merchant has been validated. | ||
* Completes the validation for a merchant session. | ||
* @param merchantSession - An opaque message session object. | ||
@@ -98,9 +98,10 @@ */ | ||
/** | ||
* Call when a payment has been authorized. | ||
* @param status - The status of the payment. | ||
* Completes the payment authorization with a result. | ||
* @param result - The status of the payment, whether it succeeded or failed for Apple Pay JS versions 1 and 2, | ||
* or the result of the payment authorization, including its status and list of errors for Apple Pay JS version 3. | ||
*/ | ||
completePayment(status: number): void; | ||
completePayment(result: number | ApplePayJS.ApplePayPaymentAuthorizationResult): void; | ||
/** | ||
* Call after a payment method has been selected. | ||
* Call after a payment method has been selected for Apple Pay JS versions 1 and 2. | ||
* @param newTotal - An ApplePayLineItem dictionary representing the total price for the purchase. | ||
@@ -112,3 +113,9 @@ * @param newLineItems - A sequence of ApplePayLineItem dictionaries. | ||
/** | ||
* Call after a shipping contact has been selected. | ||
* Completes the selection of a payment method with an update for Apple Pay JS version 3. | ||
* @param update - The updated payment method. | ||
*/ | ||
completePaymentMethodSelection(update: ApplePayJS.ApplePayPaymentMethodUpdate): void; | ||
/** | ||
* Completes the selection of a shipping contact with an update for Apple Pay JS versions 1 and 2. | ||
* @param status - The status of the shipping contact update. | ||
@@ -126,3 +133,9 @@ * @param newShippingMethods - A sequence of ApplePayShippingMethod dictionaries. | ||
/** | ||
* Call after the shipping method has been selected. | ||
* Completes the selection of a shipping contact with an update for Apple Pay JS version 3. | ||
* @param update - The updated shipping contact. | ||
*/ | ||
completeShippingContactSelection(update: ApplePayJS.ApplePayShippingContactUpdate): void; | ||
/** | ||
* Call after the shipping method has been selected for Apple Pay JS versions 1 and 2. | ||
* @param status - The status of the shipping method update. | ||
@@ -135,2 +148,8 @@ * @param newTotal - An ApplePayLineItem dictionary representing the total price for the purchase. | ||
/** | ||
* Completes the selection of a shipping method with an update for Apple Pay JS version 3. | ||
* @param update - The updated shipping method. | ||
*/ | ||
completeShippingMethodSelection(update: ApplePayJS.ApplePayShippingMethodUpdate): void; | ||
/** | ||
* The requested action succeeded. | ||
@@ -178,2 +197,74 @@ */ | ||
/** | ||
* Field names used for requesting contact information in a payment request. | ||
*/ | ||
type ApplePayContactField = | ||
'email' | | ||
'name' | | ||
'phone' | | ||
'postalAddress' | | ||
'phoneticName'; | ||
/** | ||
* A customizable error type that you create to indicate problems with the address or contact information on an Apple Pay sheet. | ||
*/ | ||
interface ApplePayError { | ||
/** | ||
* The error code for this instance. | ||
*/ | ||
code: ApplePayErrorCode; | ||
/** | ||
* The name of the field that contains the error. | ||
*/ | ||
contactField?: ApplePayErrorContactField; | ||
/** | ||
* A localized, user-facing string that describes the error. | ||
*/ | ||
message: string; | ||
} | ||
/** | ||
* The error code that indicates whether an error on the payment sheet is for shipping or billing information, or for another kind of error. | ||
*/ | ||
type ApplePayErrorCode = | ||
/** | ||
* Shipping address or contact information is invalid or missing. | ||
*/ | ||
'shippingContactInvalid' | | ||
/** | ||
* Billing address information is invalid or missing. | ||
*/ | ||
'billingContactInvalid' | | ||
/** | ||
* The merchant cannot provide service to the shipping address (for example, can't deliver to a P.O. Box). | ||
*/ | ||
'addressUnserviceable' | | ||
/** | ||
* An unknown but nonfatal error occurred during payment processing. The user can attempt authorization again. | ||
*/ | ||
'unknown'; | ||
/** | ||
* Names of the fields in the shipping or billing contact information, used to locate errors in the payment sheet. | ||
*/ | ||
type ApplePayErrorContactField = | ||
'phoneNumber' | | ||
'emailAddress' | | ||
'name' | | ||
'phoneticName' | | ||
'postalAddress' | | ||
'addressLines' | | ||
'locality' | | ||
'subLocality' | | ||
'postalCode' | | ||
'administrativeArea' | | ||
'subAdministrativeArea' | | ||
'country' | | ||
'countryCode'; | ||
/** | ||
* Defines a line item in a payment request - for example, total, tax, discount, or grand total. | ||
@@ -195,6 +286,44 @@ */ | ||
*/ | ||
type?: string; | ||
type?: ApplePayLineItemType; | ||
} | ||
/** | ||
* A type that indicates whether a line item is final or pending. | ||
*/ | ||
type ApplePayLineItemType = | ||
/** | ||
* A line item representing the known, final cost. | ||
*/ | ||
'final' | | ||
/** | ||
* A line item representing an estimated or unknown cost. | ||
*/ | ||
'pending'; | ||
/** | ||
* The payment capabilities supported by the merchant. | ||
*/ | ||
type ApplePayMerchantCapability = | ||
/** | ||
* Required. This value must be supplied. | ||
*/ | ||
'supports3DS' | | ||
/** | ||
* Include this value only if you support China Union Pay transactions. | ||
*/ | ||
'supportsEMV' | | ||
/** | ||
* Optional. If present, only transactions that are categorized as credit cards are allowed. | ||
*/ | ||
'supportsCredit' | | ||
/** | ||
* Optional. If present, only transactions that are categorized as debit cards are allowed. | ||
*/ | ||
'supportsDebit'; | ||
/** | ||
* Represents the result of authorizing a payment request and contains encrypted payment information. | ||
@@ -204,3 +333,3 @@ */ | ||
/** | ||
* The encrypted token for an authorized payment. | ||
* The encrypted information for an authorized payment. | ||
*/ | ||
@@ -225,3 +354,3 @@ token: ApplePayPaymentToken; | ||
/** | ||
* The payment token used to authorize a payment. | ||
* The authorized payment information for this transaction. | ||
*/ | ||
@@ -232,2 +361,17 @@ readonly payment: ApplePayPayment; | ||
/** | ||
* The result of payment authorization, including status and errors. | ||
*/ | ||
interface ApplePayPaymentAuthorizationResult { | ||
/** | ||
* The status code for the authorization result. | ||
*/ | ||
status: number; | ||
/** | ||
* A list of custom errors to display on the payment sheet. | ||
*/ | ||
errors?: ApplePayError[]; | ||
} | ||
/** | ||
* Encapsulates contact information needed for billing and shipping. | ||
@@ -239,3 +383,3 @@ */ | ||
*/ | ||
emailAddress: string; | ||
emailAddress?: string; | ||
@@ -245,3 +389,3 @@ /** | ||
*/ | ||
familyName: string; | ||
familyName?: string; | ||
@@ -251,3 +395,3 @@ /** | ||
*/ | ||
givenName: string; | ||
givenName?: string; | ||
@@ -257,37 +401,57 @@ /** | ||
*/ | ||
phoneNumber: string; | ||
phoneNumber?: string; | ||
/** | ||
* The address for the contact. | ||
* The phonetic spelling of the contact's family name. | ||
*/ | ||
addressLines: string[]; | ||
phoneticFamilyName?: string; | ||
/** | ||
* The phonetic spelling of the contact's given name. | ||
*/ | ||
phoneticGivenName?: string; | ||
/** | ||
* The street portion of the address for the contact. | ||
*/ | ||
addressLines?: string[]; | ||
/** | ||
* The city for the contact. | ||
*/ | ||
locality: string; | ||
locality?: string; | ||
/** | ||
* Additional information associated with the location, typically defined at the city or town level (such as district or neighborhood), in a postal address. | ||
*/ | ||
subLocality?: string; | ||
/** | ||
* The state for the contact. | ||
*/ | ||
administrativeArea: string; | ||
administrativeArea?: string; | ||
/** | ||
* The zip code, where applicable, for the contact. | ||
* The subadministrative area (such as a county or other region) in a postal address. | ||
*/ | ||
postalCode: string; | ||
subAdministrativeArea?: string; | ||
/** | ||
* The colloquial country name for the contact. | ||
* The zip code or postal code, where applicable, for the contact. | ||
*/ | ||
country: string; | ||
postalCode?: string; | ||
/** | ||
* The contact's ISO country code. | ||
* The name of the country for the contact. | ||
*/ | ||
countryCode: string; | ||
country?: string; | ||
/** | ||
* The contact’s two-letter ISO 3166 country code. | ||
*/ | ||
countryCode?: string; | ||
} | ||
/** | ||
* Contains information about an Apple Pay payment card. | ||
* A dictionary that describes an Apple Pay payment card. | ||
*/ | ||
@@ -302,3 +466,2 @@ interface ApplePayPaymentMethod { | ||
* A string, suitable for display, that is the name of the payment network backing the card. | ||
* The value is one of the supported networks specified in the supportedNetworks property of the ApplePayPaymentRequest. | ||
*/ | ||
@@ -310,6 +473,6 @@ network: string; | ||
*/ | ||
type: string; | ||
type: ApplePayPaymentMethodType; | ||
/** | ||
* The payment pass object associated with the payment. | ||
* The payment pass object currently selected to complete the payment. | ||
*/ | ||
@@ -320,2 +483,11 @@ paymentPass: ApplePayPaymentPass; | ||
/** | ||
* A payment card's type of payment. | ||
*/ | ||
type ApplePayPaymentMethodType = | ||
'debit' | | ||
'credit' | | ||
'prepaid' | | ||
'store'; | ||
/** | ||
* The ApplePayPaymentMethodSelectedEvent class defines the attributes contained by the ApplePaySession.onpaymentmethodselected callback function. | ||
@@ -331,2 +503,17 @@ */ | ||
/** | ||
* Updated transaction details resulting from a change in payment method. | ||
*/ | ||
interface ApplePayPaymentMethodUpdate { | ||
/** | ||
* An optional list of line items. | ||
*/ | ||
newLineItems?: ApplePayLineItem[]; | ||
/** | ||
* The new total resulting from a change in the payment method. | ||
*/ | ||
newTotal: ApplePayLineItem; | ||
} | ||
/** | ||
* Represents a provisioned payment card for Apple Pay payments. | ||
@@ -358,6 +545,35 @@ */ | ||
*/ | ||
activationState: string; | ||
activationState: ApplePayPaymentPassActivationState; | ||
} | ||
/** | ||
* Payment pass activation states. | ||
*/ | ||
type ApplePayPaymentPassActivationState = | ||
/** | ||
* Active and ready to be used for payment. | ||
*/ | ||
'activated' | | ||
/** | ||
* Not active but may be activated by the issuer. | ||
*/ | ||
'requiresActivation' | | ||
/** | ||
* Not ready for use but activation is in progress. | ||
*/ | ||
'activating' | | ||
/** | ||
* Not active and can't be activated. | ||
*/ | ||
'suspended' | | ||
/** | ||
* Not active because the issuer has disabled the account associated with the device. | ||
*/ | ||
'deactivated'; | ||
/** | ||
* Encapsulates a request for payment, including information about payment processing capabilities, the payment amount, and shipping information. | ||
@@ -385,3 +601,3 @@ */ | ||
*/ | ||
merchantCapabilities: string[]; | ||
merchantCapabilities: ApplePayMerchantCapability[]; | ||
@@ -406,3 +622,3 @@ /** | ||
*/ | ||
requiredBillingContactFields?: string[]; | ||
requiredBillingContactFields?: ApplePayContactField[]; | ||
@@ -412,3 +628,3 @@ /** | ||
*/ | ||
requiredShippingContactFields?: string[]; | ||
requiredShippingContactFields?: ApplePayContactField[]; | ||
@@ -428,5 +644,10 @@ /** | ||
*/ | ||
shippingType?: string; | ||
shippingType?: ApplePayShippingType; | ||
/** | ||
* A list of ISO 3166 country codes for limiting payments to cards from specific countries. | ||
*/ | ||
supportedCountries?: string[]; | ||
/** | ||
* Optional user-defined data. | ||
@@ -438,3 +659,3 @@ */ | ||
/** | ||
* Contains the user's payment credentials. | ||
* An object that contains the user's payment credentials. | ||
*/ | ||
@@ -459,3 +680,3 @@ interface ApplePayPaymentToken { | ||
/** | ||
* The ApplePayShippingContactSelectedEvent class defines the attributes contained by the ApplePaySession.onshippingcontactselected callback function. | ||
* Encapsulates the attributes contained by the onshippingcontactselected callback function. | ||
*/ | ||
@@ -470,2 +691,27 @@ abstract class ApplePayShippingContactSelectedEvent extends Event { | ||
/** | ||
* Updated transaction details resulting from a change in shipping contact, including any errors. | ||
*/ | ||
class ApplePayShippingContactUpdate { | ||
/** | ||
* List of custom errors to display on the payment sheet. | ||
*/ | ||
errors?: ApplePayError[]; | ||
/** | ||
* An optional list of updated line items. | ||
*/ | ||
newLineItems?: ApplePayLineItem[]; | ||
/** | ||
* A list of shipping methods that are available to the updated shipping contact. | ||
*/ | ||
newShippingMethods?: ApplePayShippingMethod[]; | ||
/** | ||
* The new total resulting from a change in the shipping contact. | ||
*/ | ||
newTotal: ApplePayLineItem; | ||
} | ||
/** | ||
* Defines a shipping method for delivering physical goods. | ||
@@ -506,7 +752,31 @@ */ | ||
/** | ||
* The ApplePayValidateMerchantEvent class defines the attributes contained by the ApplePaySession.onvalidatemerchant callback function. | ||
* Updated transaction details resulting from a change in shipping method. | ||
*/ | ||
interface ApplePayShippingMethodUpdate { | ||
/** | ||
* An optional list of updated line items. | ||
*/ | ||
newLineItems?: ApplePayLineItem[]; | ||
/** | ||
* The new total resulting from a change in the shipping method. | ||
*/ | ||
newTotal: ApplePayLineItem; | ||
} | ||
/** | ||
* A type that indicates how purchased items are to be shipped. | ||
*/ | ||
type ApplePayShippingType = | ||
'shipping' | | ||
'delivery' | | ||
'storePickup' | | ||
'servicePickup'; | ||
/** | ||
* The attributes contained by the onvalidatemerchant callback function. | ||
*/ | ||
abstract class ApplePayValidateMerchantEvent extends Event { | ||
/** | ||
* The URL used to validate the merchant server. | ||
* The URL your server must use to validate itself and obtain a merchant session object. | ||
*/ | ||
@@ -513,0 +783,0 @@ readonly validationURL: string; |
{ | ||
"name": "@types/applepayjs", | ||
"version": "1.0.4", | ||
"version": "3.0.0", | ||
"description": "TypeScript definitions for Apple Pay JS", | ||
@@ -9,3 +9,4 @@ "license": "MIT", | ||
"name": "Martin Costello", | ||
"url": "https://martincostello.com/" | ||
"url": "https://github.com/martincostello", | ||
"githubUsername": "martincostello" | ||
} | ||
@@ -20,4 +21,4 @@ ], | ||
"dependencies": {}, | ||
"typesPublisherContentHash": "b53395b495e7a6150bc8ca51adaadd88f19664d966353fe8f6f5a2fa3c5a33b2", | ||
"typesPublisherContentHash": "fa65c02c4abbb8896cde4d81489c9aef0f77b35c0819cc4c2b770566a7bafc7e", | ||
"typeScriptVersion": "2.0" | ||
} |
@@ -11,3 +11,3 @@ # Installation | ||
Additional Details | ||
* Last updated: Mon, 21 Aug 2017 21:47:08 GMT | ||
* Last updated: Sun, 03 Dec 2017 16:26:41 GMT | ||
* Dependencies: none | ||
@@ -17,2 +17,2 @@ * Global values: ApplePayJS, ApplePaySession | ||
# Credits | ||
These definitions were written by Martin Costello <https://martincostello.com/>. | ||
These definitions were written by Martin Costello <https://github.com/martincostello>. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27106
676