/* * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* Copyright (c) 2020 Mobify Research & Development Inc. All rights reserved. */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* Shop API
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 20.4
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
*/
import ApiClient from '../ApiClient'
import NotesResult from '../models/NotesResult'
import Order from '../models/Order'
import PaymentMethodResult from '../models/PaymentMethodResult'
/**
* Orders service.
* @module api/OrdersApi
* @version 20.4
*/
export default class OrdersApi {
/**
* Constructs a new OrdersApi.
* @alias module:api/OrdersApi
* @class
* @param {module:ApiClient} apiClient Optional API client implementation to use,
* default to {@link module:ApiClient#instance} if unspecified.
*/
constructor(apiClient) {
this.apiClient = apiClient || ApiClient.instance
}
/**
* Removes an order note.
* @param {String} orderNo the id of the order to be modified
* @param {String} noteId the id of the note to be removed
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/Order} and HTTP response
*/
deleteOrdersByIDNotesByIDWithHttpInfo(orderNo, noteId) {
const postBody = null
// verify the required parameter 'orderNo' is set
if (orderNo === undefined || orderNo === null) {
throw new Error('Missing the required parameter \'orderNo\' when calling deleteOrdersByIDNotesByID')
}
// verify the required parameter 'noteId' is set
if (noteId === undefined || noteId === null) {
throw new Error('Missing the required parameter \'noteId\' when calling deleteOrdersByIDNotesByID')
}
const pathParams = {
order_no: orderNo,
note_id: noteId
}
const queryParams = {
}
const headerParams = {
}
const formParams = {
}
const authNames = ['client_id', 'customers_auth', 'oauth2_application']
const contentTypes = ['application/json', 'text/xml', 'application/xml']
const accepts = ['application/json', 'text/xml', 'application/xml']
const returnType = Order
return this.apiClient.callApi(
'/orders/{order_no}/notes/{note_id}', 'DELETE',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* Removes an order note.
* @param {String} orderNo the id of the order to be modified
* @param {String} noteId the id of the note to be removed
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/Order}
*/
deleteOrdersByIDNotesByID(orderNo, noteId) {
return this.deleteOrdersByIDNotesByIDWithHttpInfo(orderNo, noteId)
.then((response_and_data) => {
return response_and_data.data
})
}
/**
* Removes a payment instrument of an order.
* @param {String} orderNo the order number
* @param {String} paymentInstrumentId the id of the payment instrument to be updated
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/Order} and HTTP response
*/
deleteOrdersByIDPaymentInstrumentsByIDWithHttpInfo(orderNo, paymentInstrumentId) {
const postBody = null
// verify the required parameter 'orderNo' is set
if (orderNo === undefined || orderNo === null) {
throw new Error('Missing the required parameter \'orderNo\' when calling deleteOrdersByIDPaymentInstrumentsByID')
}
// verify the required parameter 'paymentInstrumentId' is set
if (paymentInstrumentId === undefined || paymentInstrumentId === null) {
throw new Error('Missing the required parameter \'paymentInstrumentId\' when calling deleteOrdersByIDPaymentInstrumentsByID')
}
const pathParams = {
order_no: orderNo,
payment_instrument_id: paymentInstrumentId
}
const queryParams = {
}
const headerParams = {
}
const formParams = {
}
const authNames = ['client_id', 'customers_auth', 'oauth2_application']
const contentTypes = ['application/json', 'text/xml', 'application/xml']
const accepts = ['application/json', 'text/xml', 'application/xml']
const returnType = Order
return this.apiClient.callApi(
'/orders/{order_no}/payment_instruments/{payment_instrument_id}', 'DELETE',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* Removes a payment instrument of an order.
* @param {String} orderNo the order number
* @param {String} paymentInstrumentId the id of the payment instrument to be updated
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/Order}
*/
deleteOrdersByIDPaymentInstrumentsByID(orderNo, paymentInstrumentId) {
return this.deleteOrdersByIDPaymentInstrumentsByIDWithHttpInfo(orderNo, paymentInstrumentId)
.then((response_and_data) => {
return response_and_data.data
})
}
/**
* Gets information for an order.
* @param {String} orderNo the order number
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/Order} and HTTP response
*/
getOrdersByIDWithHttpInfo(orderNo) {
const postBody = null
// verify the required parameter 'orderNo' is set
if (orderNo === undefined || orderNo === null) {
throw new Error('Missing the required parameter \'orderNo\' when calling getOrdersByID')
}
const pathParams = {
order_no: orderNo
}
const queryParams = {
}
const headerParams = {
}
const formParams = {
}
const authNames = ['client_id', 'customers_auth', 'oauth2_application']
const contentTypes = ['application/json', 'text/xml', 'application/xml']
const accepts = ['application/json', 'text/xml', 'application/xml']
const returnType = Order
return this.apiClient.callApi(
'/orders/{order_no}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* Gets information for an order.
* @param {String} orderNo the order number
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/Order}
*/
getOrdersByID(orderNo) {
return this.getOrdersByIDWithHttpInfo(orderNo)
.then((response_and_data) => {
return response_and_data.data
})
}
/**
* Retrieves notes for an order.
* @param {String} orderNo The id of the order from which you want to retrieve notes.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/NotesResult} and HTTP response
*/
getOrdersByIDNotesWithHttpInfo(orderNo) {
const postBody = null
// verify the required parameter 'orderNo' is set
if (orderNo === undefined || orderNo === null) {
throw new Error('Missing the required parameter \'orderNo\' when calling getOrdersByIDNotes')
}
const pathParams = {
order_no: orderNo
}
const queryParams = {
}
const headerParams = {
}
const formParams = {
}
const authNames = ['client_id', 'customers_auth', 'oauth2_application']
const contentTypes = ['application/json', 'text/xml', 'application/xml']
const accepts = ['application/json', 'text/xml', 'application/xml']
const returnType = NotesResult
return this.apiClient.callApi(
'/orders/{order_no}/notes', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* Retrieves notes for an order.
* @param {String} orderNo The id of the order from which you want to retrieve notes.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/NotesResult}
*/
getOrdersByIDNotes(orderNo) {
return this.getOrdersByIDNotesWithHttpInfo(orderNo)
.then((response_and_data) => {
return response_and_data.data
})
}
/**
* Gets the applicable payment methods for an existing order considering the open payment amount only.
* @param {String} orderNo the order number
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/PaymentMethodResult} and HTTP response
*/
getOrdersByIDPaymentMethodsWithHttpInfo(orderNo) {
const postBody = null
// verify the required parameter 'orderNo' is set
if (orderNo === undefined || orderNo === null) {
throw new Error('Missing the required parameter \'orderNo\' when calling getOrdersByIDPaymentMethods')
}
const pathParams = {
order_no: orderNo
}
const queryParams = {
}
const headerParams = {
}
const formParams = {
}
const authNames = ['client_id', 'customers_auth', 'oauth2_application']
const contentTypes = ['application/json', 'text/xml', 'application/xml']
const accepts = ['application/json', 'text/xml', 'application/xml']
const returnType = PaymentMethodResult
return this.apiClient.callApi(
'/orders/{order_no}/payment_methods', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* Gets the applicable payment methods for an existing order considering the open payment amount only.
* @param {String} orderNo the order number
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/PaymentMethodResult}
*/
getOrdersByIDPaymentMethods(orderNo) {
return this.getOrdersByIDPaymentMethodsWithHttpInfo(orderNo)
.then((response_and_data) => {
return response_and_data.data
})
}
/**
* Update an order. Considered fields for update are status (same status transitions are possible as for dw.order.Order.setStatus(int status) plus CREATED to FAILED) and custom properties. During the call the correct channel type will be assured to be set for the order in a successful call. Without agent context the channel type will be storefront otherwise callcenter.
* @param {String} orderNo the order number
* @param {module:models/Order} body
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/Order} and HTTP response
*/
patchOrdersByIDWithHttpInfo(orderNo, body) {
const postBody = body
// verify the required parameter 'orderNo' is set
if (orderNo === undefined || orderNo === null) {
throw new Error('Missing the required parameter \'orderNo\' when calling patchOrdersByID')
}
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error('Missing the required parameter \'body\' when calling patchOrdersByID')
}
const pathParams = {
order_no: orderNo
}
const queryParams = {
}
const headerParams = {
}
const formParams = {
}
const authNames = ['client_id', 'customers_auth', 'oauth2_application']
const contentTypes = ['application/json', 'text/xml', 'application/xml']
const accepts = ['application/json', 'text/xml', 'application/xml']
const returnType = Order
return this.apiClient.callApi(
'/orders/{order_no}', 'PATCH',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* Update an order. Considered fields for update are status (same status transitions are possible as for dw.order.Order.setStatus(int status) plus CREATED to FAILED) and custom properties. During the call the correct channel type will be assured to be set for the order in a successful call. Without agent context the channel type will be storefront otherwise callcenter.
* @param {String} orderNo the order number
* @param {module:models/Order} body
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/Order}
*/
patchOrdersByID(orderNo, body) {
return this.patchOrdersByIDWithHttpInfo(orderNo, body)
.then((response_and_data) => {
return response_and_data.data
})
}
/**
* Updates a payment instrument of an order and passes the order and updated payment instrument to the correct payment authorizeCreditcard or authorize hook. Details: The payment instrument is updated with the provided details. The payment method must be applicable for the order see GET /baskets/{basket_id}/payment_methods, if the payment method is 'CREDIT_CARD' a payment_card must be specified in the request. Order authorization: To authorize the order one of two possible customization hooks is called and an dw.order.OrderPaymentInstrument is passed as an input argument. Which hook is called? If the request includes a payment_card or the dw.order.OrderPaymentInstrument contains a creditCardType the customization hook dw.order.payment.authorizeCreditCard is called. See dw.order.hooks.PaymentHooks.authorizeCreditCard(order : Order, paymentDetails : OrderPaymentInstrument, cvn : String) : Status. Otherwise dw.order.payment.authorize is called. See dw.order.hooks.PaymentHooks.authorize(order : Order, paymentDetails : OrderPaymentInstrument) : Status. What is the dw.order.OrderPaymentInstrument input argument passed to the hook? If the request contains a customer_payment_instrument_id the dw.order.OrderPaymentInstrument is copied from the customer payment instrument (An exception is thrown if none was found). Otherwise the data from the request document is passed (payment_card or payment_bank_account etc. information). Note: the amount and the security_code (cvn) contained in the payment_card data will be propagated if available to dw.order.payment.authorizeCreditCard even if the dw.order.OrderPaymentInstrument is resolved from a customer payment instrument. Customization hook dw.ocapi.shop.order.afterPatchPaymentInstrument is called. The default implementation places the order if the order status is CREATED and the authorization amount equals or exceeds the order total. Placing the order (equivalent to calling dw.order.OrderMgr.placeOrder(order : Order) in the scripting API) results in the order being changed to status NEW and prepared for export.
* @param {String} orderNo the order number
* @param {String} paymentInstrumentId the id of the payment instrument to be updated
* @param {module:models/OrderPaymentInstrumentRequest} body
* @param {Object} opts Optional parameters
* @param {Boolean} opts.skipAuthorization
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/Order} and HTTP response
*/
patchOrdersByIDPaymentInstrumentsByIDWithHttpInfo(orderNo, paymentInstrumentId, body, opts) {
opts = opts || {}
const postBody = body
// verify the required parameter 'orderNo' is set
if (orderNo === undefined || orderNo === null) {
throw new Error('Missing the required parameter \'orderNo\' when calling patchOrdersByIDPaymentInstrumentsByID')
}
// verify the required parameter 'paymentInstrumentId' is set
if (paymentInstrumentId === undefined || paymentInstrumentId === null) {
throw new Error('Missing the required parameter \'paymentInstrumentId\' when calling patchOrdersByIDPaymentInstrumentsByID')
}
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error('Missing the required parameter \'body\' when calling patchOrdersByIDPaymentInstrumentsByID')
}
const pathParams = {
order_no: orderNo,
payment_instrument_id: paymentInstrumentId
}
const queryParams = {
skip_authorization: opts.skipAuthorization
}
const headerParams = {
}
const formParams = {
}
const authNames = ['client_id', 'customers_auth', 'oauth2_application']
const contentTypes = ['application/json', 'text/xml', 'application/xml']
const accepts = ['application/json', 'text/xml', 'application/xml']
const returnType = Order
return this.apiClient.callApi(
'/orders/{order_no}/payment_instruments/{payment_instrument_id}', 'PATCH',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* Updates a payment instrument of an order and passes the order and updated payment instrument to the correct payment authorizeCreditcard or authorize hook. Details: The payment instrument is updated with the provided details. The payment method must be applicable for the order see GET /baskets/{basket_id}/payment_methods, if the payment method is 'CREDIT_CARD' a payment_card must be specified in the request. Order authorization: To authorize the order one of two possible customization hooks is called and an dw.order.OrderPaymentInstrument is passed as an input argument. Which hook is called? If the request includes a payment_card or the dw.order.OrderPaymentInstrument contains a creditCardType the customization hook dw.order.payment.authorizeCreditCard is called. See dw.order.hooks.PaymentHooks.authorizeCreditCard(order : Order, paymentDetails : OrderPaymentInstrument, cvn : String) : Status. Otherwise dw.order.payment.authorize is called. See dw.order.hooks.PaymentHooks.authorize(order : Order, paymentDetails : OrderPaymentInstrument) : Status. What is the dw.order.OrderPaymentInstrument input argument passed to the hook? If the request contains a customer_payment_instrument_id the dw.order.OrderPaymentInstrument is copied from the customer payment instrument (An exception is thrown if none was found). Otherwise the data from the request document is passed (payment_card or payment_bank_account etc. information). Note: the amount and the security_code (cvn) contained in the payment_card data will be propagated if available to dw.order.payment.authorizeCreditCard even if the dw.order.OrderPaymentInstrument is resolved from a customer payment instrument. Customization hook dw.ocapi.shop.order.afterPatchPaymentInstrument is called. The default implementation places the order if the order status is CREATED and the authorization amount equals or exceeds the order total. Placing the order (equivalent to calling dw.order.OrderMgr.placeOrder(order : Order) in the scripting API) results in the order being changed to status NEW and prepared for export.
* @param {String} orderNo the order number
* @param {String} paymentInstrumentId the id of the payment instrument to be updated
* @param {module:models/OrderPaymentInstrumentRequest} body
* @param {Object} opts Optional parameters
* @param {Boolean} opts.skipAuthorization
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/Order}
*/
patchOrdersByIDPaymentInstrumentsByID(orderNo, paymentInstrumentId, body, opts) {
return this.patchOrdersByIDPaymentInstrumentsByIDWithHttpInfo(orderNo, paymentInstrumentId, body, opts)
.then((response_and_data) => {
return response_and_data.data
})
}
/**
* Submits an order based on a prepared basket. Note: If the basket has been submitted using Order Center (considered by it's client id) the channel type will be set to \"Call Center\". In case another channel type was set by a script before submitting the basket, the channel type will be reset to \"Call Center\" and a warning will be logged. The only considered value from the request body is basket_id.
* @param {module:models/Basket} body
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/Order} and HTTP response
*/
postOrdersWithHttpInfo(body) {
const postBody = body
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error('Missing the required parameter \'body\' when calling postOrders')
}
const pathParams = {
}
const queryParams = {
}
const headerParams = {
}
const formParams = {
}
const authNames = ['client_id', 'customers_auth', 'oauth2_application']
const contentTypes = ['application/json', 'text/xml', 'application/xml']
const accepts = ['application/json', 'text/xml', 'application/xml']
const returnType = Order
return this.apiClient.callApi(
'/orders', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* Submits an order based on a prepared basket. Note: If the basket has been submitted using Order Center (considered by it's client id) the channel type will be set to \"Call Center\". In case another channel type was set by a script before submitting the basket, the channel type will be reset to \"Call Center\" and a warning will be logged. The only considered value from the request body is basket_id.
* @param {module:models/Basket} body
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/Order}
*/
postOrders(body) {
return this.postOrdersWithHttpInfo(body)
.then((response_and_data) => {
return response_and_data.data
})
}
/**
* Adds a note to an existing order.
* @param {String} orderNo The id of the order to be modified.
* @param {module:models/Note} body
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/Order} and HTTP response
*/
postOrdersByIDNotesWithHttpInfo(orderNo, body) {
const postBody = body
// verify the required parameter 'orderNo' is set
if (orderNo === undefined || orderNo === null) {
throw new Error('Missing the required parameter \'orderNo\' when calling postOrdersByIDNotes')
}
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error('Missing the required parameter \'body\' when calling postOrdersByIDNotes')
}
const pathParams = {
order_no: orderNo
}
const queryParams = {
}
const headerParams = {
}
const formParams = {
}
const authNames = ['client_id', 'customers_auth', 'oauth2_application']
const contentTypes = ['application/json', 'text/xml', 'application/xml']
const accepts = ['application/json', 'text/xml', 'application/xml']
const returnType = Order
return this.apiClient.callApi(
'/orders/{order_no}/notes', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* Adds a note to an existing order.
* @param {String} orderNo The id of the order to be modified.
* @param {module:models/Note} body
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/Order}
*/
postOrdersByIDNotes(orderNo, body) {
return this.postOrdersByIDNotesWithHttpInfo(orderNo, body)
.then((response_and_data) => {
return response_and_data.data
})
}
/**
* Adds a payment instrument to an order. It is possible either to supply the full payment information or only a customer payment instrument id and amount. In case the customer payment instrument id was set all the other properties (except amount) are ignored and the payment data is resolved from the stored customer payment information. An attempt is made to authorize the order by passing it to the authorize or authorizeCreditCard hook. Details: The payment instrument is added with the provided details or the details from the customer payment instrument. The payment method must be applicable for the order see GET /baskets/{basket_id}/payment_methods, if the payment method is 'CREDIT_CARD' a payment_card must be specified in the request. Order authorization: To authorize the order one of two possible customization hooks is called and an dw.order.OrderPaymentInstrument is passed as an input argument. Which hook is called? If the request includes a payment_card or the dw.order.OrderPaymentInstrument contains a creditCardType the customization hook dw.order.payment.authorizeCreditCard is called. See dw.order.hooks.PaymentHooks.authorizeCreditCard(order : Order, paymentDetails : OrderPaymentInstrument, cvn : String) : Status. Otherwise dw.order.payment.authorize is called. See dw.order.hooks.PaymentHooks.authorize(order : Order, paymentDetails : OrderPaymentInstrument) : Status. What is the dw.order.OrderPaymentInstrument input argument passed to the hook? If the request contains a customer_payment_instrument_id the dw.order.OrderPaymentInstrument is copied from the customer payment instrument (An exception is thrown if none was found). Otherwise the data from the request document is passed (payment_card or payment_bank_account etc. information). Note: the amount and the security_code (cvn) contained in the payment_card data will be propagated if available to dw.order.payment.authorizeCreditCard even if the dw.order.OrderPaymentInstrument is resolved from a customer payment instrument. Customization hook dw.ocapi.shop.order.afterPostPaymentInstrument is called. The default implementation places the order if the order status is CREATED and the authorization amount equals or exceeds the order total. Placing the order (equivalent to calling dw.order.OrderMgr.placeOrder(order : Order) in the scripting API) results in the order being changed to status NEW and prepared for export.
* @param {String} orderNo the order number
* @param {module:models/OrderPaymentInstrumentRequest} body
* @param {Object} opts Optional parameters
* @param {Boolean} opts.skipAuthorization
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/Order} and HTTP response
*/
postOrdersByIDPaymentInstrumentsWithHttpInfo(orderNo, body, opts) {
opts = opts || {}
const postBody = body
// verify the required parameter 'orderNo' is set
if (orderNo === undefined || orderNo === null) {
throw new Error('Missing the required parameter \'orderNo\' when calling postOrdersByIDPaymentInstruments')
}
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error('Missing the required parameter \'body\' when calling postOrdersByIDPaymentInstruments')
}
const pathParams = {
order_no: orderNo
}
const queryParams = {
skip_authorization: opts.skipAuthorization
}
const headerParams = {
}
const formParams = {
}
const authNames = ['client_id', 'customers_auth', 'oauth2_application']
const contentTypes = ['application/json', 'text/xml', 'application/xml']
const accepts = ['application/json', 'text/xml', 'application/xml']
const returnType = Order
return this.apiClient.callApi(
'/orders/{order_no}/payment_instruments', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* Adds a payment instrument to an order. It is possible either to supply the full payment information or only a customer payment instrument id and amount. In case the customer payment instrument id was set all the other properties (except amount) are ignored and the payment data is resolved from the stored customer payment information. An attempt is made to authorize the order by passing it to the authorize or authorizeCreditCard hook. Details: The payment instrument is added with the provided details or the details from the customer payment instrument. The payment method must be applicable for the order see GET /baskets/{basket_id}/payment_methods, if the payment method is 'CREDIT_CARD' a payment_card must be specified in the request. Order authorization: To authorize the order one of two possible customization hooks is called and an dw.order.OrderPaymentInstrument is passed as an input argument. Which hook is called? If the request includes a payment_card or the dw.order.OrderPaymentInstrument contains a creditCardType the customization hook dw.order.payment.authorizeCreditCard is called. See dw.order.hooks.PaymentHooks.authorizeCreditCard(order : Order, paymentDetails : OrderPaymentInstrument, cvn : String) : Status. Otherwise dw.order.payment.authorize is called. See dw.order.hooks.PaymentHooks.authorize(order : Order, paymentDetails : OrderPaymentInstrument) : Status. What is the dw.order.OrderPaymentInstrument input argument passed to the hook? If the request contains a customer_payment_instrument_id the dw.order.OrderPaymentInstrument is copied from the customer payment instrument (An exception is thrown if none was found). Otherwise the data from the request document is passed (payment_card or payment_bank_account etc. information). Note: the amount and the security_code (cvn) contained in the payment_card data will be propagated if available to dw.order.payment.authorizeCreditCard even if the dw.order.OrderPaymentInstrument is resolved from a customer payment instrument. Customization hook dw.ocapi.shop.order.afterPostPaymentInstrument is called. The default implementation places the order if the order status is CREATED and the authorization amount equals or exceeds the order total. Placing the order (equivalent to calling dw.order.OrderMgr.placeOrder(order : Order) in the scripting API) results in the order being changed to status NEW and prepared for export.
* @param {String} orderNo the order number
* @param {module:models/OrderPaymentInstrumentRequest} body
* @param {Object} opts Optional parameters
* @param {Boolean} opts.skipAuthorization
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/Order}
*/
postOrdersByIDPaymentInstruments(orderNo, body, opts) {
return this.postOrdersByIDPaymentInstrumentsWithHttpInfo(orderNo, body, opts)
.then((response_and_data) => {
return response_and_data.data
})
}
/**
* Submits an order with a given order number, based on a prepared basket. The only considered value from the request body is basket_id. This resource is available for OAuth authentication and requires no user i.e. it supports server-server communication with client grant authentication and no user is specified.
* @param {String} orderNo The order number to assign to the new order.
* @param {module:models/Basket} body
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/Order} and HTTP response
*/
putOrdersByIDWithHttpInfo(orderNo, body) {
const postBody = body
// verify the required parameter 'orderNo' is set
if (orderNo === undefined || orderNo === null) {
throw new Error('Missing the required parameter \'orderNo\' when calling putOrdersByID')
}
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error('Missing the required parameter \'body\' when calling putOrdersByID')
}
const pathParams = {
order_no: orderNo
}
const queryParams = {
}
const headerParams = {
}
const formParams = {
}
const authNames = ['client_id', 'customers_auth', 'oauth2_application']
const contentTypes = ['application/json', 'text/xml', 'application/xml']
const accepts = ['application/json', 'text/xml', 'application/xml']
const returnType = Order
return this.apiClient.callApi(
'/orders/{order_no}', 'PUT',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* Submits an order with a given order number, based on a prepared basket. The only considered value from the request body is basket_id. This resource is available for OAuth authentication and requires no user i.e. it supports server-server communication with client grant authentication and no user is specified.
* @param {String} orderNo The order number to assign to the new order.
* @param {module:models/Basket} body
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/Order}
*/
putOrdersByID(orderNo, body) {
return this.putOrdersByIDWithHttpInfo(orderNo, body)
.then((response_and_data) => {
return response_and_data.data
})
}
}