calling custom code at payment completed

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
tonz
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 48
Joined: Thu Mar 13, 2008 4:08 am

calling custom code at payment completed

Post by tonz » Mon Jul 28, 2008 4:41 pm

Is it possible to call a custom code from ablecommerce when payment completes?

We would like to write a custom code which has access to order information but would be triggerred only upon payment completion. :roll:

User avatar
sohaib
Developer
Developer
Posts: 1079
Joined: Fri Jan 23, 2004 1:38 am

Re: calling custom code at payment completed

Post by sohaib » Tue Jul 29, 2008 2:43 am

You can add your code to the event handler for CheckedOut event.
Please have a look at ConLib\OnePageCheckout.ascx.cs

User avatar
tonz
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 48
Joined: Thu Mar 13, 2008 4:08 am

Re: calling custom code at payment completed

Post by tonz » Tue Jul 29, 2008 3:54 am

Looked at the code but in our understanding the checkedout event could happen when the funds have not been captured yet. We would like our custom code to run in the background only when the funds have been captured (in the store's terminology in the admin area: "Payment status: Completed"). Is there an event like that we can connect to?

Sorry for not being completely clear in the first post. It seems my question had not reached the "Phrased Clearly" status yet :)

User avatar
sohaib
Developer
Developer
Posts: 1079
Joined: Fri Jan 23, 2004 1:38 am

Re: calling custom code at payment completed

Post by sohaib » Tue Jul 29, 2008 4:11 am

It is possible that you can make multiple payments for an order. Do you want the code to run on each successful payment or do you want the code to run when full payment for an order is made?

User avatar
tonz
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 48
Joined: Thu Mar 13, 2008 4:08 am

Re: calling custom code at payment completed

Post by tonz » Tue Jul 29, 2008 4:21 am

Bigger orders where payment would come in two separate card transaction might go through our office anyway, so for the time being we can say we don't process multiple payments.

so on full payment

thanks for your help

User avatar
sohaib
Developer
Developer
Posts: 1079
Joined: Fri Jan 23, 2004 1:38 am

Re: calling custom code at payment completed

Post by sohaib » Tue Jul 29, 2008 4:30 am

Event handler for CheckedOut event is a good place for this.
Here you can check the payment status of the order first. It the status is 'Completed' you can run your custom code otherwise not. Payments can also be made from merchant admin console. You will have to write similar code to Admin/Orders/Payments/AddPayment.aspx and CapturePayment.aspx

User avatar
tonz
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 48
Joined: Thu Mar 13, 2008 4:08 am

Re: calling custom code at payment completed

Post by tonz » Tue Jul 29, 2008 4:43 am

one problem we might have with this setup: as far as we know this ascx.cs file runs when it is calld by the corresponding ascx. So the page has to be run in order that we could check for payment status. Now what if he checks out, and funds get cleared shortly after that. One page/ascx will not run however payment status will be completed.

User avatar
tonz
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 48
Joined: Thu Mar 13, 2008 4:08 am

Re: calling custom code at payment completed

Post by tonz » Wed Jul 30, 2008 2:26 am

There are a great number of triggers defined in Ablecommerce which are triggering emails. Would it be possible to hook to these triggers? So that when an event occurs (e.g. Payment status complete), shop would not only send an email but could run our custom code.

If we could call a com component or dll from these emails with the help of nvelocity, that could help but that might not be enough. Do you know by chance whether that is possible?

Thanks

Tony

User avatar
sohaib
Developer
Developer
Posts: 1079
Joined: Fri Jan 23, 2004 1:38 am

Re: calling custom code at payment completed

Post by sohaib » Wed Jul 30, 2008 10:55 am

The event triggers defined in Ablecommerce only support email triggers at this time. Support of hooking up more generic event handlers is not there yet.

I looked in to possibility of calling external code from NVelocity. It could be possible only if the 'context' provides certain objects to get something executed. So far the context only provides you objects like $token, $store, $order, $user, $customer etc etc ... but using these objects alone it does not seem to be possible to invoke some custom external code.

User avatar
tonz
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 48
Joined: Thu Mar 13, 2008 4:08 am

Re: calling custom code at payment completed

Post by tonz » Thu Jul 31, 2008 3:01 am

thanks for your answer and research. we try to get around the problem by utilizing the payment complete triggered email. I will post if we succeed. Thanks again for your patient help

Post Reply