Error in column TotalCharges when Do a Payment

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
ALD
Ensign (ENS)
Ensign (ENS)
Posts: 12
Joined: Fri Aug 08, 2008 2:46 pm

Error in column TotalCharges when Do a Payment

Post by ALD » Wed Aug 27, 2008 11:56 am

Hi all, I'm doing a system which uses ablecommerce dll's for payments. When I try to do a payment a new row in the table ac_ErrorMessages is created with the follow text:

Cannot insert the value NULL into column 'TotalCharges',
table 'AbleCommerce.dbo.ac_Orders'; column does not allow nulls.
UPDATE fails. The statement has been terminated.


Any help will be appreciated!!. Thanks
Aldo

For reference this is the code I use to do a payment:

public Payment getPayment()
{
Payment payment = new Payment();
payment.PaymentMethodId = Convert.ToInt32(ddlCardType.SelectedValue);
payment.Amount = 1000; //TODO: Validate this amount.

AccountDataDictionary instrumentBuilder = new AccountDataDictionary();
instrumentBuilder["AccountName"] = txtNameOnCard.Text;
instrumentBuilder["AccountNumber"] = txtCardNumber.Text;
instrumentBuilder["ExpirationMonth"] = ddlMonth.SelectedValue;
instrumentBuilder["ExpirationYear"] = ddlYear.SelectedValue;
instrumentBuilder["SecurityCode"] = txtVerificationCode.Text;

payment.ReferenceNumber = Payment.GenerateReferenceNumber(txtCardNumber.Text);
payment.AccountData = instrumentBuilder.ToString();

return payment;
}

public void payWithCard()
{
Address billAddress = Token.Instance.User.Basket.User.PrimaryAddress;
if (Token.Instance.User.Basket.User.PrimaryAddress != null)
{
billAddress.Email = "";
billAddress.Address1 = txtAddress.Text;
billAddress.Address2 = txtAddress2.Text;
billAddress.City = txtCity.Text;
billAddress.Company = txtCompany.Text;
billAddress.CountryCode = ddlCountry.SelectedValue;
billAddress.FirstName = txtName.Text;
billAddress.LastName = txtName.Text;
billAddress.Phone = txtPhone.Text;
billAddress.PostalCode = txtZip.Text;
billAddress.Province = txtStateProvince.Text;
billAddress.Save();
}

Payment payment = getPayment();

CheckoutRequest checkoutRequest = new CheckoutRequest(payment);
CheckoutResponse checkoutResponse = Token.Instance.User.Basket.Checkout(checkoutRequest);

if (checkoutResponse.Success)
{
payment.OrderId = checkoutResponse.OrderId;
payment.Save();
}
}

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Error in column TotalCharges when Do a Payment

Post by mazhar » Wed Sep 03, 2008 10:48 pm

Unable to reproduce the problem the code worked. Please check the version of you application and make sure that you are running the final version.

Post Reply