0

Background: Our company uses a billing system called Zuora, which integrates and syncs with Salesforce, to handle our customers subscriptions. This application (Zuora) also includes a custom Quoting interface, custom product catalog, etc. Our team uses the Zuora UI (visualforce) to build quotes, the customers then sign the agreements for those quotes, and an outbound API (part of the managed package) sends the quote and associated products to the billing system for processing.


Scenario: We are working on building an eCommerce platform. However, rather than integrating directly to Zuora, we'd like to integrate with Salesforce. Our reason for this is because we want to keep consistent records in Salesforce regarding all opportunities and quotes, and by pushing the data straight into Zuora we would bypass ever having those records created in Salesforce.

Zuora has a pretty robust set of classes/objects/methods that allows us to build and modify quotes through apex with ease, so I built an apexREST endpoint to allow the eCommerce portal to pass all of the relevant account/contact/credit card/product data to the endpoint, and then I build all of the records behind the scenes. Once I am finished building the quote and associated products, I initiate the outbound API method (from the managed package) to send that new quote to Zuora for billing.

Problem/Challenge: Just because the customer gave us credit card data and we created the quote and products in Salesforce to send to Zuora, doesn't mean that the customers credit card will be accepted by Zuora. It could decline for any number of reasons (lost/stolen card, not enough funds, general errors, etc). My challenge is that, in an ideal scenario, I would ONLY return a 200 Success from my apexREST endpoint if/when the quote is 100% processed with no errors. Unfortunately this has to happen in a separate transaction since it requires an outbound API callout to Zuora, and then Zuora kicks back an error (if there is one) and updates the quote with that error message.

I'd like to 'wait' until I confirm that Zuora accepted the entire quote without any issues before I return a 200 OK response from my endpoint. I'd hate to return a 200 OK to the customer buying online, only to have the card decline on the back-end and result in a bad customer experience/confusion since everything appears fine but actually isn't. Is something like this even possible? Can I build some sort of 'polling' logic into my apexREST endpoint to have it check the quote a few times until the status changes, and then return only after a success? If not, can anyone provide any other suggestions that may allow for this type of front-end experience?

  • I think your issue is that the ecomm transaction should validate the credit card details long before the SFDC endpoint is ever requested. By way of example, in our org, Shopify is used for the ecomm platform and only accepted-by-shopify orders ever invoke the SFDC REST webhook – cropredy Nov 23 '17 at 5:08
  • Our eComm currently validates that the card is real, but just because it's real doesn't mean it won't be declined by an issuing bank when zuora tries to bill for the full price of the transaction. Are your Shopify validated transactions being validated for the full charge amount before being sent to the SF endpoint? – Morgan Marchese Nov 23 '17 at 22:30
  • Additionally, we need to run our transactions through SF before sending them to zuora proper because the zuora SF app has a built in rules engine that applies special discounts to the transaction before it reaches zuora, that's why we're using zuora SF in the middle – Morgan Marchese Nov 23 '17 at 22:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.