Skip to content

Commit

Permalink
feat: punchout guard improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
shauke committed Mar 17, 2021
1 parent ae872aa commit 882cf4e
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/app/extensions/punchout/pages/punchout/punchout-page.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,17 @@ export class PunchoutPageGuard implements CanActivate {
// tslint:disable-next-line: no-console
console.log('STARTING cXML PUNCHOUT with sid:', route.queryParamMap.get('sid'));

// fetch sid session information (basketId, returnURL, operation, ...)
return this.punchoutService.getCxmlPunchoutSession(route.queryParamMap.get('sid')).pipe(
log('session data'),
// persist returnURL in a cookie for later cart transfer (TODO: should survive page reload)
tap(data => this.cookiesService.put('punchoutReturnURL', data.returnURL, { sameSite: 'Strict' })),
tap(data => this.cookiesService.put('punchoutBasketID', data.basketId, { sameSite: 'Strict' })),
tap(data => this.checkoutFacade.setCurrentBasketId(data.basketId)),
// use the basketId basket for the current PWA session (instead of default current basket)
tap(data => this.checkoutFacade.loadBasketWithId(data.basketId)),
mapTo(this.router.parseUrl('/home'))
);

/* TODO:
- fetch sid session information (basketId, returnURL, operation, ...) with /customers/{customerId}/punchout/cxml1.2/sessions/{sid}
- use the basketId basket for the current PWA session (instead of default basket, no basket merge, start with given basket)
- persist returnURL for later cart transfer (cookie, local storage, should survive page reload)
- FOR LATER: handle different operations or routing to a specific product, etc.
*/

// return of(this.router.parseUrl('/home'));

// handle OCI punchout with HOOK_URL (save HOOK_URL to 'hookURL' cookie)
} else if (route.queryParamMap.get('HOOK_URL')) {
this.cookiesService.put('hookURL', route.queryParamMap.get('HOOK_URL'), { sameSite: 'Strict' });
Expand Down

1 comment on commit 882cf4e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Azure Demo Servers are available:

Please sign in to comment.