@@ -95,6 +95,103 @@ export enum ApplePayStatusCodes {
9595 STATUS_PIN_LOCKOUT ,
9696}
9797
98+ export type ApplePayErrorCode =
99+ /**
100+ * Shipping address or contact information is invalid or missing.
101+ */
102+ | "shippingContactInvalid"
103+ /**
104+ * Billing address information is invalid or missing.
105+ */
106+ | "billingContactInvalid"
107+ /**
108+ * The merchant cannot provide service to the shipping address (for example, can't deliver to a P.O. Box).
109+ */
110+ | "addressUnserviceable"
111+ /**
112+ * The code that indicates an invalid coupon.
113+ */
114+ | "couponCodeInvalid"
115+ /**
116+ * The code that indicates an expired coupon.
117+ */
118+ | "couponCodeExpired"
119+ /**
120+ * An unknown but nonfatal error occurred during payment processing. The user can attempt authorization again.
121+ */
122+ | "unknown" ;
123+
124+ export interface ApplePayError {
125+ /**
126+ * The error code for this instance.
127+ */
128+ code : ApplePayErrorCode ;
129+
130+ /**
131+ * The name of the field that contains the error.
132+ */
133+ contactField ?: ApplePayErrorContactField | undefined ;
134+
135+ /**
136+ * A localized, user-facing string that describes the error.
137+ */
138+ message : string ;
139+ }
140+
141+ /**
142+ * Names of the fields in the shipping or billing contact information, used to locate errors in the payment sheet.
143+ */
144+ export type ApplePayErrorContactField =
145+ | "phoneNumber"
146+ | "emailAddress"
147+ | "name"
148+ | "phoneticName"
149+ | "postalAddress"
150+ | "addressLines"
151+ | "locality"
152+ | "subLocality"
153+ | "postalCode"
154+ | "administrativeArea"
155+ | "subAdministrativeArea"
156+ | "country"
157+ | "countryCode" ;
158+
159+ export interface ApplePayPaymentOrderDetails {
160+ /**
161+ * An identifier for the order type associated with the order.
162+ */
163+ orderTypeIdentifier : string ;
164+ /**
165+ * A unique order identifier scoped to your order type identifier.
166+ */
167+ orderIdentifier : string ;
168+ /**
169+ * The URL of your web service.
170+ */
171+ webServiceURL : string ;
172+ /**
173+ * The authentication token supplied to your web service.
174+ */
175+ authenticationToken : string ;
176+ }
177+
178+ export interface ApplePayPaymentAuthorizationResult {
179+ /**
180+ * The status code for the authorization result.
181+ */
182+ status : number ;
183+
184+ /**
185+ * A list of custom errors to display on the payment sheet.
186+ */
187+ errors ?: ApplePayError [ ] | undefined ;
188+
189+ /**
190+ * Optional metadata for an order that the customer placed using this payment method.
191+ */
192+ orderDetails ?: ApplePayPaymentOrderDetails ;
193+ }
194+
98195export type ApplePayTokenizeValues = "Yes" | "No" | "Unknown" ;
99196
100197export interface ApplePayDetails {
@@ -137,7 +234,12 @@ export class ApplePaySession {
137234
138235 begin ( ) : void ;
139236
140- completePayment ( status : ApplePayStatusCodes ) : void ;
237+ /**
238+ * Completes the payment authorization with a result.
239+ * @param result - The status of the payment, whether it succeeded or failed for Apple Pay JS versions 1 and 2,
240+ * or the result of the payment authorization, including its status and list of errors for Apple Pay JS version 3.
241+ */
242+ completePayment ( status : ApplePayStatusCodes | ApplePayPaymentAuthorizationResult ) : void ;
141243
142244 completePaymentMethodSelection ( newTotal : any , newLineItems : any ) : void ;
143245
0 commit comments