/* -*- 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"

interface nsIArray;

[builtinclass, uuid(3fef5459-b0ea-469b-be9f-b99e8ca75d3d)]
interface nsIPaymentActionCallback : nsISupports
{
  void respondPayment(in nsIPaymentActionResponse aResponse);
  void changeShippingAddress(in AString aRequestId, in nsIPaymentAddress aAddress);
  void changeShippingOption(in AString aRequestId, in AString aOption);
};

[builtinclass, uuid(7ddbe8be-beac-4952-96f6-619981dff7a6)]
interface nsIPaymentActionRequest : nsISupports
{
  const uint32_t UNKNOWN_ACTION = 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;
  const uint32_t UPDATE_ACTION = 6;

  /*
   *  The payment request identifier.
   */
  readonly attribute AString requestId;

  /*
   *  The type of the requested task.
   */
  readonly attribute uint32_t type;

  /*
   *  The callback for the response from UI module
   */
  readonly attribute nsIPaymentActionCallback callback;

  /*
   *  Initialize function for this request.
   */
  void init(in AString aRequestId,
            in uint32_t aType,
            in nsIPaymentActionCallback aCallback);
};

[builtinclass, uuid(1d38dce6-8bcd-441b-aa94-68e300b6e175)]
interface nsIPaymentCreateActionRequest : nsIPaymentActionRequest
{
  /*
   *  The tab identifier
   */
  readonly attribute uint64_t tabId;

  /*
   *  The top level document's principal
   */
  readonly attribute nsIPrincipal topLevelPrincipal;

  /*
   *  The methodData information of the payment request.
   */
  readonly attribute nsIArray methodData;

  /*
   *  The Details information of the payment request.
   */
  readonly attribute nsIPaymentDetails details;

  /*
   *  The Options information of the payment request.
   */
  readonly attribute nsIPaymentOptions options;

  /*
   *  Initialize function the this request.
   */
  void initRequest(in AString aRequestId,
                   in nsIPaymentActionCallback aCallback,
                   in uint64_t aTabId,
                   in nsIPrincipal aPrincipal,
                   in nsIArray aMethodData,
                   in nsIPaymentDetails aDetails,
                   in nsIPaymentOptions aOptions);
};

[builtinclass, uuid(4429697d-1135-47de-a46e-5196d399ec55)]
interface nsIPaymentCompleteActionRequest : nsIPaymentActionRequest
{
  /*
   *  The complete status from merchant side.
   */
  readonly attribute AString completeStatus;

  /*
   *  Initialize function for this request.
   */
  void initRequest(in AString aRequestId,
                   in nsIPaymentActionCallback aCallback,
                   in AString aCompleteStatus);
};

[builtinclass, uuid(21f631e8-c047-4fd8-b3c6-68e26c62639a)]
interface nsIPaymentUpdateActionRequest : nsIPaymentActionRequest
{
  /*
   *  The details information for updating the specified payment request.
   */
  readonly attribute nsIPaymentDetails details;

  /*
   *  Initialize function for this request.
   */
  void initRequest(in AString aRequestId,
                   in nsIPaymentActionCallback aCallback,
                   in nsIPaymentDetails aDetails);
};

%{C++
#define NS_PAYMENT_ACTION_REQUEST_CID \
  { 0x7ddbe8be, 0xbeac, 0x4952, { 0x96, 0xf6, 0x61, 0x99, 0x81, 0xdf, 0xf7, 0xa6 } }
#define NS_PAYMENT_ACTION_REQUEST_CONTRACT_ID \
  "@mozilla.org/dom/payments/payment-action-request;1"

#define NS_PAYMENT_CREATE_ACTION_REQUEST_CID \
  { 0x1d38dce6, 0x8bcd, 0x441b, { 0xaa, 0x94, 0x68, 0xe3, 0x00, 0xb6, 0xe1, 0x75 } }
#define NS_PAYMENT_CREATE_ACTION_REQUEST_CONTRACT_ID \
  "@mozilla.org/dom/payments/payment-create-action-request;1"

#define NS_PAYMENT_COMPLETE_ACTION_REQUEST_CID \
  { 0x4429697d, 0x1135, 0x47de, { 0xa4, 0x6e, 0x51, 0x96, 0xd3, 0x99, 0xec, 0x55 } }
#define NS_PAYMENT_COMPLETE_ACTION_REQUEST_CONTRACT_ID \
  "@mozilla.org/dom/payments/payment-complete-action-request;1"

#define NS_PAYMENT_UPDATE_ACTION_REQUEST_CID \
  { 0x21f631e8, 0xc047, 0x4fd8, { 0xb3, 0xc6, 0x68, 0xe2, 0x6c, 0x62, 0x63, 0x9a } }
#define NS_PAYMENT_UPDATE_ACTION_REQUEST_CONTRACT_ID \
  "@mozilla.org/dom/payments/payment-update-action-request;1"
%}
