Page 1 of 1
Payment.Capture() and Order.PaymentStatus
Posted: Mon Dec 15, 2008 6:53 pm
by AbleMods
take a look at this code:
Code: Select all
If _Order.PaymentStatus <> OrderPaymentStatus.Paid Then
For Each _Payment As Payment In _Order.Payments
If _Payment.PaymentStatus = PaymentStatus.Authorized Then
' capture payment and exit loop
_Payment.Capture(_Order.TotalCharges, True, True, "127.0.0.1")
Exit For
End If
Next
If _Order.PaymentStatus <> OrderPaymentStatus.Paid Then
' problem capturing payment, abort auto-processing
Return
End If
End If
First, notice the elegant readability of VB code
Second, despite a single authorization being correctly captured the _Order.PaymentStatus is not reporting as paid immediately after payment capture.
Why? Is there some sort of child-update that has to occur on _Order to reflect the change in payment status?
Re: Payment.Capture() and Order.PaymentStatus
Posted: Mon Dec 15, 2008 7:08 pm
by nickc
Here's what I do after capture, which seems to sort things out:
Code: Select all
order.UpdateOrderStatus((int)CommerceBuilder.Orders.OrderAction.ProcessPayments);
Re: Payment.Capture() and Order.PaymentStatus
Posted: Mon Dec 15, 2008 8:16 pm
by afm
Or, more elegantly
Code: Select all
_Order.UpdateOrderStatus(CType(CommerceBuilder.Orders.OrderAction.ProcessPayments, Integer))
You could also reload the order and get any other changes at the same time.
Re: Payment.Capture() and Order.PaymentStatus
Posted: Mon Dec 15, 2008 8:42 pm
by AbleMods
Interesting - didn't realize I needed to call the Updatestatus on the order but makes sense. Just figured it was a dynamic Get/Set and returned current order status.
A number of things are odd about how the code functions:
1. Even if I step through at debugger and fire the capture, it'll continually report "CapturePending" as the _Payment.PaymentStatus. Can sit there for 30 secs and still do the same.
2. The async parameter of the capture function seems to have no effect. I presumed it would pause code if set True i.e. wait until capture response received before proceeding. This doesn't appear to be the case. Tried both ways and didn't notice any difference. Shrug.
3. If indeed the payment is "CapturePending" and not "Captured", then I guess _Order status is correct - technically the payment hasn't yet been officially captured.
Thanks for the help, I think your suggestion will fix it.
Re: Payment.Capture() and Order.PaymentStatus
Posted: Mon Dec 15, 2008 10:03 pm
by draneb
I wished I understood you all.
Is this what you are referring to...
I will go into my Admin and I will see an order labeled "New". If I go into the Order Payments there is credit card information there but I have to select "Authorize Payment" and then it will go through (and marked Paid Full) or be declined.
But, I use Authorize.net and all this is supposed to happen before it reaches me.
I don't understand why I receive some orders like this...
Like your post title, it seems like it is not Capturing the payment automatically sometimes.
Is this what you are discussing in this thread?
Re: Payment.Capture() and Order.PaymentStatus
Posted: Mon Dec 15, 2008 10:29 pm
by AbleMods
Close, but no
What we're doing is trying to capture order payments through our own code on the back-end of things.
I've written some new automation for my solunar fishing and hunting times. Now, when a new order is saved to my store, a routine I've written fires off.
It first checks the order for solunar times being purchased. If they are purchased, it captures the payment, calculates the solunar times, emails the customer with the times attached as a PDF and then marks the order as shipped.
Once I get it done, I will have completely eliminated the daily processing steps for filling fishing/hunting times orders. Next stop, auto-upload of orders to my distributors. Then it'll be auto-download of distributor invoices so I can automatically post shipments and tracking numbers.
I'm on a huge automation kick this month - I have named it "Operation Plate Too Full "

Re: Payment.Capture() and Order.PaymentStatus
Posted: Wed Dec 17, 2008 11:39 am
by nickc
I was wondering what would happen when you hit 2,000 posts.
Welcome, you are.
Re: Payment.Capture() and Order.PaymentStatus
Posted: Wed Dec 17, 2008 1:30 pm
by AbleMods
Wow
I never even noticed it until you said something. Thanks!
Now that I'm on the Jedi Council, maybe I can get some things done around here
