Skip to Content
Author's profile photo Ramya K

How to consume SAP Localization Hub – Tax in Yaas (Commerce as a Service)

Prerequisites:

Development Environment

 

You need the following development environment to consume SAP Localization Hub – Tax within Commerce as a Service

1. Access to the following:

2. An developer account in https://account.hanatrial.ondemand.com/ or https://account.hana.ondemand.com/, where you want to deploy the storefront application consuming SAP Localization Hub – Tax.

 

3. HCP development tools to create HTML application. You install these your local system. For further details on how to create an application, refer to the following link https://help.hana.ondemand.com/help/frameset.htm?b12016370421435a9f38e6955a2820e8.html

 

Setting up the Storefront

 

You need a storefront for transacting on the products of your company. The sections in this document highlight the unique steps that you need to perform for enabling SAP Localization Hub – Tax in your storefront. For more information on setting up a default storefront refer to the following link https://devportal.yaas.io/gettingstarted/createastorefront/index.html

 

 

GIT

 

While downloading the GIT, you have the following options:

1. Create the default storefront, for tax calculations in US and CA https://github.com/hybris/caas-storefront-template

2. Create an enhanced storefront, for tax calculations in CN and MX, in addition to US and CA. https://github.com/kherrmann/yaas-storefront

 

Note: To deploy the GIT locally, follow the steps mentioned in the GITHUB links above.

 

While creating a project and site, subscribe to the following packages:

a. Core Package

b. Commerce as a Service

c. SAP Localization Hub – Tax

Deployment in HCP

 

Instead of standard deployment in YaaS, you need to deploy the storefront in HCP. To do so, perform the following:

1. Create an HTML application in HCP

2. Import the dist/public folder of the storefront project from the localhost into your application in eclipse IDE

3. Deploy the HTML application in HCP. The application opens the newly created storefront, and the products added to the project are accessible in the storefront.

 

Enable SAP Localization Hub – Tax for your site

The service, SAP Localization Hub – Tax is enabled at a site level. To enable this tax service for, you must perform the following for each site.

Note: Use the postman rest client or an equivalent to perform these steps

 

     1. Get an authorization token from the oAuth API.

         Send POST request to URL – https://api.yaas.io/hybris/oauth2/b1/token with the following passed as “x-www-form-urlencoded” parameters

      • grant_type = client_credentials
      • scope = hybris.tenant=<your project identifier> hybris.site_manage
      • client_id = jcc2RRjLS9ckcRj8jSuWu47HiqEFOf3j
      • client_secret = MaIDJA6z16VSAzDC

 

           This will return the authorization token.

           Below is the screenshot of how this request and response looks in the postman client.

 

postman req1.png

 

 

 

 

     2. Send a POST request to https://api.yaas.io/hybris/site/b1/{projectidentifier}/sites/{site code}/tax where “projectidentifier” is your project identifier and “site code” is your site code. You would have provided this information when creating your project and site in the builder. Pass the following Header data:

      • Authorization = Bearer <authorization token got from step a>
      • Content-Type = application/json

Use the below Payload:

{

“id”: “tax”,

“name”: “SLH Tax Service”,

“serviceType”: “urn:x-yaas:service:tax”,

“serviceUrl”: “https://api.yaas.io/sap/tax/b0“,

“active”: true

}

Below is the screenshot of how the request and response looks in the postman client.

 

postman req2.png

 

 

 

 

 

 

 

 

                     Note: In the screenshot example, the project id is “slhsweetsshop” and site code is “cn”

    

      This will enable SAP Localization Hub – tax for the site.                   

Once the above steps are completed, the SAP Localization Hub – Tax will be activated for your site(s). In the storefront, a user can add products to the cart and estimate tax for the products in the shopping cart by providing zip code and country and clicking on Apply. This action invokes the tax service and display the calculated tax.

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Link to Hybris's Github is wrong

      Should be https://github.com/hybris/

      but now it is https://hitgub.com/hybris/

      Author's profile photo Ramya K
      Ramya K
      Blog Post Author

      Thanks for pointing out. I've changed the link.