Order Management {#salesforce-b2c-order-management}
===================================================

`Salesforce` B2C Commerce does not natively support order management functions. This cartridge has functions that can be utilized to process captures and authorization reversals.

> These functions must be customized before use in the ` Salesforce ` B2C Commerce user interface.

Capture
-------

The capture function can be found in the script *scripts/http/capture.js*. A working example is available in the ServiceFrameworkTest-TestCaptureService controller.  
Reference the capture.js object and make this request:

```
var captureObj = require("~/cartridge/scripts/http/capture.js");
var serviceResponse = captureObj.httpCapturePayment(requestID, merchantRefCode, paymentTotal, currency);
```

The resulting serviceResponse object contains the full response object generated by the request. The contents of this object determine your logic in handling errors and successes. These are the Capture request parameters:  
**Capture Request Parameters:**

* requestID: The `Cybersource` Request ID from the initial authorization.
* merchantRefCode: The `Salesforce` Order Number.
* purchaseTotal: The capture amount.
* currency: Currency Code.

**Function Signature:**

```
httpCapturePayment(requestID, merchantRefCode, purchaseTotal, currency)
```

Authorization Reversal
----------------------

The authorization reversal function can be found in the script called *scripts/http/authReversal.js*. A working example is in the ServiceFrameworkTest-TestAuthReversal controller.  
Reference the AuthReversal.js object and make this request:

```
var reversalObj = require("~/cartridge/scripts/http/authReversal.js");
var serviceResponse = reversalObj.httpAuthReversal(requestID, merchantRefCode, paymentTotal, currency);
```

The resulting serviceResponse object contains the full response object generated by the request. The contents of this object determine your logic in handling errors and successes. These are the Authorization reversal request parameters:  
**Authorization Reversal Request Parameters:**

* requestID: The `Cybersource` Request ID from the initial authorization.
* merchantRefCode: The `Salesforce` Order Number
* purchaseTotal: The reversal amount
* currency: Currency Code

