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"
19 // The implmentation of nsIPaymentRequestService
21 class PaymentRequestService final
: public nsIPaymentRequestService
{
24 NS_DECL_NSIPAYMENTREQUESTSERVICE
26 PaymentRequestService() = default;
28 static already_AddRefed
<PaymentRequestService
> GetSingleton();
30 already_AddRefed
<payments::PaymentRequest
> GetPaymentRequestByIndex(
31 const uint32_t index
);
33 uint32_t NumPayments() const;
35 nsresult
RequestPayment(const nsAString
& aRequestId
,
36 const IPCPaymentActionRequest
& aAction
,
37 PaymentRequestParent
* aCallback
);
40 ~PaymentRequestService() = default;
42 nsresult
GetPaymentRequestById(const nsAString
& aRequestId
,
43 payments::PaymentRequest
** aRequest
);
45 nsresult
LaunchUIAction(const nsAString
& aRequestId
, uint32_t aActionType
);
47 bool CanMakePayment(const nsAString
& aRequestId
);
49 nsresult
ShowPayment(const nsAString
& aRequestId
, bool aIsUpdating
);
51 bool IsBasicCardPayment(const nsAString
& aRequestId
);
53 FallibleTArray
<RefPtr
<payments::PaymentRequest
>> mRequestQueue
;
55 nsCOMPtr
<nsIPaymentUIService
> mTestingUIService
;
57 RefPtr
<payments::PaymentRequest
> mShowingRequest
;
60 } // end of namespace dom
61 } // end of namespace mozilla