payments not saving

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
harryhair5
Ensign (ENS)
Ensign (ENS)
Posts: 14
Joined: Fri Oct 15, 2010 2:05 pm

payments not saving

Post by harryhair5 » Mon Oct 01, 2012 10:17 am

Hi -

I've written a custom billing app that successfully creates and saves orders. When the order is saved, the payment status is paid and shows up as paid on the admin order manager list as paid, but when I view the details of the order in the admin order manager, the payment status automatically switches to unpaid.

I looked in the database and find no entry in table payments even though I am doing this:

Payment recentPayment = new Payment();
recentPayment.OrderId = 7600;
recentPayment.PaymentId = 8;
recentPayment.PaymentMethodName = "Credit Card";
recentPayment.Amount = 21.00M;
recentPayment.CurrencyCode = "USD";
recentPayment.PaymentDate = DateTime.Now;
recentPayment.PaymentStatusId = 5;
recentPayment.ReCrypt = false;
//recentPayment.UpdateStatus(PaymentStatus.Completed);
recentPayment.CompletedDate = DateTime.Now;
SaveResult result = new SaveResult();
result = recentPayment.Save();

and I receive the result of: RecordUpdated

Am I forgetting to set or save something??

Thanks for your help...

Harry

mtrujillo86
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 34
Joined: Wed Feb 29, 2012 4:45 pm

Re: payments not saving

Post by mtrujillo86 » Mon Oct 01, 2012 2:41 pm

We do a lot of this type of stuff.

The reason is your just adjusting the order to be "paid". But it's not really paid.

You need to attach a true payment. It must be a "processed" payment also. Then the order will not be marked unpaid when viewing the details.

harryhair5
Ensign (ENS)
Ensign (ENS)
Posts: 14
Joined: Fri Oct 15, 2010 2:05 pm

Re: payments not saving

Post by harryhair5 » Tue Oct 02, 2012 7:41 am

Thanks for your reply - I've really been racking my brain here. So, is the order then

Create an Order
Create a Payment
Create a Transaction

Are there any other items that need to be created in order for the paid status to stick?

mtrujillo86
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 34
Joined: Wed Feb 29, 2012 4:45 pm

Re: payments not saving

Post by mtrujillo86 » Tue Oct 02, 2012 12:21 pm

I don't think so. After we attached a successful *fake* payment the order status wouldn't change.

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: payments not saving

Post by AbleMods » Thu Oct 25, 2012 9:42 am

Easiest way is to add the Payment object to the Payments collection on the Order object.

So:

Add items to the _Basket object
Call _Basket.Checkout()
Get the OrderId value from the CheckoutResponse object
Load up an Order object

Now you can create a new Payment object. Then add the Payment object to the Order object.
_Order.Payments.Add(_Payment);

Finally, save the Order object.
_Order.Save();

Works the same way with OrderNotes, LineItems etc. Essentially all the Able primary classes will check if any child collections are dirty in the base .Save() routine. If so, those child classes are written first and any trigger events fire automatically.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

Post Reply