1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_PaymentRequestService_h
8 #define mozilla_dom_PaymentRequestService_h
10 #include "nsInterfaceHashtable.h"
11 #include "nsIPaymentRequestService.h"
14 #include "PaymentRequestData.h"
16 namespace mozilla::dom
{
18 // The implmentation of nsIPaymentRequestService
20 class PaymentRequestService final
: public nsIPaymentRequestService
{
23 NS_DECL_NSIPAYMENTREQUESTSERVICE
25 PaymentRequestService() = default;
27 static already_AddRefed
<PaymentRequestService
> GetSingleton();
29 already_AddRefed
<payments::PaymentRequest
> GetPaymentRequestByIndex(
30 const uint32_t index
);
32 uint32_t NumPayments() const;
34 nsresult
RequestPayment(const nsAString
& aRequestId
,
35 const IPCPaymentActionRequest
& aAction
,
36 PaymentRequestParent
* aCallback
);
39 ~PaymentRequestService() = default;
41 nsresult
GetPaymentRequestById(const nsAString
& aRequestId
,
42 payments::PaymentRequest
** aRequest
);
44 nsresult
LaunchUIAction(const nsAString
& aRequestId
, uint32_t aActionType
);
46 bool CanMakePayment(const nsAString
& aRequestId
);
48 nsresult
ShowPayment(const nsAString
& aRequestId
, bool aIsUpdating
);
50 bool IsBasicCardPayment(const nsAString
& aRequestId
);
52 FallibleTArray
<RefPtr
<payments::PaymentRequest
>> mRequestQueue
;
54 nsCOMPtr
<nsIPaymentUIService
> mTestingUIService
;
56 RefPtr
<payments::PaymentRequest
> mShowingRequest
;
59 } // namespace mozilla::dom