summaryrefslogtreecommitdiffstats
path: root/dom/payments/ipc/PPaymentRequest.ipdl
blob: 1ac968887c5fd5a373d08e93e3c0fd4ff22bd0db (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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=4 ts=8 et tw=80 ft=cpp : */
/* 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 protocol PBrowser;

include "mozilla/dom/PermissionMessageUtils.h";

[RefCounted] using class nsIPrincipal from "nsIPrincipal.h";

namespace mozilla {
namespace dom {

struct IPCPaymentMethodData
{
  nsString supportedMethods;
  nsString data;
};

struct IPCPaymentCurrencyAmount
{
  nsString currency;
  nsString value;
};

struct IPCPaymentItem
{
  nsString label;
  IPCPaymentCurrencyAmount amount;
  bool pending;
};

struct IPCPaymentDetailsModifier
{
  nsString supportedMethods;
  IPCPaymentItem total;
  IPCPaymentItem[] additionalDisplayItems;
  nsString data;
  bool additionalDisplayItemsPassed;
};

struct IPCPaymentShippingOption
{
  nsString id;
  nsString label;
  IPCPaymentCurrencyAmount amount;
  bool selected;
};

struct IPCPaymentDetails
{
  nsString id;
  IPCPaymentItem total;
  IPCPaymentItem[] displayItems;
  IPCPaymentShippingOption[] shippingOptions;
  IPCPaymentDetailsModifier[] modifiers;
  nsString error;
  nsString shippingAddressErrors;
  nsString payerErrors;
  nsString paymentMethodErrors;
};

struct IPCPaymentOptions
{
  bool requestPayerName;
  bool requestPayerEmail;
  bool requestPayerPhone;
  bool requestShipping;
  bool requestBillingAddress;
  nsString shippingType;
};

struct IPCPaymentCreateActionRequest
{
  uint64_t topOuterWindowId;
  nsString requestId;
  nullable nsIPrincipal topLevelPrincipal;
  IPCPaymentMethodData[] methodData;
  IPCPaymentDetails details;
  IPCPaymentOptions options;
  nsString shippingOption;
};

struct IPCPaymentCanMakeActionRequest
{
  nsString requestId;
};

struct IPCPaymentShowActionRequest
{
  nsString requestId;
  bool isUpdating;
};

struct IPCPaymentAbortActionRequest
{
  nsString requestId;
};

struct IPCPaymentCompleteActionRequest
{
  nsString requestId;
  nsString completeStatus;
};

struct IPCPaymentUpdateActionRequest
{
  nsString requestId;
  IPCPaymentDetails details;
  nsString shippingOption;
};

struct IPCPaymentCloseActionRequest
{
  nsString requestId;
};

struct IPCPaymentRetryActionRequest
{
  nsString requestId;
  nsString error;
  nsString payerErrors;
  nsString paymentMethodErrors;
  nsString shippingAddressErrors;
};

union IPCPaymentActionRequest
{
  IPCPaymentCreateActionRequest;
  IPCPaymentCanMakeActionRequest;
  IPCPaymentShowActionRequest;
  IPCPaymentAbortActionRequest;
  IPCPaymentCompleteActionRequest;
  IPCPaymentUpdateActionRequest;
  IPCPaymentCloseActionRequest;
  IPCPaymentRetryActionRequest;
};

struct IPCPaymentCanMakeActionResponse
{
  nsString requestId;
  bool result;
};

struct IPCPaymentAddress
{
  nsString country;
  nsString[] addressLine;
  nsString region;
  nsString regionCode;
  nsString city;
  nsString dependentLocality;
  nsString postalCode;
  nsString sortingCode;
  nsString organization;
  nsString recipient;
  nsString phone;
};

struct IPCGeneralResponse
{
  nsString data;
};

struct IPCBasicCardResponse
{
  nsString cardholderName;
  nsString cardNumber;
  nsString expiryMonth;
  nsString expiryYear;
  nsString cardSecurityCode;
  IPCPaymentAddress billingAddress;
};

union IPCPaymentResponseData
{
  IPCGeneralResponse;
  IPCBasicCardResponse;
};

struct IPCPaymentShowActionResponse
{
  nsString requestId;
  uint32_t status;
  nsString methodName;
  IPCPaymentResponseData data;
  nsString payerName;
  nsString payerEmail;
  nsString payerPhone;
};

struct IPCPaymentAbortActionResponse
{
  nsString requestId;
  bool isSucceeded;
};

struct IPCPaymentCompleteActionResponse
{
  nsString requestId;
  bool isCompleted;
};

union IPCPaymentActionResponse
{
  IPCPaymentCanMakeActionResponse;
  IPCPaymentShowActionResponse;
  IPCPaymentAbortActionResponse;
  IPCPaymentCompleteActionResponse;
};

struct IPCGeneralChangeDetails
{
  nsString details;
};

struct IPCBasicCardChangeDetails
{
  IPCPaymentAddress billingAddress;
};

union IPCMethodChangeDetails
{
  IPCGeneralChangeDetails;
  IPCBasicCardChangeDetails;
};

[ManualDealloc]
sync protocol PPaymentRequest
{
  manager PBrowser;

parent:
  async __delete__();

  async RequestPayment(IPCPaymentActionRequest aAction);

child:
  async RespondPayment(IPCPaymentActionResponse aResponse);
  async ChangeShippingAddress(nsString aRequestId,
                              IPCPaymentAddress aAddress);
  async ChangeShippingOption(nsString aRequestId,
                             nsString aOption);
  async ChangePayerDetail(nsString aRequestId,
                          nsString aPayerName,
                          nsString aPayerEmail,
                          nsString aPayerPhone);
  async ChangePaymentMethod(nsString aRequestId,
                            nsString aMethodName,
                            IPCMethodChangeDetails aMethodDetails);
};

} // end of namespace dom
} // end of namespace mozilla