summaryrefslogtreecommitdiffstats
path: root/dom/interfaces/payments/nsIPaymentActionResponse.idl
blob: 36d5be3b9403556532194ebec17a4d05d35e13d4 (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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
/* -*- 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 bool result;

  /**
   *  The initial method.
   *  @param aRequestId - the request identifier of the payment request.
   *  @param aResult - the canMakePayment result.
   */
  void init(in AString aRequestId, in bool 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
   */
  bool 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.
   */
  bool 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_GENERAL_RESPONSE_DATA_CID \
  { 0xb986773e, 0x2b30, 0x4ed2, { 0xb8, 0xfe, 0x6a, 0x96, 0x63, 0x1c, 0x80, 0x00 } }
#define NS_GENERAL_RESPONSE_DATA_CONTRACT_ID \
  "@mozilla.org/dom/payments/general-response-data;1"

#define NS_BASICCARD_RESPONSE_DATA_CID \
  { 0x0d55a5e6, 0xd185, 0x44f0, { 0xb9, 0x92, 0xa8, 0xe1, 0x32, 0x1e, 0x4b, 0xce } }
#define NS_BASICCARD_RESPONSE_DATA_CONTRACT_ID \
  "@mozilla.org/dom/payments/basiccard-response-data;1"

#define NS_PAYMENT_CANMAKE_ACTION_RESPONSE_CID \
  { 0x52fc3f9f, 0xc0cb, 0x4874, { 0xb3, 0xd4, 0xee, 0x4b, 0x6e, 0x9c, 0xbe, 0x9c } }
#define NS_PAYMENT_CANMAKE_ACTION_RESPONSE_CONTRACT_ID \
  "@mozilla.org/dom/payments/payment-canmake-action-response;1"

#define NS_PAYMENT_SHOW_ACTION_RESPONSE_CID \
  { 0x184385cb, 0x2d35, 0x4b99, { 0xa9, 0xa3, 0x7c, 0x78, 0x0b, 0xf6, 0x6b, 0x9b } }
#define NS_PAYMENT_SHOW_ACTION_RESPONSE_CONTRACT_ID \
  "@mozilla.org/dom/payments/payment-show-action-response;1"

#define NS_PAYMENT_ABORT_ACTION_RESPONSE_CID \
  { 0x8c72bcdb, 0x0c37, 0x4786, { 0xa9, 0xe5, 0x51, 0x0a, 0xfa, 0x2f, 0x8e, 0xde } }
#define NS_PAYMENT_ABORT_ACTION_RESPONSE_CONTRACT_ID \
  "@mozilla.org/dom/payments/payment-abort-action-response;1"

#define NS_PAYMENT_COMPLETE_ACTION_RESPONSE_CID \
  { 0x62c01e69, 0x9ca4, 0x4060, { 0x99, 0xe4, 0xb9, 0x5f, 0x62, 0x8c, 0x8e, 0x6d } }
#define NS_PAYMENT_COMPLETE_ACTION_RESPONSE_CONTRACT_ID \
  "@mozilla.org/dom/payments/payment-complete-action-response;1"

#define NS_GENERAL_CHANGE_DETAILS_CID \
  { 0xe031267e, 0xbec8, 0x4f3c, { 0xb0, 0xb1, 0x39, 0x6b, 0x77, 0xca, 0x26, 0x0c } }
#define NS_GENERAL_CHANGE_DETAILS_CONTRACT_ID \
  "@mozilla.org/dom/payments/general-change-details;1"

#define NS_BASICCARD_CHANGE_DETAILS_CID \
  { 0x5296f79e, 0x15ea, 0x40c3, { 0x81, 0x96, 0x19, 0xcf, 0xa6, 0x4d, 0x32, 0x8c } }
#define NS_BASICCARD_CHANGE_DETAILS_CONTRACT_ID \
  "@mozilla.org/dom/payments/basiccard-change-details;1"
%}