配置兑换付款网关 RMA(仅限 B2C)
如果您不使用 Salesforce Payments,您可以配置支付网关来管理支付。AppExchange 上提供了一些供应商的支付包。
所需的 Edition
重要 如果您正在使用与 B2B 或 D2C Commerce 的交换,步骤 1-4 已在订单管理实施期间配置。直接转到第 5 步。
-
使用 Salesforce Apex 连接器框架创建支付网关适配器类。
为了帮助您入门,请参见参考类。
- 创建指向您创建的适配器类的支付网关提供商记录。
- 在“设置”中,定义包含网关提供商的身份验证和登录信息的命名凭据。适配器类标注定义会调用命名凭据。
- 通过创建支付网关记录来链接支付网关提供商记录和命名凭据。
- 将支付网关与网店记录相关联。
示例
要将支付网关与网店记录相关联,请使用如下脚本
// Script to add a connection between the web store and the payment gateway for B2C Commerce stores
String webStoreName = 'SiteGenesis';
String paymentGatewayName = 'SalesforceAdapter';
// obtain webstoreid
List<WebStore> webstores = [SELECT Id, Name FROM WebStore WHERE Name = :webStoreName];
System.debug('Webstores: ' + webstores);
if(webstores.isEmpty()){
System.debug('Error obtaining webstore with name ' + webStoreName);
}
String webStoreId = webstores[0].Id;
System.debug('WebStoreId: ' + webStoreId);
// obtain payment gateway id from the payment gateway name
List<PaymentGateway> paymentGateways = [SELECT Id, PaymentGatewayName FROM PaymentGateway WHERE PaymentGatewayName = :paymentGatewayName];
System.debug('paymentGateways: ' + paymentGateways);
if(paymentGateways.isEmpty()){
System.debug('Error obtaining payment gateway with name ' + paymentGatewayName);
}
String paymentGatewayId = paymentGateways[0].Id;
System.debug('paymentGatewayId: ' + paymentGatewayId);
// If a StoreIntegratedService already exists for Payment on the WebStore then update the Integration field with the paymentGatewayId
List<StoreIntegratedService> storeServices = [SELECT Id FROM StoreIntegratedService WHERE StoreId = :webStoreId AND ServiceProviderType ='Payment' ];
System.debug('storeServices: ' + storeServices);
if(storeServices.isEmpty()){
StoreIntegratedService storeService = new StoreIntegratedService(
StoreId = webStoreId,
Integration = paymentGatewayId,
ServiceProviderType ='Payment');
insert storeService;
} else {
StoreIntegratedService existingStoreService = storeServices[0];
existingStoreService.Integration = paymentGatewayId;
update existingStoreService;
}
本文章是否解决您的问题?
请与我们共享您的想法,以便我们进行改进!

