• steve-wgaca
  • NEWBIE
  • 0 Points
  • Member since 2020
  • CTO
  • WGACA LLC

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 2
    Replies
I am doing a pretty basic Order Management implementation and I've been struggling to get voids to process correctly.  Even just using the bundled Cancel Items Flow, with no changes, cancelling items does not lead to any void on the authorization.

For example:  Someone orders 2 products, $500 a piece.  The total authorization is $1000.  We have an open (uncaptured) authorization for $1000.  Then the customer cancels one of the two items using a 100% verbatim copy of the bundled Cancel Items Flow.  The item shows as cancelled on the Order Summary, but no Auth Reversal or Pending Auth Reversal amount shows up on the Order Payment Summary.  Checking with Stripe, no void call was received.  I have tried this on our other custom payment methods and the apex classes themselves are never even instantiated.

Noticing this, I tried to add the auth reversal directly to my own code:

    @future
    public static void processVoid(Id orderSummaryId, Id authorizationId,  Id accountId, Double authReversalAmount) {

        ConnectApi.AuthorizationReversalRequest req = new ConnectApi.AuthorizationReversalRequest();
        req.amount = authReversalAmount;
        req.accountId = accountId;
        ConnectApi.AuthorizationReversalResponse arr = ConnectApi.Payments.reverseAuthorization(req, authorizationId);
        

However this really doesn't work consistently and I don't know why.  Sometimes the void will make it through to the payment processor - particularly with my own payment adapters this seems to work at least some of the time.  Sometimes it won't.  Sometimes it actually happens twice (this happened with the Stripe OM adapter) and we end up voiding more than we are supposed to.  I have closely monitored the debug logs and made sure to do all my clicks through the flow extra slowly to make sure I don't have duplicate clicks / etc - there really is no rhyme or reason to it.  When it doesn't work, I'll usually get the error:

13:40:49.22 (392714288)|VARIABLE_ASSIGNMENT|[23]|inErrorCode|"ALREADY_IN_PROCESS"

This is using the Salesforce-provided Stripe OM Async adapter - which to me is almost a reference implementation so it really ought to work properly, I have seen it with my payment adapters as well.  There is really no further context - there is an expanded error message on the next line but it doesn't tell you anything else, it just repeats that.


My next work around is going to be to just skip over the whole commerce payments system and make my own direct API calls to execute the voids as normal callouts.  However, I think we all know that's a terrible kludge.  What is the right answer here?  We can't just leave these authorizations open and pending forever.  In the case of one of my payment adapters, if you don't void the authorization the customer could start receiving bills to pay off their loan when you haven't even captured yet.  The void has to be made to ensure the payment is actually cancelled.  We also get calls from customers who complain the authorization hasn't left their transaction history.  So far we have been manually voiding on the payment processors' websites which is definitely not ideal.  I would prefer that the void be made by Salesforce during the ensureRefundsAsync call (or maybe we need an ensureAuthReversalAsync call or something) and then reflect properly in the order payment summary - that would be ideal.
This post is in reference to Salesforce Order Management.

We have a requirement to allow agents to adjust the items on a customer's order.  More specifically - often we will need to remove one item from an order and add a substitute item to an order (we call this a SKU swap).  

So far, I am able to remove items from existing orders - that part is pretty well spelled out.  However, I can't find any references to any process or methods that will allow us to add a new item to an existing order.  

We do not have a good workaround in place.  Right now, the only way to do this is to refund the order and have the customer place it again.  This is not good - there is a significant risk that the customer will cancel the order and not reorder, either because they find it inconvenient or they struggle to use websites in general (maybe, a child or caregiver helped them place the original order) and don't make it to the finish line on the new order.    These sound like edge cases but they're really not, it's a very common occurence (several times a week).  We need the ability to negotiate these changes over the phone / over email and then make the changes for the customer.  We also need the ability to do all of this without returning any funds to the customer or authorizing any new charges (since typically this is a like for like swap).  

In any event - SKU swaps aren't even the only place where we need this capability.  If anyone knows how to accomplish this or has a better workaround than we do, I'm all ears!!  Thanks for any assistance.

PLEASE NOTE: I am already cross posting this in the trailblazer community as well.
I am migrating over an existing system to commerce cloud, where I need to keep track of a variety of product details as they change over time.  
 
Since unfortunately Commerce Cloud has no webhooks or other way of informing other systems of updates, I am polling OCAPI every few hours to check for any updates to all live products.
 
There are 2 fields I haven't been able to get.  They would be the start and end date of the entry for the product in the discount pricebook.  I can use the Shop API with /products/{id}/prices to get the actual prices from all pricebooks, but in the discount pricebook there is usually a date range which I also need to poll and keep up to date.  This is critical reporting information because they use these dates almost as reason codes.  There are a variety of reports and processes already built that rely on this information.
 
I can't find anywhere where I can access more information from the pricebook than just the price.  Ideally if I could just download the whole pricebook and then look up each SKU against it that would be easiest, rather than making 2K+ API calls for each item (which is the only method I've found that works right now, for getting any price data).
 
Any ideas on how to get this data in an automated, not by-hand fashion?
I have a lightning page set up to help with managing Quotes.  There are 2 canvas apps that can update the Quote on the page.  They work fine, but the highlights panel at the top of the page does not update when the canvas apps update the quote.  The canvas apps each publish an event and subscribe to that same event, so when one canvas app updates, the other canvas app does update as well.  However, I can't seem to get the outer (non-canvas) lightning page to subscribe to the same update event.

I have also tried to fire force:refreshView from the canvas apps but this has no effect.

There doesn't seem to be any way to call Sfdc.canvas.controller.subscribe from the Aura component controller.

How exactly is this supposed to be done?  I find it hard to believe they would design this whole canvas app system complete with events but then make it impossible for lightning pages to listen to their canvas components' events.  I just want the highlights panel to refresh when the canvas apps update the quote.
I have several canvas apps implemented through lightning components on a lightning record page.  The lightning page also contains a highlights panel and other panels that are native to lightning.  

When data is updated by the canvas app, I would like for the outer page components (the highlights panel, etc) to refresh with the latest data.  For example, one of the fields in the highlights panel shows the total value of a Quote - when the canvas app adds line items to the quote, I would like the value in the highlights panel to update to reflect the changes.  Right now, the user has to refresh the whole page in order to get the panel to update.

I can fire an event from the canvas app just fine - there is tons of documentation on how to do that - but there's no documentation I can find on actually subscribing to that event in the components' controllers in order to fire force:refreshView.  I'm not even sure if that's the right approach.  Has anyone managed to do something like this and if so, how?
I am migrating over an existing system to commerce cloud, where I need to keep track of a variety of product details as they change over time.  
 
Since unfortunately Commerce Cloud has no webhooks or other way of informing other systems of updates, I am polling OCAPI every few hours to check for any updates to all live products.
 
There are 2 fields I haven't been able to get.  They would be the start and end date of the entry for the product in the discount pricebook.  I can use the Shop API with /products/{id}/prices to get the actual prices from all pricebooks, but in the discount pricebook there is usually a date range which I also need to poll and keep up to date.  This is critical reporting information because they use these dates almost as reason codes.  There are a variety of reports and processes already built that rely on this information.
 
I can't find anywhere where I can access more information from the pricebook than just the price.  Ideally if I could just download the whole pricebook and then look up each SKU against it that would be easiest, rather than making 2K+ API calls for each item (which is the only method I've found that works right now, for getting any price data).
 
Any ideas on how to get this data in an automated, not by-hand fashion?