in

dashCommerce

An ASP.NET Open Source e-Commerce Application

Coupon Provider Errors

Last post 10-18-2008 4:53 AM by hiskeyd. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 08-30-2008 6:46 AM

    Coupon Provider Errors

     Hi,

    I'm trying to use the percent off coupon provider, but when I enable it two things go wrong.  Number one, the continue button doesn't work unless the credit card info is already put in. 

     The second more troubling error is that if any coupon is put in for a discount i get a message saying the transaction has completed (although it hasn't and nothing gets charged), but that the total for the items was less than the total that was attempted to charge.

    I'm guessing what is going on here is that the total for the items says, for example, $19.99, but then there is say $3 off in the coupon that is subtracted from the order total.  But then perhaps when it is getting sent to paypal for processing the $19.99 is what is being sent + shipping + tax, but then the total is less then the sum of those because of the coupon.

    Anyways, so it doesn't work at all.  Any ideas? (btw orders process fine with no coupons)

  • 08-30-2008 7:07 AM In reply to

    Re: Coupon Provider Errors

     the exact error as logged in the error logger is as follows:

    MettleSystems.dashCommerce.Store.Services.PaymentService.PayPal.PayPalServiceException:  This transaction has been completed, but the total of items in the cart did not match the total of all items..
       at MettleSystems.dashCommerce.Store.Services.PaymentService.PayPal.PayPalService.DoDirectPayment(Order order, Boolean authorizeOnly) in C:\Users\Daven\Documents\Visual Studio 2008\WebSites\CrackedTees2\Store\Services\PaymentService\PayPal\PayPalService.cs:line 757
       at MettleSystems.dashCommerce.Store.Services.PaymentService.PayPalProPaymentProvider.Charge(Order order) in C:\Users\Daven\Documents\Visual Studio 2008\WebSites\CrackedTees2\Store\Services\PaymentService\PayPalProPaymentProvider.cs:line 148
       at MettleSystems.dashCommerce.Store.Services.PaymentService.PaymentService.Charge(Order order) in C:\Users\Daven\Documents\Visual Studio 2008\WebSites\CrackedTees2\Store\Services\PaymentService\PaymentService.cs:line 157
       at MettleSystems.dashCommerce.Store.OrderController.Charge(Order order, String userName) in C:\Users\Daven\Documents\Visual Studio 2008\WebSites\CrackedTees2\Store\Controllers\OrderController.cs:line 455
       at MettleSystems.dashCommerce.Web.checkout.btnProcessOrder_Click(Object sender, EventArgs e) in C:\Users\Daven\Documents\Visual Studio 2008\WebSites\CrackedTees2\Web\checkout.aspx.cs:line 561

     

  • 08-31-2008 8:19 AM In reply to

    Re: Coupon Provider Errors

     UPDATE

    It turns out paypal is processing the transaction with the coupon'd amount.  But due to the fact that paypal is also throwing the above exception, my dashcommerce website is not completing the transaction on my end.

    So obviously the "hack" fix would be to just ignore that specific excpetion from paypal and if it is thrown, just complete the order anyways.

    The better thing to do would be to actually fix it, but i'm not 100% sure what to do here.  I'm assuming what is happening (now that i can see that paypal is processing the coupon'd amount correctly).  That in the order they are being sent they see the non-discounted item total, at say $30 + shipping/tax, but then the item total they are being asked to charge is say $20 + shipping/tax.  

    So i guess the fix would be to make the discounted item total match the actual item total somehow.  So maybe when the "process order" button is clicked before sending off the order to be processed by paypal i should just reset the item total to whatever the discounted item total should be, then get rid of the discount.  Then before before everything gets recorded on the dashcommerce website's end, re-put in the discount and reset the item total, so that on the reciept everything looks right to the end user.  Would this be possible/work?

     Is there a better way?  I'm a bit confused about what is going on exactly on the process order click event even after looking at it.  Any help would be much appreciated.  Thanks!

  • 09-05-2008 2:02 AM In reply to

    Re: Coupon Provider Errors

    anybody?
  • 09-10-2008 5:33 AM In reply to

    Re: Coupon Provider Errors

    ok, so i've fixed the problem with having to enter the credit card info before the coupon "continue" button will work. Basically what is going wrong here is the clientside required field validator javascript on the CC fields isn't letting the page postback. So you can just turn off the clientside validation (it all happens asynchronously anyways). Then be sure and add this function to the top of the CC continue button's event to still make sure things are being validated: if (!Page.IsValid) { acCheckout.SelectedIndex--; return; } So then this makes sure the page is validated and sets the transition index back one, so it will transition back to the CC panel so they can see the required field error.
  • 09-24-2008 11:38 AM In reply to

    Re: Coupon Provider Errors

    I'm not able to completely follow your fix.  Can someone help me here?

    I made the following changes so far:
    checkout.aspx line 208 old
    <asp:TextBox runat="server" ID="txtCreditCardNumber" CssClass="longtextbox" /><asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="txtCreditCardNumber" ErrorMessage="*" /><br /><br />
    line 208 new
    <asp:TextBox runat="server" ID="txtCreditCardNumber" CssClass="longtextbox" /><br /><br />

    line 210 old
    <asp:TextBox runat="server" ID="txtCreditCardSecurityNumber" CssClass="smalltextbox" /><asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtCreditCardSecurityNumber" ErrorMessage="*" /><br /><br />
    Line 210 new
    <asp:TextBox runat="server" ID="txtCreditCardSecurityNumber" CssClass="smalltextbox" /><br /><br />

    So far, is that correct?  And where do I put the "if (!Page.IsValid) { acCheckout.SelectedIndex--; return; }" statement?

  • 09-24-2008 12:23 PM In reply to

    Re: Coupon Provider Errors

    actually you keep the RequiredFieldValidators, but then turn their clientscript off (i believe it is "EnableClientScript="false" in their attributes fields, so <asp:RequiredFieldValidator EnableClientScript="false" ...).  Then put the if(!Page.IsValid)... lines in your process payment function.

    There is also another option that is slightly more complicated where you keep the client-side validation and then you can just use javascript to detect whether the required field validators are hidden or not by accessing the style properties.  So then if they are hidden then it validated, if they are not it didn't so re-set the selected index back to the current index.  I ended up changing mine to this way because of some other changes i made to the checkout page, but the first option works just as well, so it really doesn't matter.

  • 09-29-2008 10:38 AM In reply to

    • yocuteem
    • Top 10 Contributor
    • Joined on 03-16-2008
    • Philadelphia Area
    • Posts 67

    Re: Coupon Provider Errors

    Hi, would you mind posting the javascript changes that you made?

    Thanks,

    Tim

    hiskeyd:

    actually you keep the RequiredFieldValidators, but then turn their clientscript off (i believe it is "EnableClientScript="false" in their attributes fields, so <asp:RequiredFieldValidator EnableClientScript="false" ...).  Then put the if(!Page.IsValid)... lines in your process payment function.

    There is also another option that is slightly more complicated where you keep the client-side validation and then you can just use javascript to detect whether the required field validators are hidden or not by accessing the style properties.  So then if they are hidden then it validated, if they are not it didn't so re-set the selected index back to the current index.  I ended up changing mine to this way because of some other changes i made to the checkout page, but the first option works just as well, so it really doesn't matter.

    Tim
  • 10-04-2008 10:56 AM In reply to

    Re: Coupon Provider Errors

    The first part of the original post can be solved by changing line 755 of PaypalService.cs from:

     if (directPaymentResponse.Ack != AckCodeType.Success || directPaymentResponse.Ack != AckCodeType.SuccessWithWarning) {

     To:

    if (directPaymentResponse.Ack != AckCodeType.Success && directPaymentResponse.Ack != AckCodeType.SuccessWithWarning) {

     The logical OR should be a logical AND.

    The warning paypal is sending back I believe is a round error of the tax of the line items as they are rounded individually to 2 decimals. The total being charged is correct but the line item tax does not sum to the order total tax because of those little rounded 1000ths. The offending code can be found on the same page at line 692.

    It took a long time to trace this down. I hope this helps save somebody some time and/or gets added to the build.

     

    C.

  • 10-10-2008 10:17 PM In reply to

    • Corey10e
    • Top 25 Contributor
    • Joined on 08-06-2008
    • Hooper, UT
    • Posts 43

    Re: Coupon Provider Errors

    You are making this too complicated :)  Just put validationgroup="CC" on each of the RequiredFieldValidators and the Continue button of the CreditCard area.... Thats all I had to do.

    Corey10e
    Jumpin Pages LLC
    See our new addon's at www.dashcommerce.com
  • 10-18-2008 4:53 AM In reply to

    Re: Coupon Provider Errors

     ok, finally located the actual cause of the error and the fix.  Specifically in the PaypalService.DoExpressCheckout() under the "basic payment information"  you need to make the following change:

    paymentDetails.ItemTotal = GetBasicAmount(decimal.Round(order.SubTotal, currency.CurrencyDecimals));

    change to

    paymentDetails.ItemTotal = GetBasicAmount(decimal.Round((order.SubTotal - order.DiscountAmount), currency.CurrencyDecimals));

     I just made the change and tested it and it worked without returning any errors or warnings.

Page 1 of 1 (11 items)