• Resolved deepsea

    (@deepsea)


    Hi Stephen,

    First of all, thanks for this great work.

    I have been trying to get this to work on my website. However, I am facing some problems. Specifically, when a user is logged in, I get the following error

    Error: Invalid string: {“amount”=>”2348”, “currency”=>”usd”, “token”=>”tok_111111111111111111”, “description”=>”Charge for %[email protected]”, “chosen_card”=>”0”, “card”=>{“name”=>”aaa aaa”, “billing_email”=>”[email protected]”, “address_line1″=>”100 Main Street”, “address_line2″=>”Apt 1111”, “address_zip”=>”93025”, “address_state”=>”CA”, “address_country”=>”US”}, “errors”=>””}
    Transaction Error: Could not complete your payment.

    The payment attempt gets hit in the backend under order in woocommerce. However, the status is pending. Also, the following order note with empty message is added to the order page in the backend

    S4WC Credit Card Payment Failed with message: “”

    Finally, no payment shows up at the dashboard of stripe.

    Note that the above phenomenon only happens if a user is logged in.

    It would be great if you could look into this.

    Thanks.

    Simon

    https://www.ads-software.com/plugins/stripe-for-woocommerce/

Viewing 8 replies - 16 through 23 (of 23 total)
  • Plugin Author Stephen Zuniga

    (@stephenzuniga001)

    Hey, my email is [email protected]

    Thanks.

    Thread Starter deepsea

    (@deepsea)

    just sent you the link

    Plugin Author Stephen Zuniga

    (@stephenzuniga001)

    I don’t know if this is too technical, but I’ll try to keep it easy to follow.

    Basically, the credit card number is valid and the entire form is valid before submission, so that’s all fine and dandy. When you do a guest checkout without creating an account and using the 4000000000000069 card number it gives an error saying that the card has expired. Perfectly acceptable behavior.

    Once you create an account you hit this part of the code: https://github.com/woothemes/woocommerce/blob/master/includes/class-wc-checkout.php#L560

    What that’s doing is checking if you checked the create an account box (or it’s mandatory), and if so it creates a user. It then reloads the page here: https://github.com/woothemes/woocommerce/blob/master/includes/class-wc-checkout.php#L574

    After the page is reloaded and the new account is logged in, it recalculates the cart totals (and this is the only reason the account is created here) to see if there are role based discounts. Now we run into the normal process that you would have had if you didn’t create an account here: https://github.com/woothemes/woocommerce/blob/master/includes/class-wc-checkout.php#L591

    This is the point that we have a problem, the page is reloaded, all of the work that Stripe did with the old card is now lost. Since it’s all done in the browser for added security, I can’t save it on the server since that defeats the purpose, so once the page is reloaded we’re back at square one.

    I have to somehow save the stripe token for resubmission after the page reloads and the user is logged in, I’ll probably have to use a cookie. This is all speculation, but that seems like the appropriate course.

    Thread Starter deepsea

    (@deepsea)

    this makes sense. thanks.

    Plugin Author Stephen Zuniga

    (@stephenzuniga001)

    This should be fixed now (on github), I just unset the reload_checkout so it doesn’t refresh with a bad card. So the expected behavior should be the same as any other checkout process.

    If the card is declined for whatever reason, a user account is created but the page doesn’t refresh, instead the page is scrolled to the errors to display “Your card has been declined” (or whatever the message should be).

    Once a valid card is input, then the checkout goes through like normal and the user is redirected to the thank you page. Let me know if it works for you or you find some other bug.

    Thanks for the help, I want to fix a few other things before releasing this to WordPress to make sure this release is not as full of bugs as the last one was.

    Thread Starter deepsea

    (@deepsea)

    I tried 1.24 and it looks like if a user uses a valid card AFTER trying an invalid card, the payment processing page will never get out from the spinning dots.

    This is the sequence of events

    1) user check out with create an account box checked
    2) users input an invalid card “4000000000000069”
    3) error msg shown at the top of the page
    4) user got created at the backend
    5) all the fields at the checkout page is still filled up.
    6) resubmit the form with a valid card (the rest of the field unchanged)
    7) the page never gets out from the spinning dots

    Plugin Author Stephen Zuniga

    (@stephenzuniga001)

    Okay, so I spammed your site a few times and I’m done for now. I can’t replicate it exactly but I am able to come up with another problem that seems similar enough. If you checkout with the bad card then change an address field it removes the payment form and puts a ‘-1’ in it’s place. So that’s kind of bad, and should probably be fixed. Hopefully it fixes the problem you’re having.

    I’ll update you soon.

    Thread Starter deepsea

    (@deepsea)

    okay, sounds good. thanks. I will put the site back to password protected.

Viewing 8 replies - 16 through 23 (of 23 total)
  • The topic ‘Error: Invalid string: {…} when user is logged in’ is closed to new replies.