Developer forum

Forum » Development » Capturing through the API

Capturing through the API

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

Is it possible to capture orders through the API? We have a site with many orders and the finance department would like to automate capturing through Dynamicweb. We can handle the selection of orders that need to be captured just fine, but I don't know yet how to do the actual capture using the API. Can this be automated or does it always require the context of a logged in user in the backend? Any pointers would be highly appreciated.

Imar


Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
This post has been marked as an answer

Hi Imar,

There are a couple of ways to accomplish capturing multiple orders.

One way is through the Administration where you can check the box next to the orders you wish to capture then click "Capture orders" in the Ribbon. This will start the process of capturing all selected orders.

You can also automate the process using Scheduled Tasks and the API. You could create a Scheduled Task that fetches all the relevant orders using the API or some custom query. Once you have the Order objects and made the relevant checks, you simply need to call order.Capture(). You can then look at the resulting OrderCaptureInfo to see how it went. If the payment method used does not support capture, the result will be null.

Hope this gives you the pointers you need :)

- Jeppe

Votes for this answer: 1
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi Jeppe,

Thanks; it's the Capture method I was looking for. I assume this does the same thing as the UI and update the status info in the order as well?

Imar

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Glad to hear it :)

The Capture method does indeed save the capture information, just be aware that it creates a new instance of the order from the database and saves that. It also sets the CaptureAmount and CaptureInfo properties on your instance but does not save it. I mention this just so you know, that even though the capture information is saved to the database, other changed fields are not and you need to save the order manually.

 

You must be logged in to post in the forum