mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-02-26 10:42:51 +00:00
[REPO] add payemnt requets spec
This commit is contained in:
parent
bf439e4134
commit
406ee078bc
91
paymentrequest/index.d.ts
vendored
91
paymentrequest/index.d.ts
vendored
@ -0,0 +1,91 @@
|
||||
// Type definitions for PaymentRequest
|
||||
// Project: https://www.w3.org/TR/payment-request/
|
||||
// Definitions by: Adam Cmiel <https://github.com/adamcmiel>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface PaymentRequest extends EventTarget {
|
||||
new (methodData: PaymentMethodData[], details: PaymentDetails, options?: PaymentOptions);
|
||||
show(): PromiseLike<PaymentResponse>;
|
||||
abort(): PromiseLike<void>;
|
||||
shippingAddress?: PaymentAddress;
|
||||
shippingOption?: string;
|
||||
onshippingaddresschange: PaymentUpdateEventListener;
|
||||
onshippingoptionchange: PaymentUpdateEventListener;
|
||||
}
|
||||
|
||||
interface PaymentMethodData {
|
||||
supportedMethods: string[];
|
||||
data?: Object;
|
||||
}
|
||||
|
||||
interface PaymentCurrencyAmount {
|
||||
currency: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
interface PaymentDetails {
|
||||
total: PaymentItem;
|
||||
displayItems?: PaymentItem[];
|
||||
shippingOptions?: PaymentShippingOption[];
|
||||
modifiers: PaymentDetailsModifier[];
|
||||
}
|
||||
|
||||
interface PaymentDetailsModifier {
|
||||
supportedMethods: string[];
|
||||
total?: PaymentItem;
|
||||
additionalDisplayItems: PaymentItem[];
|
||||
}
|
||||
|
||||
interface PaymentOptions {
|
||||
requestShipping: boolean;
|
||||
requestPayerEmail: boolean;
|
||||
requestPayerPhone: boolean;
|
||||
}
|
||||
|
||||
interface PaymentItem {
|
||||
label: string;
|
||||
amount: PaymentCurrencyAmount
|
||||
}
|
||||
|
||||
interface PaymentAddress {
|
||||
country: string;
|
||||
addressLine: string[];
|
||||
region: string;
|
||||
city: string;
|
||||
dependentLocality: string;
|
||||
postalCode: string;
|
||||
sortingCode: string;
|
||||
languageCode: string;
|
||||
organization: string;
|
||||
recipient: string;
|
||||
careOf: string;
|
||||
phone: string;
|
||||
}
|
||||
|
||||
interface PaymentShippingOption {
|
||||
id: string;
|
||||
label: string;
|
||||
amount: PaymentCurrencyAmount;
|
||||
}
|
||||
|
||||
interface PaymentResponse {
|
||||
methodName: string;
|
||||
details: Object;
|
||||
shippingAddress?: PaymentAddress;
|
||||
shippingOption?: string;
|
||||
payerEmail?: string;
|
||||
payerPhone?: string;
|
||||
|
||||
complete(result?: '' | 'success' | 'fail'): PromiseLike<void>;
|
||||
}
|
||||
|
||||
interface PaymentUpdateEventListener extends EventListener {
|
||||
(evt: PaymentRequestUpdateEvent): void;
|
||||
}
|
||||
|
||||
interface PaymentRequestUpdateEvent extends Event {
|
||||
updateWith(d: PromiseLike<PaymentDetails>): void;
|
||||
}
|
||||
|
||||
declare var PaymentRequest: PaymentRequest;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user