| // Copyright 2016 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| module payments.mojom; |
| |
| import "components/payments/mojom/payment_request_data.mojom"; |
| import "mojo/public/mojom/base/time.mojom"; |
| import "third_party/blink/public/mojom/manifest/manifest.mojom"; |
| import "third_party/blink/public/mojom/payments/payment_request.mojom"; |
| import "third_party/blink/public/mojom/payments/payment_handler_host.mojom"; |
| import "url/mojom/url.mojom"; |
| |
| enum PaymentHandlerStatus { |
| SUCCESS, |
| NOT_FOUND, |
| NO_ACTIVE_WORKER, |
| STORAGE_OPERATION_FAILED, |
| FETCH_INSTRUMENT_ICON_FAILED, |
| FETCH_PAYMENT_APP_INFO_FAILED, |
| }; |
| |
| enum CanMakePaymentEventResponseType { |
| // Reasons for not firing the "canmakepayment" event. |
| INCOGNITO, |
| NO_EXPLICITLY_VERIFIED_METHODS, |
| NOT_INSTALLED, |
| NO_URL_BASED_PAYMENT_METHODS, |
| |
| // Common response types from respondWith() and respondWithMinimalUI(). |
| BOOLEAN_CONVERSION_ERROR, |
| BROWSER_ERROR, |
| INTERNAL_ERROR, |
| NO_RESPONSE, |
| REJECT, |
| SUCCESS, |
| TIMEOUT, |
| |
| // Response types specifically used in respondWithMinimalUI(), which is |
| // available when features::kWebPaymentsMinimalUI is ebabled. |
| INVALID_ACCOUNT_BALANCE_VALUE, |
| MINIMAL_UI_RESPONSE_CONVERSION_ERROR, |
| NO_ACCOUNT_BALANCE_VALUE, |
| NO_CAN_MAKE_PAYMENT_VALUE, |
| NO_READY_FOR_MINIMAL_UI_VALUE, |
| }; |
| |
| enum PaymentEventResponseType { |
| PAYER_NAME_EMPTY, |
| PAYER_EMAIL_EMPTY, |
| PAYER_PHONE_EMPTY, |
| PAYMENT_DETAILS_ABSENT, |
| PAYMENT_DETAILS_NOT_OBJECT, |
| PAYMENT_DETAILS_STRINGIFY_ERROR, |
| PAYMENT_EVENT_BROWSER_ERROR, |
| PAYMENT_EVENT_INTERNAL_ERROR, |
| PAYMENT_EVENT_NO_RESPONSE, |
| PAYMENT_EVENT_REJECT, |
| PAYMENT_EVENT_SERVICE_WORKER_ERROR, |
| PAYMENT_EVENT_SUCCESS, |
| PAYMENT_EVENT_TIMEOUT, |
| PAYMENT_HANDLER_ACTIVITY_DIED, |
| PAYMENT_HANDLER_FAIL_TO_LOAD_MAIN_FRAME, |
| PAYMENT_HANDLER_INSECURE_NAVIGATION, |
| PAYMENT_HANDLER_WINDOW_CLOSING, |
| PAYMENT_METHOD_NAME_EMPTY, |
| SHIPPING_ADDRESS_INVALID, |
| SHIPPING_OPTION_EMPTY, |
| }; |
| |
| // This struct is provided to hold a payment instrument from render |
| // side (PaymentInstrument.idl). |
| struct PaymentInstrument { |
| string name; |
| array<blink.mojom.ManifestImageResource> icons; |
| string method; |
| string stringified_capabilities; |
| |
| // Parsed basic-card specific capabilities. |
| // Non-empty only if |method| is "basic-card". |
| array<BasicCardNetwork> supported_networks; |
| }; |
| |
| enum PaymentDelegation { |
| SHIPPING_ADDRESS, |
| PAYER_NAME, |
| PAYER_PHONE, |
| PAYER_EMAIL, |
| }; |
| |
| // This interface provides implementation of PaymentInstruments.idl |
| // and PaymentManager.idl in render side. This interface is implemented |
| // by payment_manager.cc and runs in browser side. |
| interface PaymentManager { |
| // |context_url| is the url of the web page creating this interface. |
| // |service_worker_scope| is passed as string since it is from |
| // ServiceWorkerRegistration and the interface is used for |
| // ServiceWorkerRegistration.idl |
| Init(url.mojom.Url context_url, string service_worker_scope); |
| DeletePaymentInstrument(string instrument_key) |
| => (PaymentHandlerStatus status); |
| GetPaymentInstrument(string instrument_key) |
| => (PaymentInstrument instrument, PaymentHandlerStatus status); |
| KeysOfPaymentInstruments() |
| => (array<string> keys, PaymentHandlerStatus status); |
| HasPaymentInstrument(string instrument_key) |
| => (PaymentHandlerStatus status); |
| SetPaymentInstrument(string instrument_key, PaymentInstrument instrument) |
| => (PaymentHandlerStatus status); |
| ClearPaymentInstruments() |
| => (PaymentHandlerStatus status); |
| SetUserHint(string user_hint); |
| // A method from PaymentManager.idl which lets payment handlers specify |
| // whether or not they can handle shipping address or contact info (payer's |
| // name/email/phone). |
| EnableDelegations(array<PaymentDelegation> delegations) |
| =>(PaymentHandlerStatus status); |
| }; |
| |
| // This struct is provided to send payment request data to render side |
| // (CanMakePaymentEvent.idl). |
| struct CanMakePaymentEventData { |
| url.mojom.Url top_origin; |
| url.mojom.Url payment_request_origin; |
| array<PaymentMethodData> method_data; |
| array<PaymentDetailsModifier> modifiers; |
| |
| // The field is null when features::kWebPaymentsMinimalUI is disabled. |
| string? currency; |
| }; |
| |
| // This struct is provided to send payment request data to render side |
| // (PaymentRequestEvent.idl). |
| struct PaymentRequestEventData { |
| url.mojom.Url top_origin; |
| url.mojom.Url payment_request_origin; |
| string payment_request_id; |
| array<PaymentMethodData> method_data; |
| PaymentCurrencyAmount total; |
| array<PaymentDetailsModifier> modifiers; |
| string instrument_key; |
| PaymentOptions? payment_options; |
| array<PaymentShippingOption>? shipping_options; |
| |
| // Handles events raised by the payment handler, such as "payment method |
| // changed" event. NullRemote in content_browsertests. |
| pending_remote<PaymentHandlerHost>? payment_handler_host; |
| }; |
| |
| // Response to "can make payment" query. Sent from the renderer to the browser. |
| struct CanMakePaymentResponse { |
| CanMakePaymentEventResponseType response_type; |
| bool can_make_payment; |
| |
| // The following fields are used for the minimal UI feature when |
| // features::kWebPaymentsMinimalUI is enabled. |
| bool ready_for_minimal_ui; |
| string? account_balance; |
| }; |
| |
| // This struct is provided to receive payment app response from render |
| // side (PaymentHandlerResponse.idl). |
| struct PaymentHandlerResponse { |
| string method_name; |
| string stringified_details; |
| PaymentEventResponseType response_type; |
| string? payer_name; |
| string? payer_email; |
| string? payer_phone; |
| PaymentAddress? shipping_address; |
| string? shipping_option; |
| }; |
| |
| // This interface is provided to pass a payment handler response from payment |
| // request event in renderer side to browser side by calling respondWith() or |
| // respondWithMinimalUI(). |
| interface PaymentHandlerResponseCallback { |
| // Response from the renderer to the browser about the status of attempted |
| // abort of payment. |
| OnResponseForAbortPayment(bool payment_aborted); |
| |
| // Response from the renderer to the browser about the ability of the payment |
| // handler to make payments. |
| OnResponseForCanMakePayment(CanMakePaymentResponse response); |
| |
| // Response from the renderer to the browser containing the payment details |
| // from the payment handler. |
| OnResponseForPaymentRequest(PaymentHandlerResponse response); |
| }; |