summaryrefslogtreecommitdiffstats
path: root/dom/interfaces/payments/nsIPaymentRequestService.idl
blob: 34c296df940402cefc54c8bd750667e43a173e31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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"
%}