Skip to content

Latest commit

 

History

History
109 lines (88 loc) · 3.48 KB

File metadata and controls

109 lines (88 loc) · 3.48 KB

Customer Rest API

The Jhoose Commerce Customer Rest API is used to support customer centric activities.

All requests (unless otherwise specified) work in the scope of the currently authenticated user.

Example:

  • The customer has not access to any carts they do not own.
  • Pricing is relevant to the customer.
  • Coupons are will not be applied if they are not valid for the customer

API Features

Installation

dotnet add package Jhoose.CommerceApi

Getting Started

Modify startup.cs ConfigureServices method.

    // add authentication
    services
    .AddAuthentication()
    .AddJhooseCommerceAuthentication(o => {
        o.Audience = _configuration["Jwt:Audience"];
        o.Authority = _configuration["Jwt:Authority"];
        o.Issuer = _configuration["Jwt:Issuer"];
    });

    // add jhoose commerce api
    services.AddJhooseCommerceApi(_configuration, o =>
    {
        o.ProxyCurrentMarket = true;
        o.CreateAbsoluteUrls = true;
    });

Modify startup.cs Configure method.

    // Add after UseRouting, but before UseAuthentication and UseAuthorization, else will have CORS issues 
        
    app.UseJhooseCommerceApi();

Settings can also be managed in appSettings.json

  "JhooseCommerceApiOptions": {
    "JwtKey": "cd1b757768494850a3c280adda607373",
    "AuthorizationKey": "Y2QxYjc1Nzc2ODQ5NDg1MGEzYzI4MGFkZGE2MDczNzM=",
    "ProxyCurrentMarket": true,
    "CreateAbsoluteUrls": true,
    "SiteHostname": "http://localhost:3000",
    "Encryption": {
      "Key": "cd1b757768494850a3c280adda607373",
      "IV": "cd1b757768494850"
    }
  }

The framework also expects the MSRP Sales Price type to exist and is required for the standard pricing to work.

  "EPiServer": {
    "Commerce": {

      "CatalogOptions": {

        // Add the MSRP Sales price type
        "SalePriceTypes": [
          {
            "Key": "MSRP",
            "Value": "4",
            "Description": "MSRP"
          }
        ]
      }
    }

JwtBearer Options

Used to configure the external authentication provider.

Property Description
Audience As supplied by external provider
Authority As supplied by external provider
Issuer As supplied by external provider

JhooseCommerceApiOptions

Property Description
SiteHostname This is the hostname of the external site that is using the CommerceApi. Include the protocol and (port if necessary). This is used by CORS
JwtKey This is the key used to sign the JWT token used for anonymous authentication. See: JWT Keys
AuthorizationKey This is the key used to authenticate for anonymous authentication.
ProxyCurrentMarket If true, the local ICurrentMarket implementation will be proxied with the CommerceApi implementation. See Markets
CreateAbsoluteUrls If true, all urls will be created as absolute urls.
Encryption.Key AES Encryption Key used See: Encryption Keys
Encryption.IV AES Initilization Vector used