Error in column TotalCharges when Do a Payment
Posted: 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();
}
}
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();
}
}