Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@W-14886263 - Update Apex for Delivery Estimation #301

Merged
merged 31 commits into from
Jan 30, 2024
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d1de810
Update: Heroku Deprecation
gurpreetsainisalesforce Aug 14, 2023
90ca54b
Update: Use example.com as the hostname
gurpreetsainisalesforce Aug 17, 2023
d3ab189
Update: PR Feedback
gurpreetsainisalesforce Aug 17, 2023
5ed07bf
Update: heroku url remote site
gurpreetsainisalesforce Aug 17, 2023
2e45de9
Update: B2B Samples
gurpreetsainisalesforce Aug 21, 2023
1a46d77
Update: Fix Compilation Issues
gurpreetsainisalesforce Aug 21, 2023
060e425
Update: Revert with sharing and security enforced
gurpreetsainisalesforce Aug 22, 2023
323a1a7
Update: Cleanup
gurpreetsainisalesforce Aug 23, 2023
ccb9c64
Update: Cleanup
gurpreetsainisalesforce Aug 23, 2023
336f98c
Update: Cleanup
gurpreetsainisalesforce Aug 23, 2023
ecd1258
Update: Sync Integrations
gurpreetsainisalesforce Aug 23, 2023
571fd7a
Update: After SFDX Runs
gurpreetsainisalesforce Aug 25, 2023
5d5c511
Merge branch 'forcedotcom:develop' into develop
gurpreetsainisalesforce Sep 5, 2023
b9d2184
Update: Remove References to Custom Labels
gurpreetsainisalesforce Sep 5, 2023
947d678
Update: Revert B2B Aura Sample
gurpreetsainisalesforce Sep 8, 2023
b787ab9
Merge branch 'forcedotcom:develop' into develop
gurpreetsainisalesforce Sep 8, 2023
d57daab
Update: Revert B2B Aura Sample
gurpreetsainisalesforce Sep 8, 2023
7a57dec
Update: Revert B2B Aura Sample
gurpreetsainisalesforce Sep 8, 2023
b811311
Update: Revert B2B Aura Sample
gurpreetsainisalesforce Sep 8, 2023
9706330
Update: Fix B2BTaxSample
gurpreetsainisalesforce Sep 8, 2023
7ae2f27
Merge branch 'forcedotcom:develop' into develop
gurpreetsainisalesforce Sep 8, 2023
2be08a6
Merge branch 'forcedotcom:develop' into develop
gurpreetsainisalesforce Sep 12, 2023
2a6fb5b
Update: B2BSyncTax to consider United States
gurpreetsainisalesforce Sep 12, 2023
05010f4
Merge branch 'forcedotcom:develop' into develop
gurpreetsainisalesforce Sep 22, 2023
71e690b
Merge branch 'forcedotcom:develop' into develop
gurpreetsainisalesforce Jan 23, 2024
6530644
@W-14886263 - Update Apex for Delivery Estimation
gurpreetsainisalesforce Jan 25, 2024
94ecc07
Update API version to 61
gurpreetsainisalesforce Jan 26, 2024
7cf0d9e
Update: Remvoe hardcoding Class Name
gurpreetsainisalesforce Jan 29, 2024
f93fe99
Merge branch 'forcedotcom:develop' into develop
gurpreetsainisalesforce Jan 29, 2024
f202b98
Update: Remvoe hardcoding Class Name
gurpreetsainisalesforce Jan 29, 2024
6e3d59a
Update: Compilation Failure
gurpreetsainisalesforce Jan 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update: Revert with sharing and security enforced
gurpreetsainisalesforce committed Aug 22, 2023

Verified

This commit was signed with the committer’s verified signature.
Doctor-wu Doctor Wu
commit 060e425bef3f091ab43fb0aa1abbd3c2623c0ce0
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This must implement the sfdc_checkout.CartInventoryValidation interface
// in order to be processed by the checkout flow and used for your Check Inventory integration.
global class B2BCheckInventorySample implements sfdc_checkout.CartInventoryValidation {
global with sharing class B2BCheckInventorySample implements sfdc_checkout.CartInventoryValidation {
// You MUST change this to be your service or you must launch your own Heroku Service
// and add the host in Setup | Security | Remote site settings.
private static String httpHost = 'https://example.com';
@@ -11,7 +11,7 @@ global class B2BCheckInventorySample implements sfdc_checkout.CartInventoryValid
try {
// Get all SKUs and their quantities from cart items.
Map<String, Decimal> quantitiesFromSalesforce = new Map<String, Decimal>();
for (CartItem cartItem : [SELECT Sku, Quantity FROM CartItem WHERE CartId = :cartId AND Type = 'Product']) {
for (CartItem cartItem : [SELECT Sku, Quantity FROM CartItem WHERE CartId = :cartId AND Type = 'Product' WITH SECURITY_ENFORCED]) {
if (String.isBlank(cartItem.Sku)) {
String errorMessage = 'The SKUs for all products in your cart must be defined.';
return integrationStatusFailedWithCartValidationOutputError(
12 changes: 6 additions & 6 deletions examples/b2b/checkout/integrations/classes/B2BDeliverySample.cls
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This must implement the sfdc_checkout.CartShippingCharges interface
// in order to be processed by the checkout flow for the "Shipping" integration

global class B2BDeliverySample implements sfdc_checkout.CartShippingCharges {
global with sharing class B2BDeliverySample implements sfdc_checkout.CartShippingCharges {
// You MUST change this to be your service or you must launch your own Heroku Service
// and add the host in Setup | Security | Remote site settings.
private static String httpHost = 'https://example.com';
@@ -11,7 +11,7 @@ global class B2BDeliverySample implements sfdc_checkout.CartShippingCharges {
try {
// In the Winter '21 release there should be two delivery groups per cart.
// We need to get the ID of the cart delivery group in order to create the cart delivery group methods.
Id cartDeliveryGroupId = [SELECT CartDeliveryGroupId FROM CartItem WHERE CartId = :cartId][0].CartDeliveryGroupId;
Id cartDeliveryGroupId = [SELECT CartDeliveryGroupId FROM CartItem WHERE CartId = :cartId WITH SECURITY_ENFORCED][0].CartDeliveryGroupId;

// Get the shipping options from an external service.
// We're getting information like rates and carriers from this external service.
@@ -30,7 +30,7 @@ global class B2BDeliverySample implements sfdc_checkout.CartShippingCharges {
}

// On re-entry of the checkout flow delete all previous CartDeliveryGroupMehods for the given cartDeliveryGroupId
delete [SELECT Id FROM CartDeliveryGroupMethod WHERE CartDeliveryGroupId = :cartDeliveryGroupId];
delete [SELECT Id FROM CartDeliveryGroupMethod WHERE CartDeliveryGroupId = :cartDeliveryGroupId WITH SECURITY_ENFORCED];

// Create a CartDeliveryGroupMethod record for every shipping option returned from the external service
for (ShippingOptionsAndRatesFromExternalService shippingOption: shippingOptionsAndRatesFromExternalService) {
@@ -234,10 +234,10 @@ global class B2BDeliverySample implements sfdc_checkout.CartShippingCharges {
// ReferenceNumber: Reference Number from External Service
// IsActive: If this Option is Active
Id productId = getDefaultShippingChargeProduct2Id();
String cartCurrency = [SELECT CurrencyIsoCode FROM WebCart WHERE Id = :webCartId][0].CurrencyIsoCode;
//String cartCurrency = [SELECT CurrencyIsoCode FROM WebCart WHERE Id = :webCartId WITH SECURITY_ENFORCED][0].CurrencyIsoCode;
CartDeliveryGroupMethod cartDeliveryGroupMethod = new CartDeliveryGroupMethod(
CartDeliveryGroupId = cartDeliveryGroupId,
CurrencyIsoCode = cartCurrency,
//CurrencyIsoCode = cartCurrency,
ExternalProvider = shippingOption.getProvider(),
Name = shippingOption.getName(),
ShippingFee = shippingOption.getRate(),
@@ -281,7 +281,7 @@ global class B2BDeliverySample implements sfdc_checkout.CartShippingCharges {
// Check to see if a Product2 with that name already exists.
// If it doesn't exist, create one.
String shippingChargeProduct2Name = 'Shipping Charge';
List<Product2> shippingChargeProducts = [SELECT Id FROM Product2 WHERE Name = :shippingChargeProduct2Name];
List<Product2> shippingChargeProducts = [SELECT Id FROM Product2 WHERE Name = :shippingChargeProduct2Name WITH SECURITY_ENFORCED];
if (shippingChargeProducts.isEmpty()) {
Product2 shippingChargeProduct = new Product2(
isActive = true,
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

// This must implement the sfdc_checkout.CartPriceCalculations interface
// in order to be processed by the checkout flow and used for your Price Calculations integration.
global class B2BPricingSample implements sfdc_checkout.CartPriceCalculations {
global with sharing class B2BPricingSample implements sfdc_checkout.CartPriceCalculations {
// You MUST change this to be your service or you must launch your own Heroku Service
// and add the host in Setup | Security | Remote site settings.
private static String httpHost = 'https://example.com';
@@ -16,11 +16,11 @@ global class B2BPricingSample implements sfdc_checkout.CartPriceCalculations {
// In the real-life scenario, the ID will probably be an external ID
// that identifies the customer in the external system,
// but for simplicity we are using the Salesforce ID in this sample.
Id customerId = [SELECT OwnerId FROM WebCart WHERE id = :cartId][0].OwnerId;
Id customerId = [SELECT OwnerId FROM WebCart WHERE id = :cartId WITH SECURITY_ENFORCED][0].OwnerId;

// Get all SKUs and their sale prices (customer-specific prices) from the cart items.
Map<String, Decimal> salesPricesFromSalesforce = new Map<String, Decimal>();
for (CartItem cartItem : [SELECT Sku, SalesPrice FROM CartItem WHERE CartId = :cartId AND Type = 'Product']) {
for (CartItem cartItem : [SELECT Sku, SalesPrice FROM CartItem WHERE CartId = :cartId AND Type = 'Product' WITH SECURITY_ENFORCED]) {
if (String.isBlank(cartItem.Sku)) {
String errorMessage = 'The SKUs for all products in your cart must be defined.';
return integrationStatusFailedWithCartValidationOutputError(
14 changes: 7 additions & 7 deletions examples/b2b/checkout/integrations/classes/B2BTaxSample.cls
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This must implement the sfdc_checkout.CartTaxCalculations interface
// in order to be processed by the checkout flow and used for your Taxes integration.

global class B2BTaxSample implements sfdc_checkout.CartTaxCalculations {
global with sharing class B2BTaxSample implements sfdc_checkout.CartTaxCalculations {
// You MUST change this to be your service or you must launch your own Heroku Service
// and add the host in Setup | Security | Remote site settings.
private static String httpHost = 'https://example.com';
@@ -11,7 +11,7 @@ global class B2BTaxSample implements sfdc_checkout.CartTaxCalculations {
sfdc_checkout.IntegrationStatus integStatus = new sfdc_checkout.IntegrationStatus();
try {
// If there are any Products with null SKU throw exception.
CartItem[] nullSKUs = [SELECT Id FROM CartItem WHERE CartId=:cartId AND Type='Product' AND Sku=null];
CartItem[] nullSKUs = [SELECT Id FROM CartItem WHERE CartId=:cartId AND Type='Product' AND Sku=null WITH SECURITY_ENFORCED];
if (!nullSKUs.isEmpty()) {
String errorMessage = 'The SKUs for all products in your cart must be defined.';
return integrationStatusFailedWithCartValidationOutputError(
@@ -26,11 +26,11 @@ global class B2BTaxSample implements sfdc_checkout.CartTaxCalculations {
// In the future, when multiple delivery groups can be created,
// this sample should be updated to loop through all delivery groups.
// We need to get the ID of the delivery group in order to get the DeliverTo info.
Id cartDeliveryGroupId = [SELECT CartDeliveryGroupId FROM CartItem WHERE CartId = :cartId][0].CartDeliveryGroupId;
CartDeliveryGroup deliveryGroup = [SELECT DeliverToState, DeliverToCountry FROM CartDeliveryGroup WHERE Id = :cartDeliveryGroupId][0];
String taxType = [SELECT TaxType FROM WebCart WHERE Id = :cartId][0].TaxType;
Id cartDeliveryGroupId = [SELECT CartDeliveryGroupId FROM CartItem WHERE CartId = :cartId WITH SECURITY_ENFORCED][0].CartDeliveryGroupId;
CartDeliveryGroup deliveryGroup = [SELECT DeliverToState, DeliverToCountry FROM CartDeliveryGroup WHERE Id = :cartDeliveryGroupId WITH SECURITY_ENFORCED][0];
String taxType = [SELECT TaxType FROM WebCart WHERE Id = :cartId WITH SECURITY_ENFORCED][0].TaxType;

Map<ID, CartItem> cartItemsMap = new Map<ID, CartItem>([SELECT Id, Sku, Quantity, TotalLineAmount, AdjustmentAmount, (Select Id, TotalAmount from CartItemPriceAdjustments) FROM CartItem WHERE CartId = :cartId]);
Map<ID, CartItem> cartItemsMap = new Map<ID, CartItem>([SELECT Id, Sku, Quantity, TotalLineAmount, AdjustmentAmount, (Select Id, TotalAmount from CartItemPriceAdjustments) FROM CartItem WHERE CartId = :cartId WITH SECURITY_ENFORCED]);

// Following snippet of code fetches a mocked static json response from getDataFromStaticResponse.
// Another example that demonstrates how to call a live 3rd party HTTP Service to fetch the desired
@@ -95,7 +95,7 @@ global class B2BTaxSample implements sfdc_checkout.CartTaxCalculations {
// See the readme section about error handling for details about how to create that notification.
return integrationStatusFailedWithCartValidationOutputError(
integStatus,
String.format('System.Label.ERROR_EXCEPTION_OCCURRED', new List<String>{ e.getTypeName(), e.getMessage() }),
'An exception of type ' + e.getTypeName() + ' has occurred: ' + e.getMessage(),
jobInfo,
cartId
);