Order Issues with Generating Invoice and POSTing payment results

Cleveland Metroparks asked on March 29, 2022 21:50

Summary: We are using Kentico 11 to handle ecommerce transactions and integrating them into our mobile app. So, we are posting the mobile app transactions into Kentico using the REST API. We have two issues with the end of the transaction process and we don't know if they are related or not, or where we might be going wrong.

A. Using the Kentico REST APIs, how can we automatically generate an order invoice so that it populates the order confirmation email and then sends the email?

Initially, we were submitting the transaction to the order module as a complete "payment received"/complete transaction payload. This didn't generate an invoice, and when we manually generated it, it wasn't populated with the order items. So we then created the order as New using the API, and then update it to Payment Received once the payment is complete. Manually generating the invoice then populated it with the right sku/items. However the order confirmation email is still blank. We assume that the order confirmation email populates itself from the information that's in the invoice, and if the invoice doesn't exist, the order confirmation email sends a blank result.

B. The billing "Payment Result" that we get from the payment processor that we send via API POST is getting stripped or is not accepted by the Kentico order module. We don't know why, and we don't know what to do to get it recorded. We also don't know if items A and B are related.

Recent Answers

Brenden Kehren answered on April 6, 2022 06:55

I believe the first item may be related to the orders status being changed. Out of the box when an order is created, it's created with a NEW order status. When payment is submitted and approved you can tell it to mark the other as paid. I believe this triggers the order to generate the invoice which can then be emailed out.

I believe the second issue could be slightly related to the first one in the fact that the order needs to be placed in a status flagged as paid. BUT you cannot directly set the payment result value. This result needs to be created as its own object which in turn updates the the orders status and sets the results from the payment provider.

0 votesVote for this answer Mark as a Correct answer

Cleveland Metroparks answered on April 6, 2022 15:46

Thank you, Brendan - we have tried POSTing the order as NEW first, and then updating to PAYMENT RECEIVED, but that didn't help. Since the entire transaction/cart process takes place in the mobile app, our current thought is that we might need to create a shopping cart in Kentico via the API instead of just POSTing directly to the order table. I'll update with more info as we discover it.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 6, 2022 15:51

There are a lot of activities that happen with the regular Kentico C# API that I'm not sure the REST API handles OOTB. Simply dumping the order and order items into the database tables, doesn't automatically trigger any of the other necessary API calls needed to perform the proper results for your application.

What I'd suggest is create a custom endpoint that simply takes an order object with items and inside that custom endpoint, you perform the actions via the Kentico C# API to do your work. I think you'll have a much better result than if you were to continue to force the REST API to do the work it can't.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.