1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2/* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6#include "nsISupports.idl" 7#include "nsIVariant.idl" 8#include "nsIPaymentAddress.idl" 9 10/** 11 * The base interface of response data for the specified payment method. 12 * The response data is the content of the PaymentResponse's detail attribute. 13 */ 14[builtinclass, scriptable, uuid(2a338575-c688-40ee-a157-7488ab292ef2)] 15interface nsIPaymentResponseData: nsISupports 16{ 17 /** 18 * The consts for representing the response data type. 19 * GENERAL_RESPONSE is the general purpose response data type. Except basic 20 * card response data, all response data should belong to this type. 21 * BASICCARD_RESPONSE is a special response data type for basic card response. 22 */ 23 const uint32_t GENERAL_RESPONSE = 0; 24 const uint32_t BASICCARD_RESPONSE = 1; 25 26 /** 27 * The response data type. 28 * Using the above defined consts(GENERAL_RESPONSE or BASICCARD_RESPONSE). 29 */ 30 readonly attribute uint32_t type; 31 32 /** 33 * The initial method. 34 * @param aType - the response data type. 35 */ 36 void init(in uint32_t aType); 37}; 38 39/** 40 * The general purpose response data. 41 */ 42[builtinclass, scriptable, uuid(b986773e-2b30-4ed2-b8fe-6a96631c8000)] 43interface nsIGeneralResponseData : nsIPaymentResponseData 44{ 45 /** 46 * The stringified response data. 47 */ 48 readonly attribute AString data; 49 50 /** 51 * The initial method for nsIGeneralResponseData. 52 * @param aData - the javascript object of the content. 53 */ 54 [implicit_jscontext] 55 void initData(in jsval aData); 56}; 57 58/** 59 * The basic card response data. 60 * Since PaymentAddress is an no constructor interface type, UI code can not 61 * easy create PaymentAddress by calling new PaymentAddress(). 62 * Unfortunately, BasicCardResponse has a PaymentAddress attribute, billingAddress 63 * , it means UI can not create BsaicCardResponse by calling the init() with a 64 * given JSObject directly, because PaymentAddress creation in JS code is hard. 65 * To let UI code can create BasicCardResponse easier, nsIBasicCardResponse is 66 * provided for UI by passing the raw data of BasicCardResponse, 67 */ 68[builtinclass, scriptable, uuid(0d55a5e6-d185-44f0-b992-a8e1321e4bce)] 69interface nsIBasicCardResponseData : nsIPaymentResponseData 70{ 71 /** 72 * The cardholder name. 73 */ 74 readonly attribute AString cardholderName; 75 76 /** 77 * The card number. 78 */ 79 readonly attribute AString cardNumber; 80 81 /** 82 * The expiry month. 83 */ 84 readonly attribute AString expiryMonth; 85 86 /** 87 * The expiry year. 88 */ 89 readonly attribute AString expiryYear; 90 91 /** 92 * The card security number. 93 */ 94 readonly attribute AString cardSecurityCode; 95 96 /** 97 * The billing address. 98 */ 99 readonly attribute nsIPaymentAddress billingAddress; 100 101 /** 102 * The initial method for nsIBasicCardResponseData. 103 * @param aCardholderName - the cardholder name. 104 * @param aCardNumber - the card number. 105 * @param aExpiryMonth - the expiry month. 106 * @param aExpiryYear - the expiry year. 107 * @param aCardSecurityCode - the card security code. 108 * @param aBillingAddreess - the billing address. 109 */ 110 void initData(in AString aCardholderName, 111 in AString aCardNumber, 112 in AString aExpiryMonth, 113 in AString aExpiryYear, 114 in AString aCardSecurityCode, 115 in nsIPaymentAddress billingAddress); 116}; 117 118/** 119 * The base interface of user's response. 120 * Payment UI should create different sub-interface of nsIPaymentActionResponse 121 * according to user's action, and call nsIPaymentRequestService::respondPayment 122 * with the created action to inform the merchant. 123 */ 124[builtinclass, scriptable, uuid(a607c095-ef60-4a9b-a3d0-0506c60728b3)] 125interface nsIPaymentActionResponse : nsISupports 126{ 127 /** 128 * The response type. 129 * Align type to nsIPaymentActionRequest types, 130 * where 1 is for payment request creation. 131 * the action expects no response from UI module. 132 */ 133 const uint32_t NO_TYPE = 0; 134 // const uint32_t CREATE_ACTION = 1; 135 const uint32_t CANMAKE_ACTION = 2; 136 const uint32_t SHOW_ACTION = 3; 137 const uint32_t ABORT_ACTION = 4; 138 const uint32_t COMPLETE_ACTION = 5; 139 140 /** 141 * The abort status. 142 */ 143 const uint32_t ABORT_SUCCEEDED = 1; 144 const uint32_t ABORT_FAILED = 0; 145 146 /** 147 * The payment status. 148 */ 149 const uint32_t PAYMENT_REJECTED = 0; 150 const uint32_t PAYMENT_ACCEPTED = 1; 151 const uint32_t PAYMENT_NOTSUPPORTED = 2; 152 153 /** 154 * The complete status. 155 */ 156 const uint32_t COMPLETE_SUCCEEDED = 1; 157 const uint32_t COMPLETE_FAILED = 0; 158 159 /* 160 * The payment request identity. 161 */ 162 readonly attribute AString requestId; 163 164 /* 165 * The response type. 166 */ 167 readonly attribute uint32_t type; 168}; 169 170/** 171 * The response for canMakePayment action. 172 */ 173[builtinclass, scriptable, uuid(52fc3f9f-c0cb-4874-b3d4-ee4b6e9cbe9c)] 174interface nsIPaymentCanMakeActionResponse : nsIPaymentActionResponse 175{ 176 /** 177 * The result of canMakePayment action. 178 */ 179 readonly attribute bool result; 180 181 /** 182 * The initial method. 183 * @param aRequestId - the request identifier of the payment request. 184 * @param aResult - the canMakePayment result. 185 */ 186 void init(in AString aRequestId, in bool aResult); 187}; 188 189/** 190 * The response for show action. 191 * Notice that to represent user's cancel, we should use nsIPaymentShowActionResponse 192 * with PAYMENT_REJECTED status, not nsIPaymentAbortActionResponse. 193 */ 194[builtinclass, scriptable, uuid(184385cb-2d35-4b99-a9a3-7c780bf66b9b)] 195interface nsIPaymentShowActionResponse : nsIPaymentActionResponse 196{ 197 /** 198 * Accept status of the payment. 199 * Using the defined consts(PAYMENT_XXX) in nsIPaymentActionResponse. 200 */ 201 readonly attribute uint32_t acceptStatus; 202 203 /** 204 * The decided payment method name. i.e. "basic-card". 205 */ 206 readonly attribute AString methodName; 207 208 /** 209 * The data needed by the payment method. (it must be serializable) 210 */ 211 readonly attribute nsIPaymentResponseData data; 212 213 /** 214 * The payer name information. 215 */ 216 readonly attribute AString payerName; 217 218 /** 219 * The payer email information. 220 */ 221 readonly attribute AString payerEmail; 222 223 /** 224 * The payer phone information. 225 */ 226 readonly attribute AString payerPhone; 227 228 /** 229 * The initial method. 230 * @param aRequestId - the request identifier of the payment request. 231 * @param aAcceptStatus - the payment status. 232 * @param aMethodName - the decided method name. 233 * @param aData - the response data for the decided payment method. 234 * @param aPayerName - the payer's name. 235 * @param aPayerEmail - the payer's email. 236 * @param aPayerPhone - the payer's phone. 237 */ 238 void init(in AString aRequestId, 239 in uint32_t aAcceptStatus, 240 in AString aMethodName, 241 in nsIPaymentResponseData aData, 242 in AString aPayerName, 243 in AString aPayerEmail, 244 in AString aPayerPhone); 245}; 246 247/** 248 * The response for abort action. 249 */ 250[builtinclass, scriptable, uuid(8c72bcdb-0c37-4786-a9e5-510afa2f8ede)] 251interface nsIPaymentAbortActionResponse : nsIPaymentActionResponse 252{ 253 /** 254 * The abort action status. 255 * Using the defined consts(ABORT_XXX) in nsIPaymentActionResponse. 256 */ 257 readonly attribute uint32_t abortStatus; 258 259 /** 260 * The Initial method. 261 * @param aRequestId - the request identifier of payment request. 262 * @param aAbortStatus - the abort action result. 263 */ 264 void init(in AString aRequestId, in uint32_t aAbortStatus); 265 266 /** 267 * Check if the abort action is succeeded 268 */ 269 bool isSucceeded(); 270}; 271 272[builtinclass, scriptable, uuid(62c01e69-9ca4-4060-99e4-b95f628c8e6d)] 273interface nsIPaymentCompleteActionResponse : nsIPaymentActionResponse 274{ 275 /** 276 * The complete action status. 277 * Using the defined consts(COMPLETE_XXX) in nsIPaymentActionResponse. 278 */ 279 readonly attribute uint32_t completeStatus; 280 281 /** 282 * The Initial method. 283 * @param aRequestId - the request identifier of payment request. 284 * @param aCompleteStatus - the complete action result. 285 */ 286 void init(in AString aRequestId, 287 in uint32_t aCompleteStatus); 288 289 /** 290 * Check if the complete action is succeeded. 291 */ 292 bool isCompleted(); 293}; 294 295[builtinclass, scriptable, uuid(2035e0a9-c9ab-4c9f-b8e9-28b2ed61548c)] 296interface nsIMethodChangeDetails : nsISupports 297{ 298 /** 299 * The consts for representing the method change details data type. 300 * GENERAL_DETAILS is the general purpose details data type. Except basic 301 * card details, all details should belong to this type. 302 * BASICCARD_DETAILS is a special details data type for basic card change 303 * details. 304 */ 305 const uint32_t GENERAL_DETAILS = 0; 306 const uint32_t BASICCARD_DETAILS = 1; 307 308 /** 309 * The method change details data type. 310 * Using the above defined consts(GENERAL_DETAILS or BASICCARD_DETAILS). 311 */ 312 readonly attribute uint32_t type; 313 314 /** 315 * The initial method. 316 * @param aType - the method change details data type. 317 */ 318 void init(in uint32_t aType); 319}; 320 321/** 322 * The general purpose method change details. 323 */ 324[builtinclass, scriptable, uuid(e031267e-bec8-4f3c-b0b1-396b77ca260c)] 325interface nsIGeneralChangeDetails : nsIMethodChangeDetails 326{ 327 /** 328 * The stringified change details. 329 */ 330 readonly attribute AString details; 331 332 /** 333 * The initial method for nsIGeneralChangeDetails. 334 * @param aData - the javascript object of the content. 335 */ 336 [implicit_jscontext] 337 void initData(in jsval aDetails); 338}; 339 340/** 341 * The basic card change details. 342 * Since PaymentAddress is an no constructor interface type, UI code can not 343 * easy create PaymentAddress by calling new PaymentAddress(). 344 * Unfortunately, BasicCardResponse has a PaymentAddress attribute, billingAddress 345 * , it means UI can not create BsaicCardChangeDetails by calling the init() with a 346 * given JSObject directly, because PaymentAddress creation in JS code is hard. 347 * To let UI code can create BasicCardResponse easier, nsIBasicCardResponse is 348 * provided for UI by passing the raw data of BasicCardResponse, 349 */ 350[builtinclass, scriptable, uuid(5296f79e-15ea-40c3-8196-19cfa64d328c)] 351interface nsIBasicCardChangeDetails : nsIMethodChangeDetails 352{ 353 /** 354 * The billing address. 355 */ 356 readonly attribute nsIPaymentAddress billingAddress; 357 358 /** 359 * The initial method for nsIBasicCardChangeDetails. 360 * @param aBillingAddreess - the billing address. 361 */ 362 void initData(in nsIPaymentAddress billingAddress); 363}; 364 365 366%{C++ 367#define NS_GENERAL_RESPONSE_DATA_CID \ 368 { 0xb986773e, 0x2b30, 0x4ed2, { 0xb8, 0xfe, 0x6a, 0x96, 0x63, 0x1c, 0x80, 0x00 } } 369#define NS_GENERAL_RESPONSE_DATA_CONTRACT_ID \ 370 "@mozilla.org/dom/payments/general-response-data;1" 371 372#define NS_BASICCARD_RESPONSE_DATA_CID \ 373 { 0x0d55a5e6, 0xd185, 0x44f0, { 0xb9, 0x92, 0xa8, 0xe1, 0x32, 0x1e, 0x4b, 0xce } } 374#define NS_BASICCARD_RESPONSE_DATA_CONTRACT_ID \ 375 "@mozilla.org/dom/payments/basiccard-response-data;1" 376 377#define NS_PAYMENT_CANMAKE_ACTION_RESPONSE_CID \ 378 { 0x52fc3f9f, 0xc0cb, 0x4874, { 0xb3, 0xd4, 0xee, 0x4b, 0x6e, 0x9c, 0xbe, 0x9c } } 379#define NS_PAYMENT_CANMAKE_ACTION_RESPONSE_CONTRACT_ID \ 380 "@mozilla.org/dom/payments/payment-canmake-action-response;1" 381 382#define NS_PAYMENT_SHOW_ACTION_RESPONSE_CID \ 383 { 0x184385cb, 0x2d35, 0x4b99, { 0xa9, 0xa3, 0x7c, 0x78, 0x0b, 0xf6, 0x6b, 0x9b } } 384#define NS_PAYMENT_SHOW_ACTION_RESPONSE_CONTRACT_ID \ 385 "@mozilla.org/dom/payments/payment-show-action-response;1" 386 387#define NS_PAYMENT_ABORT_ACTION_RESPONSE_CID \ 388 { 0x8c72bcdb, 0x0c37, 0x4786, { 0xa9, 0xe5, 0x51, 0x0a, 0xfa, 0x2f, 0x8e, 0xde } } 389#define NS_PAYMENT_ABORT_ACTION_RESPONSE_CONTRACT_ID \ 390 "@mozilla.org/dom/payments/payment-abort-action-response;1" 391 392#define NS_PAYMENT_COMPLETE_ACTION_RESPONSE_CID \ 393 { 0x62c01e69, 0x9ca4, 0x4060, { 0x99, 0xe4, 0xb9, 0x5f, 0x62, 0x8c, 0x8e, 0x6d } } 394#define NS_PAYMENT_COMPLETE_ACTION_RESPONSE_CONTRACT_ID \ 395 "@mozilla.org/dom/payments/payment-complete-action-response;1" 396 397#define NS_GENERAL_CHANGE_DETAILS_CID \ 398 { 0xe031267e, 0xbec8, 0x4f3c, { 0xb0, 0xb1, 0x39, 0x6b, 0x77, 0xca, 0x26, 0x0c } } 399#define NS_GENERAL_CHANGE_DETAILS_CONTRACT_ID \ 400 "@mozilla.org/dom/payments/general-change-details;1" 401 402#define NS_BASICCARD_CHANGE_DETAILS_CID \ 403 { 0x5296f79e, 0x15ea, 0x40c3, { 0x81, 0x96, 0x19, 0xcf, 0xa6, 0x4d, 0x32, 0x8c } } 404#define NS_BASICCARD_CHANGE_DETAILS_CONTRACT_ID \ 405 "@mozilla.org/dom/payments/basiccard-change-details;1" 406%} 407