From 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:47:29 +0200 Subject: Adding upstream version 115.8.0esr. Signed-off-by: Daniel Baumann --- dom/interfaces/payments/moz.build | 15 + .../payments/nsIPaymentActionResponse.idl | 406 +++++++++++++++++++++ dom/interfaces/payments/nsIPaymentAddress.idl | 43 +++ dom/interfaces/payments/nsIPaymentRequest.idl | 93 +++++ .../payments/nsIPaymentRequestService.idl | 102 ++++++ dom/interfaces/payments/nsIPaymentUIService.idl | 85 +++++ 6 files changed, 744 insertions(+) create mode 100644 dom/interfaces/payments/moz.build create mode 100644 dom/interfaces/payments/nsIPaymentActionResponse.idl create mode 100644 dom/interfaces/payments/nsIPaymentAddress.idl create mode 100644 dom/interfaces/payments/nsIPaymentRequest.idl create mode 100644 dom/interfaces/payments/nsIPaymentRequestService.idl create mode 100644 dom/interfaces/payments/nsIPaymentUIService.idl (limited to 'dom/interfaces/payments') diff --git a/dom/interfaces/payments/moz.build b/dom/interfaces/payments/moz.build new file mode 100644 index 0000000000..f7e1229a82 --- /dev/null +++ b/dom/interfaces/payments/moz.build @@ -0,0 +1,15 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +XPIDL_SOURCES += [ + "nsIPaymentActionResponse.idl", + "nsIPaymentAddress.idl", + "nsIPaymentRequest.idl", + "nsIPaymentRequestService.idl", + "nsIPaymentUIService.idl", +] + +XPIDL_MODULE = "dom_payments" diff --git a/dom/interfaces/payments/nsIPaymentActionResponse.idl b/dom/interfaces/payments/nsIPaymentActionResponse.idl new file mode 100644 index 0000000000..36d5be3b94 --- /dev/null +++ b/dom/interfaces/payments/nsIPaymentActionResponse.idl @@ -0,0 +1,406 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsISupports.idl" +#include "nsIVariant.idl" +#include "nsIPaymentAddress.idl" + +/** + * The base interface of response data for the specified payment method. + * The response data is the content of the PaymentResponse's detail attribute. + */ +[builtinclass, scriptable, uuid(2a338575-c688-40ee-a157-7488ab292ef2)] +interface nsIPaymentResponseData: nsISupports +{ + /** + * The consts for representing the response data type. + * GENERAL_RESPONSE is the general purpose response data type. Except basic + * card response data, all response data should belong to this type. + * BASICCARD_RESPONSE is a special response data type for basic card response. + */ + const uint32_t GENERAL_RESPONSE = 0; + const uint32_t BASICCARD_RESPONSE = 1; + + /** + * The response data type. + * Using the above defined consts(GENERAL_RESPONSE or BASICCARD_RESPONSE). + */ + readonly attribute uint32_t type; + + /** + * The initial method. + * @param aType - the response data type. + */ + void init(in uint32_t aType); +}; + +/** + * The general purpose response data. + */ +[builtinclass, scriptable, uuid(b986773e-2b30-4ed2-b8fe-6a96631c8000)] +interface nsIGeneralResponseData : nsIPaymentResponseData +{ + /** + * The stringified response data. + */ + readonly attribute AString data; + + /** + * The initial method for nsIGeneralResponseData. + * @param aData - the javascript object of the content. + */ + [implicit_jscontext] + void initData(in jsval aData); +}; + +/** + * The basic card response data. + * Since PaymentAddress is an no constructor interface type, UI code can not + * easy create PaymentAddress by calling new PaymentAddress(). + * Unfortunately, BasicCardResponse has a PaymentAddress attribute, billingAddress + * , it means UI can not create BsaicCardResponse by calling the init() with a + * given JSObject directly, because PaymentAddress creation in JS code is hard. + * To let UI code can create BasicCardResponse easier, nsIBasicCardResponse is + * provided for UI by passing the raw data of BasicCardResponse, + */ +[builtinclass, scriptable, uuid(0d55a5e6-d185-44f0-b992-a8e1321e4bce)] +interface nsIBasicCardResponseData : nsIPaymentResponseData +{ + /** + * The cardholder name. + */ + readonly attribute AString cardholderName; + + /** + * The card number. + */ + readonly attribute AString cardNumber; + + /** + * The expiry month. + */ + readonly attribute AString expiryMonth; + + /** + * The expiry year. + */ + readonly attribute AString expiryYear; + + /** + * The card security number. + */ + readonly attribute AString cardSecurityCode; + + /** + * The billing address. + */ + readonly attribute nsIPaymentAddress billingAddress; + + /** + * The initial method for nsIBasicCardResponseData. + * @param aCardholderName - the cardholder name. + * @param aCardNumber - the card number. + * @param aExpiryMonth - the expiry month. + * @param aExpiryYear - the expiry year. + * @param aCardSecurityCode - the card security code. + * @param aBillingAddreess - the billing address. + */ + void initData(in AString aCardholderName, + in AString aCardNumber, + in AString aExpiryMonth, + in AString aExpiryYear, + in AString aCardSecurityCode, + in nsIPaymentAddress billingAddress); +}; + +/** + * The base interface of user's response. + * Payment UI should create different sub-interface of nsIPaymentActionResponse + * according to user's action, and call nsIPaymentRequestService::respondPayment + * with the created action to inform the merchant. + */ +[builtinclass, scriptable, uuid(a607c095-ef60-4a9b-a3d0-0506c60728b3)] +interface nsIPaymentActionResponse : nsISupports +{ + /** + * The response type. + * Align type to nsIPaymentActionRequest types, + * where 1 is for payment request creation. + * the action expects no response from UI module. + */ + const uint32_t NO_TYPE = 0; + // const uint32_t CREATE_ACTION = 1; + const uint32_t CANMAKE_ACTION = 2; + const uint32_t SHOW_ACTION = 3; + const uint32_t ABORT_ACTION = 4; + const uint32_t COMPLETE_ACTION = 5; + + /** + * The abort status. + */ + const uint32_t ABORT_SUCCEEDED = 1; + const uint32_t ABORT_FAILED = 0; + + /** + * The payment status. + */ + const uint32_t PAYMENT_REJECTED = 0; + const uint32_t PAYMENT_ACCEPTED = 1; + const uint32_t PAYMENT_NOTSUPPORTED = 2; + + /** + * The complete status. + */ + const uint32_t COMPLETE_SUCCEEDED = 1; + const uint32_t COMPLETE_FAILED = 0; + + /* + * The payment request identity. + */ + readonly attribute AString requestId; + + /* + * The response type. + */ + readonly attribute uint32_t type; +}; + +/** + * The response for canMakePayment action. + */ +[builtinclass, scriptable, uuid(52fc3f9f-c0cb-4874-b3d4-ee4b6e9cbe9c)] +interface nsIPaymentCanMakeActionResponse : nsIPaymentActionResponse +{ + /** + * The result of canMakePayment action. + */ + readonly attribute bool result; + + /** + * The initial method. + * @param aRequestId - the request identifier of the payment request. + * @param aResult - the canMakePayment result. + */ + void init(in AString aRequestId, in bool aResult); +}; + +/** + * The response for show action. + * Notice that to represent user's cancel, we should use nsIPaymentShowActionResponse + * with PAYMENT_REJECTED status, not nsIPaymentAbortActionResponse. + */ +[builtinclass, scriptable, uuid(184385cb-2d35-4b99-a9a3-7c780bf66b9b)] +interface nsIPaymentShowActionResponse : nsIPaymentActionResponse +{ + /** + * Accept status of the payment. + * Using the defined consts(PAYMENT_XXX) in nsIPaymentActionResponse. + */ + readonly attribute uint32_t acceptStatus; + + /** + * The decided payment method name. i.e. "basic-card". + */ + readonly attribute AString methodName; + + /** + * The data needed by the payment method. (it must be serializable) + */ + readonly attribute nsIPaymentResponseData data; + + /** + * The payer name information. + */ + readonly attribute AString payerName; + + /** + * The payer email information. + */ + readonly attribute AString payerEmail; + + /** + * The payer phone information. + */ + readonly attribute AString payerPhone; + + /** + * The initial method. + * @param aRequestId - the request identifier of the payment request. + * @param aAcceptStatus - the payment status. + * @param aMethodName - the decided method name. + * @param aData - the response data for the decided payment method. + * @param aPayerName - the payer's name. + * @param aPayerEmail - the payer's email. + * @param aPayerPhone - the payer's phone. + */ + void init(in AString aRequestId, + in uint32_t aAcceptStatus, + in AString aMethodName, + in nsIPaymentResponseData aData, + in AString aPayerName, + in AString aPayerEmail, + in AString aPayerPhone); +}; + +/** + * The response for abort action. + */ +[builtinclass, scriptable, uuid(8c72bcdb-0c37-4786-a9e5-510afa2f8ede)] +interface nsIPaymentAbortActionResponse : nsIPaymentActionResponse +{ + /** + * The abort action status. + * Using the defined consts(ABORT_XXX) in nsIPaymentActionResponse. + */ + readonly attribute uint32_t abortStatus; + + /** + * The Initial method. + * @param aRequestId - the request identifier of payment request. + * @param aAbortStatus - the abort action result. + */ + void init(in AString aRequestId, in uint32_t aAbortStatus); + + /** + * Check if the abort action is succeeded + */ + bool isSucceeded(); +}; + +[builtinclass, scriptable, uuid(62c01e69-9ca4-4060-99e4-b95f628c8e6d)] +interface nsIPaymentCompleteActionResponse : nsIPaymentActionResponse +{ + /** + * The complete action status. + * Using the defined consts(COMPLETE_XXX) in nsIPaymentActionResponse. + */ + readonly attribute uint32_t completeStatus; + + /** + * The Initial method. + * @param aRequestId - the request identifier of payment request. + * @param aCompleteStatus - the complete action result. + */ + void init(in AString aRequestId, + in uint32_t aCompleteStatus); + + /** + * Check if the complete action is succeeded. + */ + bool isCompleted(); +}; + +[builtinclass, scriptable, uuid(2035e0a9-c9ab-4c9f-b8e9-28b2ed61548c)] +interface nsIMethodChangeDetails : nsISupports +{ + /** + * The consts for representing the method change details data type. + * GENERAL_DETAILS is the general purpose details data type. Except basic + * card details, all details should belong to this type. + * BASICCARD_DETAILS is a special details data type for basic card change + * details. + */ + const uint32_t GENERAL_DETAILS = 0; + const uint32_t BASICCARD_DETAILS = 1; + + /** + * The method change details data type. + * Using the above defined consts(GENERAL_DETAILS or BASICCARD_DETAILS). + */ + readonly attribute uint32_t type; + + /** + * The initial method. + * @param aType - the method change details data type. + */ + void init(in uint32_t aType); +}; + +/** + * The general purpose method change details. + */ +[builtinclass, scriptable, uuid(e031267e-bec8-4f3c-b0b1-396b77ca260c)] +interface nsIGeneralChangeDetails : nsIMethodChangeDetails +{ + /** + * The stringified change details. + */ + readonly attribute AString details; + + /** + * The initial method for nsIGeneralChangeDetails. + * @param aData - the javascript object of the content. + */ + [implicit_jscontext] + void initData(in jsval aDetails); +}; + +/** + * The basic card change details. + * Since PaymentAddress is an no constructor interface type, UI code can not + * easy create PaymentAddress by calling new PaymentAddress(). + * Unfortunately, BasicCardResponse has a PaymentAddress attribute, billingAddress + * , it means UI can not create BsaicCardChangeDetails by calling the init() with a + * given JSObject directly, because PaymentAddress creation in JS code is hard. + * To let UI code can create BasicCardResponse easier, nsIBasicCardResponse is + * provided for UI by passing the raw data of BasicCardResponse, + */ +[builtinclass, scriptable, uuid(5296f79e-15ea-40c3-8196-19cfa64d328c)] +interface nsIBasicCardChangeDetails : nsIMethodChangeDetails +{ + /** + * The billing address. + */ + readonly attribute nsIPaymentAddress billingAddress; + + /** + * The initial method for nsIBasicCardChangeDetails. + * @param aBillingAddreess - the billing address. + */ + void initData(in nsIPaymentAddress billingAddress); +}; + + +%{C++ +#define NS_GENERAL_RESPONSE_DATA_CID \ + { 0xb986773e, 0x2b30, 0x4ed2, { 0xb8, 0xfe, 0x6a, 0x96, 0x63, 0x1c, 0x80, 0x00 } } +#define NS_GENERAL_RESPONSE_DATA_CONTRACT_ID \ + "@mozilla.org/dom/payments/general-response-data;1" + +#define NS_BASICCARD_RESPONSE_DATA_CID \ + { 0x0d55a5e6, 0xd185, 0x44f0, { 0xb9, 0x92, 0xa8, 0xe1, 0x32, 0x1e, 0x4b, 0xce } } +#define NS_BASICCARD_RESPONSE_DATA_CONTRACT_ID \ + "@mozilla.org/dom/payments/basiccard-response-data;1" + +#define NS_PAYMENT_CANMAKE_ACTION_RESPONSE_CID \ + { 0x52fc3f9f, 0xc0cb, 0x4874, { 0xb3, 0xd4, 0xee, 0x4b, 0x6e, 0x9c, 0xbe, 0x9c } } +#define NS_PAYMENT_CANMAKE_ACTION_RESPONSE_CONTRACT_ID \ + "@mozilla.org/dom/payments/payment-canmake-action-response;1" + +#define NS_PAYMENT_SHOW_ACTION_RESPONSE_CID \ + { 0x184385cb, 0x2d35, 0x4b99, { 0xa9, 0xa3, 0x7c, 0x78, 0x0b, 0xf6, 0x6b, 0x9b } } +#define NS_PAYMENT_SHOW_ACTION_RESPONSE_CONTRACT_ID \ + "@mozilla.org/dom/payments/payment-show-action-response;1" + +#define NS_PAYMENT_ABORT_ACTION_RESPONSE_CID \ + { 0x8c72bcdb, 0x0c37, 0x4786, { 0xa9, 0xe5, 0x51, 0x0a, 0xfa, 0x2f, 0x8e, 0xde } } +#define NS_PAYMENT_ABORT_ACTION_RESPONSE_CONTRACT_ID \ + "@mozilla.org/dom/payments/payment-abort-action-response;1" + +#define NS_PAYMENT_COMPLETE_ACTION_RESPONSE_CID \ + { 0x62c01e69, 0x9ca4, 0x4060, { 0x99, 0xe4, 0xb9, 0x5f, 0x62, 0x8c, 0x8e, 0x6d } } +#define NS_PAYMENT_COMPLETE_ACTION_RESPONSE_CONTRACT_ID \ + "@mozilla.org/dom/payments/payment-complete-action-response;1" + +#define NS_GENERAL_CHANGE_DETAILS_CID \ + { 0xe031267e, 0xbec8, 0x4f3c, { 0xb0, 0xb1, 0x39, 0x6b, 0x77, 0xca, 0x26, 0x0c } } +#define NS_GENERAL_CHANGE_DETAILS_CONTRACT_ID \ + "@mozilla.org/dom/payments/general-change-details;1" + +#define NS_BASICCARD_CHANGE_DETAILS_CID \ + { 0x5296f79e, 0x15ea, 0x40c3, { 0x81, 0x96, 0x19, 0xcf, 0xa6, 0x4d, 0x32, 0x8c } } +#define NS_BASICCARD_CHANGE_DETAILS_CONTRACT_ID \ + "@mozilla.org/dom/payments/basiccard-change-details;1" +%} diff --git a/dom/interfaces/payments/nsIPaymentAddress.idl b/dom/interfaces/payments/nsIPaymentAddress.idl new file mode 100644 index 0000000000..7f9bf39e51 --- /dev/null +++ b/dom/interfaces/payments/nsIPaymentAddress.idl @@ -0,0 +1,43 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsISupports.idl" + +interface nsIArray; + +[builtinclass, scriptable, uuid(49a02241-7e48-477a-9345-9f246925dcb3)] +interface nsIPaymentAddress : nsISupports +{ + readonly attribute AString country; + readonly attribute nsIArray addressLine; + readonly attribute AString region; + readonly attribute AString regionCode; + readonly attribute AString city; + readonly attribute AString dependentLocality; + readonly attribute AString postalCode; + readonly attribute AString sortingCode; + readonly attribute AString organization; + readonly attribute AString recipient; + readonly attribute AString phone; + + void init(in AString aCountry, + in nsIArray aAddressLine, + in AString aRegion, + in AString aRegionCode, + in AString aCity, + in AString aDependentLocality, + in AString aPostalCode, + in AString aSortingCode, + in AString aOrganization, + in AString aRecipient, + in AString aPhone); +}; + +%{C++ +#define NS_PAYMENT_ADDRESS_CID \ + { 0x49a02241, 0x7e48, 0x477a, { 0x93, 0x45, 0x9f, 0x24, 0x69, 0x25, 0xdc, 0xb3 } } +#define NS_PAYMENT_ADDRESS_CONTRACT_ID \ + "@mozilla.org/dom/payments/payment-address;1" +%} diff --git a/dom/interfaces/payments/nsIPaymentRequest.idl b/dom/interfaces/payments/nsIPaymentRequest.idl new file mode 100644 index 0000000000..ea5b6cba47 --- /dev/null +++ b/dom/interfaces/payments/nsIPaymentRequest.idl @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsISupports.idl" +#include "nsIVariant.idl" +#include "nsIPrincipal.idl" + +interface nsIArray; + +[scriptable, builtinclass, uuid(2fe296cc-d917-4820-b492-aa42df23f9b4)] +interface nsIPaymentMethodData : nsISupports +{ + readonly attribute AString supportedMethods; + [implicit_jscontext] + readonly attribute jsval data; +}; + +[scriptable, builtinclass, uuid(d22a6f5f-767b-4fea-bf92-68b0b8003eba)] +interface nsIPaymentCurrencyAmount : nsISupports +{ + readonly attribute AString currency; + readonly attribute AString value; +}; + +[scriptable, builtinclass, uuid(4f78a59f-b5ff-4fb5-ab48-3b37d0101b02)] +interface nsIPaymentItem : nsISupports +{ + readonly attribute AString label; + readonly attribute nsIPaymentCurrencyAmount amount; + readonly attribute boolean pending; +}; + +[scriptable, builtinclass, uuid(74259861-c318-40e8-b3d5-518e701bed80)] +interface nsIPaymentDetailsModifier : nsISupports +{ + readonly attribute AString supportedMethods; + readonly attribute nsIPaymentItem total; + readonly attribute nsIArray additionalDisplayItems; + [implicit_jscontext] + readonly attribute jsval data; +}; + +[scriptable, builtinclass, uuid(68341551-3605-4381-b936-41e830aa88fb)] +interface nsIPaymentShippingOption : nsISupports +{ + readonly attribute AString id; + readonly attribute AString label; + readonly attribute nsIPaymentCurrencyAmount amount; + attribute boolean selected; +}; + +[scriptable, builtinclass, uuid(73a5a3f1-45b9-4605-a6e6-7aa60daa9039)] +interface nsIPaymentDetails : nsISupports +{ + readonly attribute AString id; + readonly attribute nsIPaymentItem totalItem; + readonly attribute nsIArray displayItems; + readonly attribute nsIArray shippingOptions; + readonly attribute nsIArray modifiers; + readonly attribute AString error; + [implicit_jscontext] + readonly attribute jsval shippingAddressErrors; + [implicit_jscontext] + readonly attribute jsval payerErrors; + [implicit_jscontext] + readonly attribute jsval paymentMethodErrors; +}; + +[scriptable, builtinclass, uuid(d53f9f20-138e-47cc-9fd5-db16a3f6d301)] +interface nsIPaymentOptions : nsISupports +{ + readonly attribute boolean requestPayerName; + readonly attribute boolean requestPayerEmail; + readonly attribute boolean requestPayerPhone; + readonly attribute boolean requestShipping; + readonly attribute boolean requestBillingAddress; + readonly attribute AString shippingType; +}; + +[scriptable, builtinclass, uuid(2fa36783-d684-4487-b7a8-9def6ae3128f)] +interface nsIPaymentRequest : nsISupports +{ + readonly attribute uint64_t topOuterWindowId; + readonly attribute nsIPrincipal topLevelPrincipal; + readonly attribute AString requestId; + readonly attribute AString completeStatus; + readonly attribute nsIArray paymentMethods; + readonly attribute nsIPaymentDetails paymentDetails; + readonly attribute nsIPaymentOptions paymentOptions; + readonly attribute AString shippingOption; +}; diff --git a/dom/interfaces/payments/nsIPaymentRequestService.idl b/dom/interfaces/payments/nsIPaymentRequestService.idl new file mode 100644 index 0000000000..34c296df94 --- /dev/null +++ b/dom/interfaces/payments/nsIPaymentRequestService.idl @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsISupports.idl" +#include "nsIVariant.idl" +#include "nsIPaymentRequest.idl" +#include "nsIPaymentActionResponse.idl" +#include "nsIPaymentAddress.idl" +#include "nsISimpleEnumerator.idl" +#include "nsIPaymentUIService.idl" + +/** + * nsPaymentRequestService is used to manage the created PaymentRequest in the + * chrome process. It is also the IPC agent for payment UI to communicate with + * merchant side. + */ +[scriptable, builtinclass, uuid(cccd665f-edf3-41fc-ab9b-fc55b37340aa)] +interface nsIPaymentRequestService : nsISupports +{ + /** + * Get the nsIPaymentRequest through the given payment request identifier. + * @param aRequestId - the payment request identifier. + * This is an internal id generated by Gecko. + * @return - the requested payment request. null if there is no + * coressponding nsIPaymentRequest for aRequestId. + */ + nsIPaymentRequest getPaymentRequestById(in AString aRequestId); + + /** + * Get the enumerator for all managed nsIPaymentRequests. + * @return - an enumerator for all managed nsIPaymentRequests. + */ + nsISimpleEnumerator enumerate(); + + /** + * Send the user's response to the merchant. + * @param aResponse - the user's response. + */ + void respondPayment(in nsIPaymentActionResponse aResponse); + + /** + * Inform the merchant the shipping address has changed. + * @param requestId - the request identifier of the payment request. + * @param aAddress - the new payment address. + */ + void changeShippingAddress(in AString requestId, in nsIPaymentAddress aAddress); + + /** + * Inform the merchant the shipping option has changed. + * @param requestId - the request identifier of the payment request. + * @param option - the shipping option ID string. + */ + void changeShippingOption(in AString requestId, in AString option); + + /** + * Inform the merchant the payer's details changed in the PaymentResponse. + * @param requestId - the request identifier of the payment request. + * @param aPayerName - the changed payer's name. + * @param aPayerEmail - the changed payer's email. + * @param aPayerPhone - the changed payer's phone. + */ + void changePayerDetail(in AString requestId, + in AString aPayerName, + in AString aPayerEmail, + in AString aPayerPhone); + + /** + * Inform the merchant the payment method has changed. + * @param requestId - the request identifier of the payment request. + * @param aMethodName - the changed payment method's name. + * @param aMethodDetails - the changed payment method's details. + */ + void changePaymentMethod(in AString requestId, + in AString aMethodName, + in nsIMethodChangeDetails aMethodDetails); + + + /** + * Following APIs are for testing or platform code only. UI implementation + * should not use them. + */ + /** + * Clean up the all managed payment requests. + * This API is for testing only. + */ + void cleanup(); + + /** + * Setup the customized nsIPaymentUIService. + * This API is for testing only. + */ + void setTestingUIService(in nsIPaymentUIService aUIService); +}; + +%{C++ +#define NS_PAYMENT_REQUEST_SERVICE_CID \ + { 0xcccd665f, 0xedf3, 0x41fc, { 0xab, 0x9b, 0xfc, 0x55, 0xb3, 0x73, 0x40, 0xaa } } +#define NS_PAYMENT_REQUEST_SERVICE_CONTRACT_ID \ + "@mozilla.org/dom/payments/payment-request-service;1" +%} diff --git a/dom/interfaces/payments/nsIPaymentUIService.idl b/dom/interfaces/payments/nsIPaymentUIService.idl new file mode 100644 index 0000000000..21b181d6a1 --- /dev/null +++ b/dom/interfaces/payments/nsIPaymentUIService.idl @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsISupports.idl" +#include "nsIPaymentActionResponse.idl" + +/** + * nsIPaymentUIService is the interface used by Gecko to communicate with the + * payment UI. + * In general, the implementation of this interface should be a service that + * manages all payment UI components and receives the requested payment actions + * from Gecko and perform the corresponding UI behavior. + */ +[scriptable, uuid(01f8bd55-9017-438b-85ec-7c15d2b35cdc)] +interface nsIPaymentUIService : nsISupports +{ + /** + * Show the payment UI to users. + * The implementation gets the payment data through nsIPaymentRequestService + * by the passed in requestId, then shows the payment UI and start to interact + * with users. + * According to user's action, nsIPaymentRequestService's APIs respondPayment, + * changeShippingAddress, or changeShippingOtpion is possible to called in the + * implementation. + * @param requestId - the request identify of the payment request. + * Notice that this requestId is an internal request Id + * generated by Gecko + */ + void showPayment(in AString requestId); + + /** + * Abort the payment. + * The implementation must abort and close the showing payment UI then call + * nsIPaymentRequestService respondPayment with nsIPaymentAbortActionResponse + * to inform Gecko of the abort status. + * @param requestId - the request identify of the payment request. + * Notice that this requestId is an internal request Id + * generated by Gecko + */ + void abortPayment(in AString requestId); + + /** + * Complete the payment. + * The implementation should close the showing payment UI, then call + * nsIPaymentRequestService respondPayment with nsIPaymentCompleteActionResponse + * to inform Gecko of the complete status. + * @param requestId - the request identify of the payment request. + * Notice that this requestId is an internal request Id + * generated by Gecko + */ + void completePayment(in AString requestId); + + /** + * Update the payment data in the payment UI. + * The implementation should get the updated payment data through the + * nsIPaymentRequestService again, and update the UI. + * @param requestId - the request identify of the payment request. + * Notice that this requestId is an internal request Id + * generated by Gecko + */ + void updatePayment(in AString requestId); + + /** + * Close the payment UI for the specified PaymentRequest. + * The implementation should clean up the PaymentRequest data saved in the UI + * component and close the UI if the specified PaymentRequest is showing to + * the user. + * Notice when the method is called, that means the PaymentRequest is invalid + * in nsIPaymentRequestService. + * @param requestId - the request identify of the payment request. + * Notice that this requestId is an internal request Id + * generated by Gecko + */ + void closePayment(in AString requestId); + +}; + +%{C++ +#define NS_PAYMENT_UI_SERVICE_CID \ + { 0x01f8bd55, 0x9017, 0x438b, { 0x85, 0xec, 0x7c, 0x15, 0xd2, 0xb3, 0x5c, 0xdc } } +#define NS_PAYMENT_UI_SERVICE_CONTRACT_ID \ + "@mozilla.org/dom/payments/payment-ui-service;1" +%} -- cgit v1.2.3