@@ -14,6 +14,7 @@ import {
14
14
} from './core'
15
15
import { FormattedPrice , Price } from './price'
16
16
import { ProductComponents } from './pcm'
17
+ import { XOR } from './util'
17
18
18
19
export interface OrderAddressBase {
19
20
first_name : string
@@ -191,14 +192,158 @@ export interface OrderItem extends Identifiable, OrderItemBase {
191
192
catalog_source ?: 'pim'
192
193
}
193
194
195
+ export type PurchasePaymentMethod = 'purchase'
196
+ export type AuthorizePaymentMethod = 'authorize'
197
+ export type CapturePaymentMethod = 'capture'
198
+ export type RefundPaymentMethod = 'refund'
199
+
200
+ export type PaymentMethod =
201
+ | PurchasePaymentMethod
202
+ | AuthorizePaymentMethod
203
+ | CapturePaymentMethod
204
+ | RefundPaymentMethod
205
+
206
+ interface PaymentBase {
207
+ payment : string
208
+ }
209
+
210
+ export interface AdyenPayment extends PaymentBase {
211
+ method : PurchasePaymentMethod | AuthorizePaymentMethod | CapturePaymentMethod
212
+ gateway : 'adyen'
213
+ options : {
214
+ shopper_reference : string
215
+ recurring_processing_model ?: string
216
+ }
217
+ }
218
+
219
+ export interface AuthorizeNetPayment extends PaymentBase {
220
+ method : PurchasePaymentMethod | AuthorizePaymentMethod | CapturePaymentMethod
221
+ gateway : 'authorize_net'
222
+ options : {
223
+ customer_payment_profile_id : string
224
+ }
225
+ }
226
+
227
+ /** Braintree Payment **/
228
+
229
+ type BraintreePaymentOptions = XOR <
230
+ { payment_method_nonce : true } ,
231
+ { payment_method_token : true }
232
+ > & {
233
+ custom_fields ?: Record < string , string >
234
+ }
235
+
236
+ export interface BraintreePayment extends PaymentBase {
237
+ method : PurchasePaymentMethod | AuthorizePaymentMethod
238
+ gateway : 'braintree'
239
+ options ?: BraintreePaymentOptions
240
+ }
241
+
242
+ export interface CardConnectPayment extends PaymentBase {
243
+ method :
244
+ | PurchasePaymentMethod
245
+ | AuthorizePaymentMethod
246
+ | CapturePaymentMethod
247
+ | RefundPaymentMethod
248
+ gateway : 'card_connect'
249
+ }
250
+
251
+ export interface CyberSourcePayment extends PaymentBase {
252
+ method : PurchasePaymentMethod | AuthorizePaymentMethod
253
+ gateway : 'cyber_source'
254
+ options ?: Record < string , string >
255
+ }
256
+
257
+ export interface PayPalExpressCheckoutPayment extends PaymentBase {
258
+ method : PurchasePaymentMethod | AuthorizePaymentMethod
259
+ gateway : 'paypal_express_checkout'
260
+ options ?: {
261
+ description ?: string
262
+ soft_descriptor ?: string
263
+ application_context ?: {
264
+ return_url ?: string
265
+ cancel_url ?: string
266
+ shipping_preference ?: string
267
+ landing_page ?: 'LOGIN' | 'BILLING' | 'NO_PREFERENCE'
268
+ locale ?: string
269
+ brand_name ?: string
270
+ }
271
+ }
272
+ }
273
+
274
+ /**
275
+ * Stripe Payments
276
+ */
277
+
278
+ export type StripePaymentOptionBase = {
279
+ idempotency_key ?: string
280
+ receipt_email ?: string
281
+ customer ?: string
282
+ }
283
+
284
+ export interface StripePaymentBase extends PaymentBase {
285
+ amount ?: number
286
+ options ?: StripePaymentOptionBase
287
+ }
288
+
289
+ export interface StripePayment extends StripePaymentBase {
290
+ method : PurchasePaymentMethod | AuthorizePaymentMethod | CapturePaymentMethod
291
+ gateway : 'stripe'
292
+ options ?: StripePaymentOptionBase & {
293
+ destination ?: string
294
+ }
295
+ }
296
+
297
+ export interface StripeConnectPayment extends StripePaymentBase {
298
+ method : PurchasePaymentMethod | AuthorizePaymentMethod
299
+ gateway : 'stripe_connect'
300
+ }
301
+
302
+ export interface StripeIntentsPayment extends StripePaymentBase {
303
+ method : PurchasePaymentMethod | AuthorizePaymentMethod
304
+ gateway : 'stripe_payment_intents'
305
+ }
306
+
307
+ export interface ElasticPathStripePayment extends StripePaymentBase {
308
+ method : PurchasePaymentMethod | AuthorizePaymentMethod
309
+ gateway : 'elastic_path_payments_stripe'
310
+ }
311
+
312
+ /**
313
+ * Manual Payments
314
+ */
315
+
316
+ export interface ManualPayment extends PaymentBase {
317
+ method : PurchasePaymentMethod | AuthorizePaymentMethod
318
+ gateway : 'manual'
319
+ amount ?: number
320
+ paymentmethod_meta ?: {
321
+ name ?: string
322
+ custom_reference ?: string
323
+ }
324
+ }
325
+
326
+ export type PaymentRequestBody =
327
+ | ManualPayment
328
+ | ElasticPathStripePayment
329
+ | StripeIntentsPayment
330
+ | StripeConnectPayment
331
+ | StripePayment
332
+ | PayPalExpressCheckoutPayment
333
+ | CyberSourcePayment
334
+ | CardConnectPayment
335
+ | BraintreePayment
336
+ | AuthorizeNetPayment
337
+ | AdyenPayment
338
+
194
339
export interface ConfirmPaymentBody {
195
340
method : string
196
341
gateway : string
197
342
payment : string
198
343
options ?: {
199
- customer : string
200
- idempotency_key : string
201
- receipt_email : string
344
+ customer ? : string
345
+ idempotency_key ? : string
346
+ receipt_email ? : string
202
347
}
203
348
}
204
349
@@ -314,7 +459,7 @@ export interface OrdersEndpoint
314
459
* @param id - The UUID of the order that you want to authorize payment for.
315
460
* @param body - The body of the order
316
461
*/
317
- Payment ( id : string , body : ConfirmPaymentBody ) : Promise < ConfirmPaymentResponse >
462
+ Payment ( id : string , body : PaymentRequestBody ) : Promise < ConfirmPaymentResponse >
318
463
319
464
/**
320
465
* Update an Order
@@ -330,10 +475,6 @@ export interface OrdersEndpoint
330
475
* anonymize an Order
331
476
* Description: Anonymize order with the list of the ids.
332
477
* DOCS: https://documentation.elasticpath.com/commerce-cloud/docs/api
333
- * @param id
334
- * @param body
335
- * @constructor
336
478
*/
337
-
338
479
anonymize ( ids : AnonymizeOrder ) : Promise < AnonymizeOrderResponse >
339
480
}
0 commit comments