Home > @poq/sdk-sfcc > IOrdersClient > postOrdersByIDPaymentInstruments
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.
Signature:
postOrdersByIDPaymentInstruments(orderNo: string, body: OrderPaymentInstrumentRequest, skipAuthorization?: boolean, options?: RequestOptions): Promise<PoqResponse<Order>>;
Parameter | Type | Description |
---|---|---|
orderNo | string | the order number |
body | OrderPaymentInstrumentRequest | |
skipAuthorization | boolean | (Optional) |
options | RequestOptions | (Optional) Override http request option. |
Returns:
Promise<PoqResponse<Order>>