summaryrefslogtreecommitdiffstats
path: root/dom/interfaces/payments/nsIPaymentActionResponse.idl
blob: c4a7ff19435ae33b45940b65c1724ff97c20e2b7 (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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
/* -*- 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 "nsIPaymentAddress.idl"

/**
 *  The base interface of response data for the specified payment method.
 *  The response data is the content of the PaymentResponse's detail attribute.
 */
[builtinclass, scriptable, uuid(2a338575-c688-40ee-a157-7488ab292ef2)]
interface nsIPaymentResponseData: nsISupports
{
  /**
   *  The consts for representing the response data type.
   *  GENERAL_RESPONSE is the general purpose response data type. Except basic
   *  card response data, all response data should belong to this type.
   *  BASICCARD_RESPONSE is a special response data type for basic card response.
   */
  const uint32_t GENERAL_RESPONSE = 0;
  const uint32_t BASICCARD_RESPONSE = 1;

  /**
   *  The response data type.
   *  Using the above defined consts(GENERAL_RESPONSE or BASICCARD_RESPONSE).
   */
  readonly attribute uint32_t type;

  /**
   *  The initial method.
   *  @param aType - the response data type.
   */
  void init(in uint32_t aType);
};

/**
 * The general purpose response data.
 */
[builtinclass, scriptable, uuid(b986773e-2b30-4ed2-b8fe-6a96631c8000)]
interface nsIGeneralResponseData : nsIPaymentResponseData
{
  /**
   *  The stringified response data.
   */
  readonly attribute AString data;

  /**
   *  The initial method for nsIGeneralResponseData.
   *  @param aData - the javascript object of the content.
   */
  [implicit_jscontext]
  void initData(in jsval aData);
};

/**
 *  The basic card response data.
 *  Since PaymentAddress is an no constructor interface type, UI code can not
 *  easy create PaymentAddress by calling new PaymentAddress().
 *  Unfortunately, BasicCardResponse has a PaymentAddress attribute, billingAddress
 *  , it means UI can not create BsaicCardResponse by calling the init() with a
 *  given JSObject directly, because PaymentAddress creation in JS code is hard.
 *  To let UI code can create BasicCardResponse easier, nsIBasicCardResponse is
 *  provided for UI by passing the raw data of BasicCardResponse,
 */
[builtinclass, scriptable, uuid(0d55a5e6-d185-44f0-b992-a8e1321e4bce)]
interface nsIBasicCardResponseData : nsIPaymentResponseData
{
  /**
   *  The cardholder name.
   */
  readonly attribute AString cardholderName;

  /**
   *  The card number.
   */
  readonly attribute AString cardNumber;

  /**
   *  The expiry month.
   */
  readonly attribute AString expiryMonth;

  /**
   *  The expiry year.
   */
  readonly attribute AString expiryYear;

  /**
   *  The card security number.
   */
  readonly attribute AString cardSecurityCode;

  /**
   *  The billing address.
   */
  readonly attribute nsIPaymentAddress billingAddress;

  /**
   *  The initial method for nsIBasicCardResponseData.
   *  @param aCardholderName   - the cardholder name.
   *  @param aCardNumber       - the card number.
   *  @param aExpiryMonth      - the expiry month.
   *  @param aExpiryYear       - the expiry year.
   *  @param aCardSecurityCode - the card security code.
   *  @param aBillingAddreess  - the billing address.
   */
  void initData(in AString aCardholderName,
                in AString aCardNumber,
                in AString aExpiryMonth,
                in AString aExpiryYear,
                in AString aCardSecurityCode,
                in nsIPaymentAddress billingAddress);
};

/**
 *  The base interface of user's response.
 *  Payment UI should create different sub-interface of nsIPaymentActionResponse
 *  according to user's action, and call nsIPaymentRequestService::respondPayment
 *  with the created action to inform the merchant.
 */
[builtinclass, scriptable, uuid(a607c095-ef60-4a9b-a3d0-0506c60728b3)]
interface nsIPaymentActionResponse : nsISupports
{
  /**
   *  The response type.
   *  Align type to nsIPaymentActionRequest types,
   *  where 1 is for payment request creation.
   *  the action expects no response from UI module.
   */
  const uint32_t NO_TYPE = 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;

  /**
   *  The abort status.
   */
  const uint32_t ABORT_SUCCEEDED = 1;
  const uint32_t ABORT_FAILED = 0;

  /**
   *  The payment status.
   */
  const uint32_t PAYMENT_REJECTED = 0;
  const uint32_t PAYMENT_ACCEPTED = 1;
  const uint32_t PAYMENT_NOTSUPPORTED = 2;

  /**
   *  The complete status.
   */
  const uint32_t COMPLETE_SUCCEEDED = 1;
  const uint32_t COMPLETE_FAILED = 0;

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

  /*
   *  The response type.
   */
  readonly attribute uint32_t type;
};

/**
 *  The response for canMakePayment action.
 */
[builtinclass, scriptable, uuid(52fc3f9f-c0cb-4874-b3d4-ee4b6e9cbe9c)]
interface nsIPaymentCanMakeActionResponse : nsIPaymentActionResponse
{
  /**
   *  The result of canMakePayment action.
   */
  readonly attribute boolean result;

  /**
   *  The initial method.
   *  @param aRequestId - the request identifier of the payment request.
   *  @param aResult - the canMakePayment result.
   */
  void init(in AString aRequestId, in boolean aResult);
};

/**
 *  The response for show action.
 *  Notice that to represent user's cancel, we should use nsIPaymentShowActionResponse
 *  with PAYMENT_REJECTED status, not nsIPaymentAbortActionResponse.
 */
[builtinclass, scriptable, uuid(184385cb-2d35-4b99-a9a3-7c780bf66b9b)]
interface nsIPaymentShowActionResponse : nsIPaymentActionResponse
{
  /**
   *  Accept status of the payment.
   *  Using the defined consts(PAYMENT_XXX) in nsIPaymentActionResponse.
   */
  readonly attribute uint32_t acceptStatus;

  /**
   *  The decided payment method name. i.e. "basic-card".
   */
  readonly attribute AString methodName;

  /**
   *  The data needed by the payment method. (it must be serializable)
   */
  readonly attribute nsIPaymentResponseData data;

  /**
   *  The payer name information.
   */
  readonly attribute AString payerName;

  /**
   *  The payer email information.
   */
  readonly attribute AString payerEmail;

  /**
   *  The payer phone information.
   */
  readonly attribute AString payerPhone;

  /**
   *  The initial method.
   *  @param aRequestId - the request identifier of the payment request.
   *  @param aAcceptStatus - the payment status.
   *  @param aMethodName - the decided method name.
   *  @param aData - the response data for the decided payment method.
   *  @param aPayerName - the payer's name.
   *  @param aPayerEmail - the payer's email.
   *  @param aPayerPhone - the payer's phone.
   */
  void init(in AString aRequestId,
            in uint32_t aAcceptStatus,
            in AString aMethodName,
            in nsIPaymentResponseData aData,
            in AString aPayerName,
            in AString aPayerEmail,
            in AString aPayerPhone);
};

/**
 *  The response for abort action.
 */
[builtinclass, scriptable, uuid(8c72bcdb-0c37-4786-a9e5-510afa2f8ede)]
interface nsIPaymentAbortActionResponse : nsIPaymentActionResponse
{
  /**
   *  The abort action status.
   *  Using the defined consts(ABORT_XXX) in nsIPaymentActionResponse.
   */
  readonly attribute uint32_t abortStatus;

  /**
   *  The Initial method.
   *  @param aRequestId - the request identifier of payment request.
   *  @param aAbortStatus - the abort action result.
   */
  void init(in AString aRequestId, in uint32_t aAbortStatus);

  /**
   *  Check if the abort action is succeeded
   */
  boolean isSucceeded();
};

[builtinclass, scriptable, uuid(62c01e69-9ca4-4060-99e4-b95f628c8e6d)]
interface nsIPaymentCompleteActionResponse : nsIPaymentActionResponse
{
  /**
   *  The complete action status.
   *  Using the defined consts(COMPLETE_XXX) in nsIPaymentActionResponse.
   */
  readonly attribute uint32_t completeStatus;

  /**
   *  The Initial method.
   *  @param aRequestId - the request identifier of payment request.
   *  @param aCompleteStatus - the complete action result.
   */
  void init(in AString aRequestId,
            in uint32_t aCompleteStatus);

  /**
   *  Check if the complete action is succeeded.
   */
  boolean isCompleted();
};

[builtinclass, scriptable, uuid(2035e0a9-c9ab-4c9f-b8e9-28b2ed61548c)]
interface nsIMethodChangeDetails : nsISupports
{
  /**
   *  The consts for representing the method change details data type.
   *  GENERAL_DETAILS is the general purpose details data type. Except basic
   *  card details, all details should belong to this type.
   *  BASICCARD_DETAILS is a special details data type for basic card change
   *  details.
   */
  const uint32_t GENERAL_DETAILS = 0;
  const uint32_t BASICCARD_DETAILS = 1;

  /**
   *  The method change details data type.
   *  Using the above defined consts(GENERAL_DETAILS or BASICCARD_DETAILS).
   */
  readonly attribute uint32_t type;

  /**
   *  The initial method.
   *  @param aType - the method change details data type.
   */
  void init(in uint32_t aType);
};

/**
 * The general purpose method change details.
 */
[builtinclass, scriptable, uuid(e031267e-bec8-4f3c-b0b1-396b77ca260c)]
interface nsIGeneralChangeDetails : nsIMethodChangeDetails
{
  /**
   *  The stringified change details.
   */
  readonly attribute AString details;

  /**
   *  The initial method for nsIGeneralChangeDetails.
   *  @param aData - the javascript object of the content.
   */
  [implicit_jscontext]
  void initData(in jsval aDetails);
};

/**
 *  The basic card change details.
 *  Since PaymentAddress is an no constructor interface type, UI code can not
 *  easy create PaymentAddress by calling new PaymentAddress().
 *  Unfortunately, BasicCardResponse has a PaymentAddress attribute, billingAddress
 *  , it means UI can not create BsaicCardChangeDetails by calling the init() with a
 *  given JSObject directly, because PaymentAddress creation in JS code is hard.
 *  To let UI code can create BasicCardResponse easier, nsIBasicCardResponse is
 *  provided for UI by passing the raw data of BasicCardResponse,
 */
[builtinclass, scriptable, uuid(5296f79e-15ea-40c3-8196-19cfa64d328c)]
interface nsIBasicCardChangeDetails : nsIMethodChangeDetails
{
  /**
   *  The billing address.
   */
  readonly attribute nsIPaymentAddress billingAddress;

  /**
   *  The initial method for nsIBasicCardChangeDetails.
   *  @param aBillingAddreess  - the billing address.
   */
  void initData(in nsIPaymentAddress billingAddress);
};


%{C++
#define NS_PAYMENT_CANMAKE_ACTION_RESPONSE_CONTRACT_ID \
  "@mozilla.org/dom/payments/payment-canmake-action-response;1"

#define NS_PAYMENT_SHOW_ACTION_RESPONSE_CONTRACT_ID \
  "@mozilla.org/dom/payments/payment-show-action-response;1"
%}