Skip to content

Commit

Permalink
Update createOrder to send SLAS USID (#920)
Browse files Browse the repository at this point in the history
* Update createOrder to send SLAS USID

* Modify some tests to include setting the header

Co-authored-by: echessman <[email protected]>
  • Loading branch information
vcua-mobify and echessman authored Jan 24, 2023
1 parent 34608a0 commit 6d8563a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@ export default function useBasket(opts = {}) {
*/
async createOrder() {
const response = await api.shopperOrders.createOrder({
// We send the SLAS usid via this header. This is required by ECOM to map
// Einstein events sent via the API with the finishOrder event fired by ECOM
// when an Order transitions from Created to New status.
// Without this, various order conversion metrics will not appear on reports and dashboards
headers: {_sfdc_customer_id: api.auth.usid},
body: {basketId: basket.basketId}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ describe('CommerceAPI', () => {
const api = getAPI()
fetch.mockResponseOnce(JSON.stringify(ocapiBasketResponse))
const response = await api.shopperOrders.createOrder({
headers: {_sfdc_customer_id: 'usid'},
parameters: {},
body: {basketId: ''}
})
Expand All @@ -695,6 +696,7 @@ describe('CommerceAPI', () => {
const api = getAPI()
fetch.mockResponseOnce(JSON.stringify(ocapiBasketResponse))
const response = await api.shopperOrders.createOrder({
headers: {_sfdc_customer_id: 'usid'},
parameters: {}
})
expect(response.title).toEqual('Body is required for this request')
Expand All @@ -704,6 +706,7 @@ describe('CommerceAPI', () => {
const api = getAPI()
fetch.mockResponseOnce(JSON.stringify(ocapiBasketResponse))
const response = await api.shopperOrders.getOrder({
headers: {_sfdc_customer_id: 'usid'},
parameters: {orderNo: ''}
})
expect(response).toBeDefined()
Expand All @@ -713,6 +716,7 @@ describe('CommerceAPI', () => {
const api = getAPI()
fetch.mockResponseOnce(JSON.stringify(ocapiBasketResponse))
const response = await api.shopperOrders.getOrder({
headers: {_sfdc_customer_id: 'usid'},
parameters: {}
})
expect(response.title).toEqual(
Expand All @@ -728,6 +732,7 @@ describe('CommerceAPI', () => {
await expect(
api.shopperOrders.createOrder({
parameters: {},
headers: {_sfdc_customer_id: 'usid'},
body: {basketId: ''}
})
).rejects.toThrow(ocapiFaultResponse.fault.message)
Expand Down

0 comments on commit 6d8563a

Please sign in to comment.