Loading
B2C Commerce 入门
配置 Salesforce IdP 生产组织的 SSO

配置 Salesforce IdP 生产组织的 SSO

如果 B2C 实例连接到 Salesforce 生产组织,请为 Merchant Agent 工作配置登录流程。无需设置身份验证提供程序。

在主要 Salesforce 组织配置登录流程

要在 B2C Commerce 和 Salesforce 组织 IdP 之间同步用户身份,请在主 Salesforce 组织配置登录流。当用户登录到 Salesforce IdP 组织时,此流程将处理同步。

  1. 登录到充当 IdP 的主 Salesforce 组织。
  2. 创建登录流可调用操作。
    1. 在页面顶部,单击“ 设置 ”,然后选择 “设置”。
    2. 在“快速查找”框中,输入并选择 Apex 类。
    3. 点击新建。
    4. 复制此代码并将其粘贴到 Apex 类编辑器中。
      /**
               * 登录流的可调用操作,用于在 Commerce Cloud 和核心身份提供商之间同步商家
               的 * 身份。
               */
               public class CommerceIdentitySyncAction {
               @InvocableMethod(
               label='Sync Commerce Identity'
               description='建立登录核心用户和 ECOM 用户之间的映射。'
               category='Identity'
               )
               public static List<ActionResult> execute() {
               List<ActionResult> results = new List<ActionResult>();
               ActionResult 结果 = 新的 ActionResult();
               try {
               // 调用系统身份同步逻辑
               Auth.CommerceIdentitySynchronizationAction.UserSynchronizationResult syncStatus =
               Auth.CommerceIdentitySynchronizationAction.establishUserSynchronization();
               if (syncStatus != null) {
               result.isSuccess = syncStatus.isSuccess;
               result.errorMessage = syncStatus.errorMessage;
              
               } } catch (Exception ex) {
               // 捕获任何意外问题,防止登录流中断
               result.isSuccess = false;
               result.errorMessage = '身份同步期间发生意外错误: ' + ex.getMessage();
              
               } results.add(结果);
               返回结果;
              
               } /**
               * 捕获同步的状态,以便在 Flow 决策元素中使用。
               */
               public class ActionResult {
               @InvocableVariable(label='Is Success' description='如果身份映射创建成功,则为 True.')
               public Boolean isSuccess;
               @InvocableVariable(label='Error Message' description='同步失败的原因,如果适用.')
               public String errorMessage;
              
               } }
    5. 点击保存。
  3. 在 Salesforce IdP 组织中创建并分配登录流。
    1. 在“快速查找”框中,查找并选择 “流”。
    2. 单击“ 新建 ”,然后选择 “屏幕流”。
    3. 在 “屏幕流开始”和“结束 ”之间,单击 “+ ”按钮,然后选择 “操作”。
    4. 搜索操作 Sync Commerce Identity。
    5. 选择操作并提供 标签 和 API 名称。
    6. 点击保存。
    7. 单击 “激活 ”,然后退出 Flow Builder。
  4. 在“快速查找”框中,输入并选择 “登录流”。
  5. 单击 “新建 ”,然后在表中输入字段值。
    字段 值
    类型 流程
    流程 选择您创建的流。
    用户许可证 Salesforce
    概况 标准用户
  6. 保存更改。
 
正在加载
Salesforce Help | Article